On Tue, Sep 29, 2026 at 12:24:37PM -0700, Rosen Penev wrote: > Use a flexible array member to avoid allocating separately. > > Use __counted_by for extra runtime analysis. > > Signed-off-by: Rosen Penev <[email protected]> > --- > drivers/clk/tegra/clk-bpmp.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/drivers/clk/tegra/clk-bpmp.c b/drivers/clk/tegra/clk-bpmp.c > index 067a8555c4e7..15b976162b59 100644 > --- a/drivers/clk/tegra/clk-bpmp.c > +++ b/drivers/clk/tegra/clk-bpmp.c > @@ -32,7 +32,7 @@ struct tegra_bpmp_clk { > unsigned int id; > > unsigned int num_parents; > - unsigned int *parents; > + unsigned int parents[] __counted_by(num_parents); > }; > > static inline struct tegra_bpmp_clk *to_tegra_bpmp_clk(struct clk_hw *hw) > @@ -518,20 +518,14 @@ tegra_bpmp_clk_register(struct tegra_bpmp *bpmp, > unsigned int i; > int err; > > - clk = devm_kzalloc(bpmp->dev, sizeof(*clk), GFP_KERNEL); > + clk = devm_kzalloc(bpmp->dev, struct_size(clk, parents, > info->num_parents), GFP_KERNEL);
k{m,z}alloc_flex() exists for this, but there's no devm variant of
those, so I guess someone should add one. In the meantime, this is as
good as it's going to get for now:
Reviewed-by: Thierry Reding <[email protected]>
Acked-by: Thierry Reding <[email protected]>
signature.asc
Description: PGP signature

