[PATCH] sound: samsung: Add error handling to clk_set_rate in smdk_spdif

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds error handling for clk_set_rate calls in the
set_audio_clock_rate function of the smdk_spdif.c file. Previously,
the return value of clk_set_rate was not checked, which could potentially
lead to unhandled errors in setting the audio clock rate. This change
ensures that if clk_set_rate fails, the error is properly reported and
handled.

Signed-off-by: Haoran Liu <liuhaoran14@xxxxxxx>
---
 sound/soc/samsung/smdk_spdif.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/smdk_spdif.c b/sound/soc/samsung/smdk_spdif.c
index 2474eb619882..c31b82b89148 100644
--- a/sound/soc/samsung/smdk_spdif.c
+++ b/sound/soc/samsung/smdk_spdif.c
@@ -75,6 +75,7 @@ static int set_audio_clock_rate(unsigned long epll_rate,
 				unsigned long audio_rate)
 {
 	struct clk *fout_epll, *sclk_spdif;
+	int ret;
 
 	fout_epll = clk_get(NULL, "fout_epll");
 	if (IS_ERR(fout_epll)) {
@@ -82,7 +83,14 @@ static int set_audio_clock_rate(unsigned long epll_rate,
 		return -ENOENT;
 	}
 
-	clk_set_rate(fout_epll, epll_rate);
+	ret = clk_set_rate(fout_epll, epll_rate);
+	if (ret) {
+		printk(KERN_ERR "%s: failed to set rate for fout_epll\n",
+				__func__);
+		clk_put(fout_epll);
+		return ret;
+	}
+
 	clk_put(fout_epll);
 
 	sclk_spdif = clk_get(NULL, "sclk_spdif");
@@ -91,7 +99,15 @@ static int set_audio_clock_rate(unsigned long epll_rate,
 		return -ENOENT;
 	}
 
-	clk_set_rate(sclk_spdif, audio_rate);
+	ret = clk_set_rate(sclk_spdif, audio_rate);
+	if (ret) {
+		printk(KERN_ERR "%s: failed to set rate for sclk_spdif\n",
+				__func__);
+		clk_put(sclk_spdif);
+		clk_put(fout_epll);
+		return ret;
+	}
+
 	clk_put(sclk_spdif);
 
 	return 0;
-- 
2.17.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux