[PATCH] ASoC: stm: stm32_adfsdm: Use devm helpers and drop remove callback

From: phucduc . bui

Date: Thu Nov 26 2026 - 05:08:00 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

The components are registered with devm helpers, but the remove
callback unregisters them explicitly. Use devm_pm_runtime_enable()
and drop the remove callback.

Also get the IIO channels first and register the PCM component
before the DAI component.

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

Note: Compile-tested only.

sound/soc/stm/stm32_adfsdm.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 083dc4c26274..cd54fd071b2b 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -336,12 +336,6 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)

dev_set_drvdata(&pdev->dev, priv);

- ret = devm_snd_soc_register_component(&pdev->dev,
- &stm32_adfsdm_dai_component,
- &priv->dai_drv, 1);
- if (ret < 0)
- return ret;
-
/* Associate iio channel */
priv->iio_ch = devm_iio_channel_get_all(&pdev->dev);
if (IS_ERR(priv->iio_ch))
@@ -357,19 +351,17 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)
return ret;
}

- ret = snd_soc_register_component(&pdev->dev, &stm32_adfsdm_soc_platform, NULL, 0);
+ ret = devm_pm_runtime_enable(&pdev->dev);
+ if (ret)
+ return ret;
+
+ ret = devm_snd_soc_register_component(&pdev->dev, &stm32_adfsdm_soc_platform, NULL, 0);
if (ret < 0)
return ret;

- pm_runtime_enable(&pdev->dev);
-
- return ret;
-}
-
-static void stm32_adfsdm_remove(struct platform_device *pdev)
-{
- snd_soc_unregister_component(&pdev->dev);
- pm_runtime_disable(&pdev->dev);
+ return devm_snd_soc_register_component(&pdev->dev,
+ &stm32_adfsdm_dai_component,
+ &priv->dai_drv, 1);
}

static struct platform_driver stm32_adfsdm_driver = {
@@ -378,7 +370,6 @@ static struct platform_driver stm32_adfsdm_driver = {
.of_match_table = stm32_adfsdm_of_match,
},
.probe = stm32_adfsdm_probe,
- .remove = stm32_adfsdm_remove,
};

module_platform_driver(stm32_adfsdm_driver);
--
2.43.0