Skip to contentSkip to conversation

ASoC: mediatek: mt2701: allocate i2s_path with priv

PATCH In review Rosen Penev 2 participants 2 messages May 19 – May 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 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(-)
sound/soc/mediatek/mt2701/mt2701-afe-common.h +1 -1
index 8b6f3a200048..c9477bc24ee9 100644
@@ -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
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +9 -12
index bb459faa6e05..d56b498e8c0c 100644
@@ -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;
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 1 line · Rosen Penev

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