* [PATCH] ASoC: mediatek: mt2701: allocate i2s_path with priv
@ 2026-05-19 1:04 Rosen Penev
2026-05-27 10:13 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-05-19 1:04 UTC (permalink / raw)
To: linux-sound
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Matthias Brugger, AngeloGioacchino Del Regno,
open list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support,
moderated list:ARM/Mediatek SoC support
Use a flexible array member to combine allocations.
Clean up surrounding code and allocate based on afe_priv and not
platform_priv which is a void pointer. struct_size needs a properly
typed pointer to work.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
sound/soc/mediatek/mt2701/mt2701-afe-common.h | 2 +-
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 21 ++++++++-----------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-common.h b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
index 8b6f3a200048..c9477bc24ee9 100644
--- a/sound/soc/mediatek/mt2701/mt2701-afe-common.h
+++ b/sound/soc/mediatek/mt2701/mt2701-afe-common.h
@@ -89,7 +89,6 @@ struct mt2701_soc_variants {
};
struct mt2701_afe_private {
- struct mt2701_i2s_path *i2s_path;
struct clk *base_ck[MT2701_BASE_CLK_NUM];
struct clk *mrgif_ck;
struct clk *hadds2pll_ck;
@@ -99,6 +98,7 @@ struct mt2701_afe_private {
bool mrg_enable[MTK_STREAM_NUM];
const struct mt2701_soc_variants *soc;
+ struct mt2701_i2s_path i2s_path[];
};
#endif
diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
index bb459faa6e05..d56b498e8c0c 100644
--- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
+++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
@@ -1593,6 +1593,7 @@ static int mt2701_afe_runtime_resume(struct device *dev)
static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
{
+ const struct mt2701_soc_variants *soc;
struct mtk_base_afe *afe;
struct mt2701_afe_private *afe_priv;
struct device *dev;
@@ -1602,23 +1603,19 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
if (!afe)
return -ENOMEM;
- afe->platform_priv = devm_kzalloc(&pdev->dev, sizeof(*afe_priv),
- GFP_KERNEL);
- if (!afe->platform_priv)
+ soc = of_device_get_match_data(&pdev->dev);
+ afe_priv = devm_kzalloc(&pdev->dev,
+ struct_size(afe_priv, i2s_path, soc->i2s_num),
+ GFP_KERNEL);
+ if (!afe_priv)
return -ENOMEM;
- afe_priv = afe->platform_priv;
- afe_priv->soc = of_device_get_match_data(&pdev->dev);
+ afe_priv->soc = soc;
+
+ afe->platform_priv = afe_priv;
afe->dev = &pdev->dev;
dev = afe->dev;
- afe_priv->i2s_path = devm_kcalloc(dev,
- afe_priv->soc->i2s_num,
- sizeof(struct mt2701_i2s_path),
- GFP_KERNEL);
- if (!afe_priv->i2s_path)
- return -ENOMEM;
-
irq_id = platform_get_irq_byname(pdev, "asys");
if (irq_id < 0)
return irq_id;
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ASoC: mediatek: mt2701: allocate i2s_path with priv
2026-05-19 1:04 [PATCH] ASoC: mediatek: mt2701: allocate i2s_path with priv Rosen Penev
@ 2026-05-27 10:13 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-05-27 10:13 UTC (permalink / raw)
To: linux-sound, Rosen Penev
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Matthias Brugger,
AngeloGioacchino Del Regno, linux-kernel, linux-arm-kernel,
linux-mediatek
On Mon, 18 May 2026 18:04:13 -0700, Rosen Penev wrote:
> ASoC: mediatek: mt2701: allocate i2s_path with priv
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/1] ASoC: mediatek: mt2701: allocate i2s_path with priv
https://git.kernel.org/broonie/sound/c/344a4c96b292
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-27 12:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19 1:04 [PATCH] ASoC: mediatek: mt2701: allocate i2s_path with priv Rosen Penev
2026-05-27 10:13 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox