ASoC: stm32: i2s: Use devm helpers and drop remove callback
Subsystems (4)
PATCH 1/1 ASoC: stm32: i2s: Use devm helpers and drop remove callback
From: bui duc phuc <[email protected]>
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 <[email protected]>
---
Note: Compile-tested only.
sound/soc/stm/stm32_i2s.c | 42 +++++++++++++-------------------------- 1 file changed, 14 insertions(+), 28 deletions(-)
sound/soc/stm/stm32_i2s.c +14 -28
@@ -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);
Signature · 1 line
2.43.0