Message ID | 20211118090035.5331-3-olivier.moysan@foss.st.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: stm32: add pm runtime support | expand |
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.
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;
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(-)