Re: [PATCH] ASoC: tegra: ADX: convert map to flexible array

Thierry Reding <[email protected]>
Newsgroups org.kernel.vger.linux-tegra,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound
Message-ID <aobUUhKX4rGgjQzX@orome>
On Tue, Aug 18, 2026 at 01:33:45PM -0700, Rosen Penev wrote:
> On Tue Aug 18, 2026 at 4:04 AM PDT, Thierry Reding wrote:
> > On Fri, Aug 14, 2026 at 01:50:18PM -0700, Rosen Penev wrote:
> >> Replace the pointer-based map allocation with a flexible array
> >> member and use struct_size() for allocation. This simplifies
> >> the code and avoid an extra allocation.
> >>
> >> Assisted-by: opencode:big-pickle
> >> Signed-off-by: Rosen Penev <[email protected]>
> >> ---
> >>  sound/soc/tegra/tegra210_adx.c | 12 ++++--------
> >>  sound/soc/tegra/tegra210_adx.h |  2 +-
> >>  2 files changed, 5 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/sound/soc/tegra/tegra210_adx.c b/sound/soc/tegra/tegra210_adx.c
> >> index 9175598b52a7..d607ba4233b6 100644
> >> --- a/sound/soc/tegra/tegra210_adx.c
> >> +++ b/sound/soc/tegra/tegra210_adx.c
> >> @@ -677,11 +677,13 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
> >>  	void __iomem *regs;
> >>  	int err, i;
> >>
> >> -	adx = devm_kzalloc(dev, sizeof(*adx), GFP_KERNEL);
> >> +	soc_data = of_device_get_match_data(dev);
> >> +	adx = devm_kzalloc(dev,
> >> +			   struct_size(adx, map, soc_data->ram_depth * TEGRA_ADX_SLOTS_PER_WORD),
> >> +			   GFP_KERNEL);
> >
> > This is slightly hideous. Maybe add a temporary "count" variable for
> > readability?
> The reason for this is to allow a treewide conversion of this when
> devm_kzalloc_flex() gets introduced.

Huh? Why not do this right away, then? It's a waste of everyone's time
to do these two-staged "cleanups". You're making maintainers do the work
twice for no benefit whatsoever.

Thierry
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmqG1QQACgkQ3SOs138+
s6HYPxAAmHrz/w3m6t4cJ6Cyg8UPUUzrB+4HAycviPsQGrBsdElxwAkz64m5/ZAF
+y0yY1N9THj6mph0j5SKTaLLEFQZ3/Tb1Ndm1wHtCgc/e5R0LnFOoxAZ05pxnjUc
9VNfmMeF2Yhgp1UKoXkhr7wEEOQcYgFfPnxQ3S/A/YchPugWhpORoKvz605p9qNM
kvXYqyO9FMTtYQ4pW/+4LlB7HjJldBimOZ1B0DS/0tbo5ib3BT8IDGQ7ICQa4cjA
ZlA/sjm210V2uBScSdqvLS64G6Ay3cD0o6yNc4QmDi0CW7LbrZiB6FEcS6sapyLu
XfzblXx2f1cvulL9n2QrE+mcwe6uJxs6XDrBYXnj1ncfeLBd3rPDo/0pOKW3Wy+H
1QmGrvhyUML4ewnq4TXPUxghcV8Nz6daY/Iuq/Z6BCMWxvYVE8UEd4Csqy0uROFJ
rgIt7EEj0fTvUNcMYBDr/QMIT+cUrPPnQ+NlNLDmuavo50QeD9ECyuf9AdwOxGSu
as7dxsIV9xs+WmAX89LgFWV5LlVjCClcV1QlgZ1U+rzBxspYWLGlBJTVhAT9zj7f
yFiUNycpRnaXJyKrO+kRx+WQoU6gFCldLOJbCU3pQmEUAHpY/eynXE3+85Q3ZstU
inPJ1YPUZXQJ5teit7lCfrl/OCka+C5A/DcUSrHAwDjm/35mI98=
=Uw62
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.