diff options
| author | Rosen Penev <rosenp@gmail.com> | 2026-05-18 18:04:13 -0700 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2026-05-27 11:13:27 +0100 |
| commit | 344a4c96b29282c03e45f3b81021a2c83398e3b5 (patch) | |
| tree | ed501a3fe08bde4d9609608cdccbbc5e41f7660b /sound | |
| parent | 2fd19f0d589e703c767949b1861b2cf8c2a6de12 (diff) | |
| download | linux-next-history-344a4c96b29282c03e45f3b81021a2c83398e3b5.tar.gz | |
ASoC: mediatek: mt2701: allocate i2s_path with priv
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>
Link: https://patch.msgid.link/20260519010413.629214-1-rosenp@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
| -rw-r--r-- | sound/soc/mediatek/mt2701/mt2701-afe-common.h | 2 | ||||
| -rw-r--r-- | 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 8b6f3a200048a..c9477bc24ee96 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 bb459faa6e054..d56b498e8c0c0 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; |
