ASoC: tegra: ADMAIF: allocate with a single kzalloc
Subsystems (3)
PATCH v2 1/1 ASoC: tegra: ADMAIF: allocate with a single kzalloc
Consolidate the allocations for capture_dma_data and playback_dma_data into a single kzalloc by using a flexible array member at the end of the tegra_admaif struct. This reduces the number of allocations from three to one, simplifies error handling, and improves memory locality.
---
v2: place description in the proper place.
sound/soc/tegra/tegra210_admaif.c | 28 ++++++++++------------------ sound/soc/tegra/tegra210_admaif.h | 2 +- sound/soc/tegra/tegra_isomgr_bw.c | 1 + 3 files changed, 12 insertions(+), 19 deletions(-)
sound/soc/tegra/tegra210_admaif.c +10 -18
@@ -11,6 +11,7 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> +#include <sound/dmaengine_pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include "tegra_isomgr_bw.h"
@@ -912,35 +913,26 @@ MODULE_DEVICE_TABLE(of, tegra_admaif_of_match);static int tegra_admaif_probe (struct platform_device *pdev) { +const struct tegra_admaif_soc_data *soc_data;struct tegra_admaif *admaif;void __iomem *regs;struct resource *res; +size_t alloc_size;int err, i; - admaif =devm_kzalloc (&pdev->dev,sizeof (*admaif),GFP_KERNEL ); + soc_data =of_device_get_match_data (&pdev->dev); + + alloc_size =struct_size (admaif, capture_dma_data, soc_data->num_ch); + alloc_size +=sizeof (*admaif->playback_dma_data) * soc_data->num_ch; + admaif =devm_kzalloc (&pdev->dev, alloc_size,GFP_KERNEL );if (!admaif)return -ENOMEM ; - admaif->soc_data =of_device_get_match_data (&pdev->dev); + admaif->playback_dma_data = admaif->capture_dma_data + soc_data->num_ch; + admaif->soc_data = soc_data;dev_set_drvdata (&pdev->dev, admaif); - admaif->capture_dma_data = -devm_kcalloc (&pdev->dev, - admaif->soc_data->num_ch, -sizeof (struct snd_dmaengine_dai_dma_data ), -GFP_KERNEL ); -if (!admaif->capture_dma_data) -return -ENOMEM ; - - admaif->playback_dma_data = -devm_kcalloc (&pdev->dev, - admaif->soc_data->num_ch, -sizeof (struct snd_dmaengine_dai_dma_data ), -GFP_KERNEL ); -if (!admaif->playback_dma_data) -return -ENOMEM ; -for (i =0 ; i <ADMAIF_PATHS ; i++) { admaif->mono_to_stereo[i] = devm_kcalloc(&pdev->dev, admaif->soc_data->num_ch,
sound/soc/tegra/tegra210_admaif.h +1 -1
@@ -229,13 +229,13 @@ struct tegra_admaif_soc_data { };struct tegra_admaif { -struct snd_dmaengine_dai_dma_data *capture_dma_data;struct snd_dmaengine_dai_dma_data *playback_dma_data;const struct tegra_admaif_soc_data *soc_data;unsigned int *mono_to_stereo[ADMAIF_PATHS ];unsigned int *stereo_to_mono[ADMAIF_PATHS ];struct regmap *regmap;struct tegra_adma_isomgr *adma_isomgr; +struct snd_dmaengine_dai_dma_data capture_dma_data[]; };#endif
sound/soc/tegra/tegra_isomgr_bw.c +1 -0
@@ -6,6 +6,7 @@#include <linux/interconnect.h> #include <linux/module.h> +#include <sound/dmaengine_pcm.h> #include <sound/pcm_params.h> #include <sound/soc.h> #include "tegra_isomgr_bw.h"
Signature · 1 line
2.54.0
Mark Brown
maintainerQuoted 1 line · Rosen Penev
ASoC: tegra: ADMAIF: allocate with a single kzalloc
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/1] ASoC: tegra: ADMAIF: allocate with a single kzalloc
https://git.kernel.org/broonie/sound/c/7ff50c1f3183
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