[PATCH 0/3] ASoC: stm32: add pm runtime support
Enable support of pm runtime on STM32 SPDIFRX, I2S and DFSDM drivers to allow power state monitoring.
Olivier Moysan (3): ASoC: stm32: i2s: add pm_runtime support ASoC: stm32: dfsdm: add pm_runtime support for audio ASoC: stm32: spdifrx: add pm_runtime support
sound/soc/stm/stm32_adfsdm.c | 11 ++++++++--- sound/soc/stm/stm32_i2s.c | 4 ++++ sound/soc/stm/stm32_spdifrx.c | 4 ++++ 3 files changed, 16 insertions(+), 3 deletions(-)
Enable support of pm_runtime on STM32 I2S driver to allow I2S power state monitoring.
Signed-off-by: Olivier Moysan olivier.moysan@foss.st.com --- sound/soc/stm/stm32_i2s.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c index 6254bacad6eb..52cd1df49be1 100644 --- a/sound/soc/stm/stm32_i2s.c +++ b/sound/soc/stm/stm32_i2s.c @@ -13,6 +13,7 @@ #include <linux/module.h> #include <linux/of_irq.h> #include <linux/of_platform.h> +#include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/reset.h> #include <linux/spinlock.h> @@ -1113,6 +1114,7 @@ static int stm32_i2s_remove(struct platform_device *pdev) { snd_dmaengine_pcm_unregister(&pdev->dev); snd_soc_unregister_component(&pdev->dev); + pm_runtime_disable(&pdev->dev);
return 0; } @@ -1195,6 +1197,8 @@ static int stm32_i2s_probe(struct platform_device *pdev) FIELD_GET(I2S_VERR_MIN_MASK, val)); }
+ pm_runtime_enable(&pdev->dev); + return ret;
error:
Enable support of pm_runtime on STM32 DFSDM audio driver to allow power state monitoring.
Signed-off-by: Olivier Moysan olivier.moysan@foss.st.com --- sound/soc/stm/stm32_adfsdm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index e6078f50e508..534f96af97c5 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -12,7 +12,7 @@ #include <linux/mutex.h> #include <linux/platform_device.h> #include <linux/slab.h> - +#include <linux/pm_runtime.h> #include <linux/iio/iio.h> #include <linux/iio/consumer.h> #include <linux/iio/adc/stm32-dfsdm-adc.h> @@ -363,15 +363,20 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) #endif
ret = snd_soc_add_component(component, NULL, 0); - if (ret < 0) + if (ret < 0) { dev_err(&pdev->dev, "%s: Failed to register PCM platform\n", __func__); + return ret; + }
- return ret; + pm_runtime_enable(&pdev->dev); + + return 0; }
static int stm32_adfsdm_remove(struct platform_device *pdev) { + pm_runtime_disable(&pdev->dev); snd_soc_unregister_component(&pdev->dev);
return 0;
On Thu, Nov 18, 2021 at 10:00:34AM +0100, Olivier Moysan wrote:
ret = snd_soc_add_component(component, NULL, 0);
- if (ret < 0)
- if (ret < 0) { dev_err(&pdev->dev, "%s: Failed to register PCM platform\n", __func__);
return ret;
- }
- return ret;
- pm_runtime_enable(&pdev->dev);
Enabling runtime PM after registering the component may potentially lead to a race where something manages to go in and starts using the device including what should be runtime PM stuff. That'd lead to a reference not being taken that should be. It's unlikely to actually happen but it's better to be safe.
Enable support of pm_runtime on STM32 SPDIFRX driver to allow SPDIFRX power state monitoring.
Signed-off-by: Olivier Moysan olivier.moysan@foss.st.com --- sound/soc/stm/stm32_spdifrx.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index 48145f553588..e885796ca5f4 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -12,6 +12,7 @@ #include <linux/delay.h> #include <linux/module.h> #include <linux/of_platform.h> +#include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/reset.h>
@@ -955,6 +956,7 @@ static int stm32_spdifrx_remove(struct platform_device *pdev)
snd_dmaengine_pcm_unregister(&pdev->dev); snd_soc_unregister_component(&pdev->dev); + pm_runtime_disable(&pdev->dev);
return 0; } @@ -1045,6 +1047,8 @@ static int stm32_spdifrx_probe(struct platform_device *pdev) FIELD_GET(SPDIFRX_VERR_MIN_MASK, ver)); }
+ pm_runtime_enable(&pdev->dev); + return ret;
error:
participants (2)
-
Mark Brown
-
Olivier Moysan