public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: tegra: use flexible array member for array
@ 2026-03-15 23:10 Rosen Penev
  2026-03-19 13:27 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-03-15 23:10 UTC (permalink / raw)
  To: linux-tegra
  Cc: Linus Walleij, Thierry Reding, Jonathan Hunter,
	open list:PIN CONTROL SUBSYSTEM, open list

Simplifies allocation slightly by removing a kcalloc call and using
struct_size.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/pinctrl/tegra/pinctrl-tegra.c | 9 ++-------
 drivers/pinctrl/tegra/pinctrl-tegra.h | 2 +-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c
index 11ecbd6a9b2a..b09d7675a33a 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.c
@@ -832,19 +832,14 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
 	int fn, gn, gfn;
 	unsigned long backup_regs_size = 0;
 
-	pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL);
+	pmx = devm_kzalloc(&pdev->dev,
+			struct_size(pmx, pingroup_configs, soc_data->ngroups), GFP_KERNEL);
 	if (!pmx)
 		return -ENOMEM;
 
 	pmx->dev = &pdev->dev;
 	pmx->soc = soc_data;
 
-	pmx->pingroup_configs = devm_kcalloc(&pdev->dev,
-					     pmx->soc->ngroups, sizeof(*pmx->pingroup_configs),
-					     GFP_KERNEL);
-	if (!pmx->pingroup_configs)
-		return -ENOMEM;
-
 	/*
 	 * Each mux group will appear in 4 functions' list of groups.
 	 * This over-allocates slightly, since not all groups are mux groups.
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.h b/drivers/pinctrl/tegra/pinctrl-tegra.h
index bc7b70913b89..c74272c82828 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra.h
+++ b/drivers/pinctrl/tegra/pinctrl-tegra.h
@@ -26,7 +26,7 @@ struct tegra_pmx {
 	void __iomem **regs;
 	u32 *backup_regs;
 	/* Array of size soc->ngroups */
-	struct tegra_pingroup_config *pingroup_configs;
+	struct tegra_pingroup_config pingroup_configs[];
 };
 
 enum tegra_pinconf_param {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-19 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-15 23:10 [PATCH] pinctrl: tegra: use flexible array member for array Rosen Penev
2026-03-19 13:27 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox