pinctrl: tegra: use flexible array member for array
Subsystems (3)
PATCH 1/1 pinctrl: tegra: use flexible array member for array
Simplifies allocation slightly by removing a kcalloc call and using struct_size.
Signed-off-by Rosen Penev <[email protected]>
--- drivers/pinctrl/tegra/pinctrl-tegra.c | 9 ++------- drivers/pinctrl/tegra/pinctrl-tegra.h | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/pinctrl/tegra/pinctrl-tegra.c +2 -7
@@ -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.
drivers/pinctrl/tegra/pinctrl-tegra.h +1 -1
@@ -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 {
Signature · 1 line
2.53.0
Linus Walleij
maintainerQuoted 4 lines · Rosen Penev
Simplifies allocation slightly by removing a kcalloc call and using
struct_size.Signed-off-by Rosen Penev <[email protected]>
Since it's my own subsystem I could just introduce the __counted_by() and extra variable when applying, so not gonna complain about that this time.
Patch applied w/mods!
Yours,
Linus Walleij