Message ID | 20250212093816.1857188-1-shengjiu.wang@nxp.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | ASoC: imx-audmix: release cpu_mclk clock at failure | expand |
On Wed, Feb 12, 2025 at 05:38:16PM +0800, Shengjiu Wang wrote: > When defer probe happens, there may be below error: > > platform 59820000.sai: Resources present before probing > > The cpu_mclk clock is from the cpu dai device, if it is > not released, then the cpu dai device probe will fail > for the second time. > ret = devm_snd_soc_register_card(&pdev->dev, &priv->card); > if (ret) { > + devm_clk_put(&cpu_pdev->dev, priv->cpu_mclk); The driver shouldn't be using another driver's device to do devm_ requests (or really to look anything up), that's just going to lead to trouble like this - if it's got to look up another device's clocks it should do a regular clk_get(). There will also potentially be problems if the other device unregisters first and frees our clock underneath us, and this will request multiple copies of the clock if we unbind and rebind the imx-audmix driver.
diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c index 231400661c90..1b16470b2f7c 100644 --- a/sound/soc/fsl/imx-audmix.c +++ b/sound/soc/fsl/imx-audmix.c @@ -348,6 +348,7 @@ static int imx_audmix_probe(struct platform_device *pdev) ret = devm_snd_soc_register_card(&pdev->dev, &priv->card); if (ret) { + devm_clk_put(&cpu_pdev->dev, priv->cpu_mclk); dev_err(&pdev->dev, "snd_soc_register_card failed\n"); return ret; }
When defer probe happens, there may be below error: platform 59820000.sai: Resources present before probing The cpu_mclk clock is from the cpu dai device, if it is not released, then the cpu dai device probe will fail for the second time. Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver") Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> --- sound/soc/fsl/imx-audmix.c | 1 + 1 file changed, 1 insertion(+)