ASoC: tegra: ADX: convert map to flexible array
Subsystems (3)
PATCH 1/1 ASoC: tegra: ADX: convert map to flexible array
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.
--- sound/soc/tegra/tegra210_adx.c | 12 ++++-------- sound/soc/tegra/tegra210_adx.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-)
sound/soc/tegra/tegra210_adx.c +4 -8
@@ -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 );if (!adx)return -ENOMEM ; - soc_data =of_device_get_match_data (dev); adx->soc_data = soc_data;dev_set_drvdata (dev, adx);
@@ -698,12 +700,6 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)regcache_cache_only (adx->regmap, true); - adx->map =devm_kcalloc (dev, - soc_data->ram_depth *TEGRA_ADX_SLOTS_PER_WORD , -sizeof (*adx->map),GFP_KERNEL ); -if (!adx->map) -return -ENOMEM ; - adx->byte_mask =devm_kcalloc (dev, soc_data->byte_mask_size,sizeof (*adx->byte_mask),GFP_KERNEL );if (!adx->byte_mask)
sound/soc/tegra/tegra210_adx.h +1 -1
@@ -92,8 +92,8 @@ struct tegra210_adx_soc_data {struct tegra210_adx {struct regmap *regmap;unsigned int *byte_mask; -u16 *map;const struct tegra210_adx_soc_data *soc_data; +u16 map[]; };#endif
Signature · 1 line
2.55.0
Quoted 16 lines · Rosen Penev
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-pickleSigned-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(-)sound/soc/tegra/tegra210_adx.c +0
-0
sound/soc/tegra/tegra210_adx.c static int tegra210_adx_platform_probe(struct platform_device *pdev) · line 683
Quoted 8 lines
sound/soc/tegra/tegra210_adx.c +4
-1@@ -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?
Either way, though, this looks correct:
Quoted 20 lines · Thierry Reding
Quoted 19 lines · Rosen Penev
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-pickleSigned-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(-)sound/soc/tegra/tegra210_adx.c +0
-0@@ -677,11 +677,13 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)void __iomem *regs;int err, i;
Quoted 8 lines
sound/soc/tegra/tegra210_adx.c static int tegra210_adx_platform_probe(struct platform_device *pdev) · line 683
Quoted 5 lines
sound/soc/tegra/tegra210_adx.c +4
-1- 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.
Quoted 4 lines
Either way, though, this looks correct:
Reviewed-by Thierry Reding <[email protected]>
Thierry Reding
maintainerQuoted 29 lines · Rosen Penev
Quoted 20 lines · Thierry Reding
Quoted 19 lines · Rosen Penev
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-pickleSigned-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(-)sound/soc/tegra/tegra210_adx.c +0
-0@@ -677,11 +677,13 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)void __iomem *regs;int err, i;Quoted 8 lines
sound/soc/tegra/tegra210_adx.c static int tegra210_adx_platform_probe(struct platform_device *pdev) · line 683
Quoted 5 lines
sound/soc/tegra/tegra210_adx.c +4
-1- 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?
Quoted 2 lines
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
Quoted 31 lines · Thierry Reding
Quoted 29 lines · Rosen Penev
Quoted 28 lines · Thierry Reding
Quoted 16 lines · Rosen Penev
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-pickleSigned-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(-)sound/soc/tegra/tegra210_adx.c +0
-0sound/soc/tegra/tegra210_adx.c static int tegra210_adx_platform_probe(struct platform_device *pdev) · line 683
Quoted 8 lines
sound/soc/tegra/tegra210_adx.c +4
-1@@ -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?
Quoted 6 lines
Quoted 2 lines
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.
I'm not handling that patchset. That's the linux hardening people.
Quoted 2 lines
Thierry
Mark Brown
maintainerQuoted 1 line · Rosen Penev
ASoC: tegra: ADX: convert map to flexible array
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/1] ASoC: tegra: ADX: convert map to flexible array
https://git.kernel.org/broonie/asoc/c/caae0e2d1718
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark