The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ASoC: stm32: i2s: Use devm helpers and drop remove callback
@ 2026-11-25 10:48 phucduc.bui
  0 siblings, 0 replies; only message in thread
From: phucduc.bui @ 2026-11-25 10:48 UTC (permalink / raw)
  To: Mark Brown, Olivier Moysan
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Arnaud Pouliquen,
	Maxime Coquelin, linux-sound, linux-stm32, linux-arm-kernel,
	linux-kernel, Alexandre Torgue, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

Commit caff4ce8cc58 ("ASoC: stm32: i2s: manage rebind issue") switched
to explicit registration and unregistration to address a sound card
rebind issue.

Commit 58f30150ffd6 ("ASoC: core: Remove only the registered component
in devm functions") fixed the underlying issue in the ASoC core, so
devm helpers can now be used again.

Also use devm_pm_runtime_enable(), which fixes the unbalanced
pm_runtime_disable() in the probe error path.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---

Note: Compile-tested only.

 sound/soc/stm/stm32_i2s.c | 42 +++++++++++++--------------------------
 1 file changed, 14 insertions(+), 28 deletions(-)

diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c
index 79465be82cb8..e6e861a957dc 100644
--- a/sound/soc/stm/stm32_i2s.c
+++ b/sound/soc/stm/stm32_i2s.c
@@ -1255,13 +1255,6 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,
 	return 0;
 }
 
-static void stm32_i2s_remove(struct platform_device *pdev)
-{
-	snd_dmaengine_pcm_unregister(&pdev->dev);
-	snd_soc_unregister_component(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
-}
-
 static int stm32_i2s_probe(struct platform_device *pdev)
 {
 	struct stm32_i2s_data *i2s;
@@ -1301,56 +1294,50 @@ static int stm32_i2s_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = snd_dmaengine_pcm_register(&pdev->dev, &stm32_i2s_pcm_config, 0);
+	ret = devm_pm_runtime_enable(&pdev->dev);
 	if (ret)
 		return ret;
 
-	ret = snd_soc_register_component(&pdev->dev, &stm32_i2s_component,
-					 i2s->dai_drv, 1);
-	if (ret) {
-		snd_dmaengine_pcm_unregister(&pdev->dev);
+	ret = devm_snd_dmaengine_pcm_register(&pdev->dev, &stm32_i2s_pcm_config, 0);
+	if (ret)
+		return ret;
+
+	ret = devm_snd_soc_register_component(&pdev->dev, &stm32_i2s_component,
+					      i2s->dai_drv, 1);
+	if (ret)
 		return ret;
-	}
 
 	/* Set SPI/I2S in i2s mode */
 	ret = regmap_update_bits(i2s->regmap, STM32_I2S_CGFR_REG,
 				 I2S_CGFR_I2SMOD, I2S_CGFR_I2SMOD);
 	if (ret)
-		goto error;
+		return ret;
 
 	ret = regmap_read(i2s->regmap, STM32_I2S_IPIDR_REG, &val);
 	if (ret)
-		goto error;
+		return ret;
 
 	if (val == I2S_IPIDR_NUMBER) {
 		ret = regmap_read(i2s->regmap, STM32_I2S_HWCFGR_REG, &val);
 		if (ret)
-			goto error;
+			return ret;
 
 		if (!FIELD_GET(I2S_HWCFGR_I2S_SUPPORT_MASK, val)) {
 			dev_err(&pdev->dev,
 				"Device does not support i2s mode\n");
-			ret = -EPERM;
-			goto error;
+			return -EPERM;
 		}
 
 		ret = regmap_read(i2s->regmap, STM32_I2S_VERR_REG, &val);
 		if (ret)
-			goto error;
+			return ret;
 
 		dev_dbg(&pdev->dev, "I2S version: %lu.%lu registered\n",
 			FIELD_GET(I2S_VERR_MAJ_MASK, val),
 			FIELD_GET(I2S_VERR_MIN_MASK, val));
 	}
 
-	pm_runtime_enable(&pdev->dev);
-
-	return ret;
-
-error:
-	stm32_i2s_remove(pdev);
-
-	return ret;
+	return 0;
 }
 
 MODULE_DEVICE_TABLE(of, stm32_i2s_ids);
@@ -1384,7 +1371,6 @@ static struct platform_driver stm32_i2s_driver = {
 		.pm = pm_ptr(&stm32_i2s_pm_ops),
 	},
 	.probe = stm32_i2s_probe,
-	.remove = stm32_i2s_remove,
 };
 
 module_platform_driver(stm32_i2s_driver);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-25 10:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 10:48 [PATCH] ASoC: stm32: i2s: Use devm helpers and drop remove callback phucduc.bui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox