From: Lubomir Rintel <lkundrak@v3.sk>
To: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
Lubomir Rintel <lkundrak@v3.sk>
Subject: [PATCH] ASoC: mmp-sspa: Fix the error handling in probe()
Date: Wed, 20 May 2020 10:35:16 +0200 [thread overview]
Message-ID: <20200520083516.2120802-1-lkundrak@v3.sk> (raw)
If we fail after pm_runtime_enable(), we fail to undo it. Same with
clk_prepare_enable(). Let's order them after all things that can fail.
Fixes: 7d98cc648253 ("ASoC: mmp-sspa: Add support for the runtime power management")
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
sound/soc/pxa/mmp-sspa.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c
index 60bf6fe05315..77a6d2998570 100644
--- a/sound/soc/pxa/mmp-sspa.c
+++ b/sound/soc/pxa/mmp-sspa.c
@@ -467,6 +467,7 @@ static const struct snd_soc_component_driver mmp_sspa_component = {
static int asoc_mmp_sspa_probe(struct platform_device *pdev)
{
struct sspa_priv *sspa;
+ int ret;
sspa = devm_kzalloc(&pdev->dev,
sizeof(struct sspa_priv), GFP_KERNEL);
@@ -518,8 +519,6 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
return PTR_ERR(sspa->sysclk);
}
}
- pm_runtime_enable(&pdev->dev);
- clk_prepare_enable(sspa->audio_clk);
platform_set_drvdata(pdev, sspa);
sspa->playback_dma_data.maxburst = 4;
@@ -529,16 +528,21 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
sspa->playback_dma_data.addr = 0x80 + SSPA_D;
if (pdev->dev.of_node) {
- int ret;
-
ret = devm_snd_dmaengine_pcm_register(&pdev->dev,
&mmp_pcm_config, 0);
if (ret)
return ret;
}
- return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
- &mmp_sspa_dai, 1);
+ ret = devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component,
+ &mmp_sspa_dai, 1);
+ if (ret)
+ return ret;
+
+ pm_runtime_enable(&pdev->dev);
+ clk_prepare_enable(sspa->audio_clk);
+
+ return 0;
}
static int asoc_mmp_sspa_remove(struct platform_device *pdev)
--
2.26.2
next reply other threads:[~2020-05-20 8:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-20 8:35 Lubomir Rintel [this message]
2020-05-20 17:17 ` [PATCH] ASoC: mmp-sspa: Fix the error handling in probe() Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200520083516.2120802-1-lkundrak@v3.sk \
--to=lkundrak@v3.sk \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).