Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: fsl: fsl_asrc: Check for clk_prepare_enable() error
@ 2015-06-20 21:00 Fabio Estevam
  2015-06-20 21:04 ` Nicolin Chen
  2015-07-07 13:57 ` Applied "ASoC: fsl: fsl_asrc: Check for clk_prepare_enable() error" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2015-06-20 21:00 UTC (permalink / raw)
  To: broonie; +Cc: nicoleotsuka, Fabio Estevam, alsa-devel

From: Fabio Estevam <fabio.estevam@freescale.com>

clk_prepare_enable() may fail, so we should better check its return value
and propagate it in the case of error.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Also handle the error for asrck_clk[i] as suggested
by Nicolin

 sound/soc/fsl/fsl_asrc.c | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index c068494..9f087d4 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -931,14 +931,29 @@ static int fsl_asrc_probe(struct platform_device *pdev)
 static int fsl_asrc_runtime_resume(struct device *dev)
 {
 	struct fsl_asrc *asrc_priv = dev_get_drvdata(dev);
-	int i;
+	int i, ret;
 
-	clk_prepare_enable(asrc_priv->mem_clk);
-	clk_prepare_enable(asrc_priv->ipg_clk);
-	for (i = 0; i < ASRC_CLK_MAX_NUM; i++)
-		clk_prepare_enable(asrc_priv->asrck_clk[i]);
+	ret = clk_prepare_enable(asrc_priv->mem_clk);
+	if (ret)
+		return ret;
+	ret = clk_prepare_enable(asrc_priv->ipg_clk);
+	if (ret)
+		goto disable_mem_clk;
+	for (i = 0; i < ASRC_CLK_MAX_NUM; i++) {
+		ret = clk_prepare_enable(asrc_priv->asrck_clk[i]);
+		if (ret)
+			goto disable_asrck_clk;
+	}
 
 	return 0;
+
+disable_asrck_clk:
+	for (i--; i >= 0; i--)
+		clk_disable_unprepare(asrc_priv->asrck_clk[i]);
+	clk_disable_unprepare(asrc_priv->ipg_clk);
+disable_mem_clk:
+	clk_disable_unprepare(asrc_priv->mem_clk);
+	return ret;
 }
 
 static int fsl_asrc_runtime_suspend(struct device *dev)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-07 13:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-20 21:00 [PATCH v2] ASoC: fsl: fsl_asrc: Check for clk_prepare_enable() error Fabio Estevam
2015-06-20 21:04 ` Nicolin Chen
2015-07-07 13:57 ` Applied "ASoC: fsl: fsl_asrc: Check for clk_prepare_enable() error" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox