[PATCH 5.19 340/717] ASoC: stm32: dfsdm: Fix PM disable depth imbalance in stm32_adfsdm_probe

Greg Kroah-Hartman
2022-10-22T08:05:40Z

From: Zhang Qilong <zhangqilong3@huawei.com>

[ Upstream commit b9a0da5b2edcae2a901b85c8cc42efc5bec4bd7b ]

The pm_runtime_enable will increase power disable depth. Thus
a pairing decrement is needed on the error handling path to
keep it balanced according to context. We fix it by moving
pm_runtime_enable to the endding of stm32_adfsdm_probe.

Fixes:98e500a12f934 ("ASoC: stm32: dfsdm: add pm_runtime support for audio")

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Reviewed-by: Olivier Moysan <olivier.moysan@foss.st.com>
Link: https://lore.kernel.org/r/20220927142601.64266-2-zhangqilong3@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/stm/stm32_adfsdm.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c
index 6ee714542b84..c0f964891b58 100644
--- a/sound/soc/stm/stm32_adfsdm.c
+++ b/sound/soc/stm/stm32_adfsdm.c
@@ -334,8 +334,6 @@ static int stm32_adfsdm_probe(struct platform_device *pdev)

dev_set_drvdata(&pdev->dev, priv);

- pm_runtime_enable(&pdev->dev);
-
ret = devm_snd_soc_register_component(&pdev->dev,
&stm32_adfsdm_dai_component,
&priv->dai_drv, 1);
@@ -365,9 +363,13 @@ 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;
+ }
+
+ pm_runtime_enable(&pdev->dev);

return ret;
}
--
2.35.1