Skip to contentSkip to conversation

ASoC: samsung: Fix checking return value of clk_get

PATCH Superseded Axel Lin 4 participants 5 messages Sep 13, 2011 – Sep 15, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 ASoC: samsung: Fix checking return value of clk_get

clk_get() returns a pointer to the struct clk or an ERR_PTR().

Cc Christian Pellegrin <[email protected]>
Cc Ben Dooks <[email protected]>
Cc Sangbeom Kim <[email protected]>
Cc Jassi Brar <[email protected]>
---
 sound/soc/samsung/s3c2412-i2s.c     |    2 +-
 sound/soc/samsung/s3c24xx-i2s.c     |    2 +-
 sound/soc/samsung/s3c24xx_uda134x.c |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/samsung/s3c2412-i2s.c +1 -1
index 841ab14..cecdbad 100644
@@ -69,7 +69,7 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai)
 	s3c2412_i2s.dma_playback = &s3c2412_i2s_pcm_stereo_out;
 
 	s3c2412_i2s.iis_cclk = clk_get(dai->dev, "i2sclk");
-	if (s3c2412_i2s.iis_cclk == NULL) {
+	if (IS_ERR(s3c2412_i2s.iis_cclk)) {
 		pr_err("failed to get i2sclk clock\n");
 		iounmap(s3c2412_i2s.regs);
 		return -ENODEV;
sound/soc/samsung/s3c24xx-i2s.c +1 -1
index 63d8849..9f888bc 100644
@@ -383,7 +383,7 @@ static int s3c24xx_i2s_probe(struct snd_soc_dai *dai)
 		return -ENXIO;
 
 	s3c24xx_i2s.iis_clk = clk_get(dai->dev, "iis");
-	if (s3c24xx_i2s.iis_clk == NULL) {
+	if (IS_ERR(s3c24xx_i2s.iis_clk)) {
 		pr_err("failed to get iis_clock\n");
 		iounmap(s3c24xx_i2s.regs);
 		return -ENODEV;
sound/soc/samsung/s3c24xx_uda134x.c +2 -2
index dc9d551..4da57cd 100644
@@ -66,13 +66,13 @@ static int s3c24xx_uda134x_startup(struct snd_pcm_substream *substream)
 	pr_debug("%s %d\n", __func__, clk_users);
 	if (clk_users == 0) {
 		xtal = clk_get(&s3c24xx_uda134x_snd_device->dev, "xtal");
-		if (!xtal) {
+		if (IS_ERR(xtal)) {
 			printk(KERN_ERR "%s cannot get xtal\n", __func__);
 			ret = -EBUSY;
 		} else {
 			pclk = clk_get(&s3c24xx_uda134x_snd_device->dev,
 				       "pclk");
-			if (!pclk) {
+			if (IS_ERR(pclk)) {
 				printk(KERN_ERR "%s cannot get pclk\n",
 				       __func__);
 				clk_put(xtal);
Signature · 1 line
1.7.4.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Axel Lin

clk_get() returns a pointer to the struct clk or an ERR_PTR().

Cc Christian Pellegrin <[email protected]>
Cc Ben Dooks <[email protected]>
Cc Sangbeom Kim <[email protected]>
Cc Jassi Brar <[email protected]>
Quoted 5 lines
---
 sound/soc/samsung/s3c2412-i2s.c     |    2 +-
 sound/soc/samsung/s3c24xx-i2s.c     |    2 +-
 sound/soc/samsung/s3c24xx_uda134x.c |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
Quoted 47 lines
sound/soc/samsung/s3c2412-i2s.c +1 -1
index 841ab14..cecdbad 100644
@@ -69,7 +69,7 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai)
 	s3c2412_i2s.dma_playback = &s3c2412_i2s_pcm_stereo_out;
 
 	s3c2412_i2s.iis_cclk = clk_get(dai->dev, "i2sclk");
-	if (s3c2412_i2s.iis_cclk == NULL) {
+	if (IS_ERR(s3c2412_i2s.iis_cclk)) {
 		pr_err("failed to get i2sclk clock\n");
 		iounmap(s3c2412_i2s.regs);
 		return -ENODEV;
sound/soc/samsung/s3c24xx-i2s.c +1 -1
index 63d8849..9f888bc 100644
@@ -383,7 +383,7 @@ static int s3c24xx_i2s_probe(struct snd_soc_dai *dai)
 		return -ENXIO;
 
 	s3c24xx_i2s.iis_clk = clk_get(dai->dev, "iis");
-	if (s3c24xx_i2s.iis_clk == NULL) {
+	if (IS_ERR(s3c24xx_i2s.iis_clk)) {
 		pr_err("failed to get iis_clock\n");
 		iounmap(s3c24xx_i2s.regs);
 		return -ENODEV;
sound/soc/samsung/s3c24xx_uda134x.c +2 -2
index dc9d551..4da57cd 100644
@@ -66,13 +66,13 @@ static int s3c24xx_uda134x_startup(struct snd_pcm_substream *substream)
 	pr_debug("%s %d\n", __func__, clk_users);
 	if (clk_users == 0) {
 		xtal = clk_get(&s3c24xx_uda134x_snd_device->dev, "xtal");
-		if (!xtal) {
+		if (IS_ERR(xtal)) {
 			printk(KERN_ERR "%s cannot get xtal\n", __func__);
 			ret = -EBUSY;
 		} else {
 			pclk = clk_get(&s3c24xx_uda134x_snd_device->dev,
 				       "pclk");
-			if (!pclk) {
+			if (IS_ERR(pclk)) {
 				printk(KERN_ERR "%s cannot get pclk\n",
 				       __func__);
 				clk_put(xtal);
#2 lore raw
In reply to Axel Lin
Quoted 1 line · Axel Lin

clk_get() returns a pointer to the struct clk or an ERR_PTR().

Are you sure that the Samsung clock implementation actually does this?

author
#3 lore raw

2011/9/13 Mark Brown <[email protected]>:

Quoted 5 lines · Axel Lin
Quoted 1 line

clk_get() returns a pointer to the struct clk or an ERR_PTR().

Are you sure that the Samsung clock implementation actually does this?

Yes.
In arch/arm/Kconfig, all samsung platforms select CLKDEV_LOOKUP. The implementation of clk_get() in drivers/clk/clkdev.c returns ERR_PTR() on failure.

Regards,
Axel

#4 lore raw
In reply to Axel Lin

sound/soc/samsung/s3c2412-i2s.c static int s3c2412_i2s_probe(struct snd_soc_dai *dai) · line 75

Quoted 6 lines · Axel Lin
sound/soc/samsung/s3c2412-i2s.c +1 -1
 	s3c2412_i2s.iis_cclk = clk_get(dai->dev, "i2sclk");
-	if (s3c2412_i2s.iis_cclk == NULL) {
+	if (IS_ERR(s3c2412_i2s.iis_cclk)) {
 		pr_err("failed to get i2sclk clock\n");
 		iounmap(s3c2412_i2s.regs);
 		return -ENODEV;

Why don't you use PTR_ERR() for return value?

Quoted 6 lines
sound/soc/samsung/s3c24xx- renamed from sound/soc/samsung/s3c24xx-i2s.c +0 -0

i2s.c
index 63d8849..9f888bc 100644

sound/soc/samsung/s3c24xx-i2s.c static int s3c24xx_i2s_probe(struct snd_soc_dai *dai) · line 389

Quoted 8 lines
sound/soc/samsung/s3c24xx-i2s.c +1 -1
@@ -383,7 +383,7 @@ static int s3c24xx_i2s_probe(struct snd_soc_dai *dai)
 		return -ENXIO;
 
 	s3c24xx_i2s.iis_clk = clk_get(dai->dev, "iis");
-	if (s3c24xx_i2s.iis_clk == NULL) {
+	if (IS_ERR(s3c24xx_i2s.iis_clk)) {
 		pr_err("failed to get iis_clock\n");
 		iounmap(s3c24xx_i2s.regs);
 		return -ENODEV;

Ditto

Quoted 6 lines
sound/soc/samsung/s3c24xx_uda134x.c +0 -0
index dc9d551..4da57cd 100644

sound/soc/samsung/s3c24xx_uda134x.c static int s3c24xx_uda134x_startup(struct · line 72

Quoted 8 lines
sound/soc/samsung/s3c24xx_uda134x.c +1 -1
@@ -66,13 +66,13 @@ static int s3c24xx_uda134x_startup(struct
 snd_pcm_substream *substream)
 	pr_debug("%s %d\n", __func__, clk_users);
 	if (clk_users == 0) {
 		xtal = clk_get(&s3c24xx_uda134x_snd_device->dev, "xtal");
-		if (!xtal) {
+		if (IS_ERR(xtal)) {
 			printk(KERN_ERR "%s cannot get xtal\n", __func__);
 			ret = -EBUSY;

Ditto

Quoted 11 lines
sound/soc/samsung/s3c24xx_uda134x.c +1 -1
 		} else {
 			pclk = clk_get(&s3c24xx_uda134x_snd_device->dev,
 				       "pclk");
-			if (!pclk) {
+			if (IS_ERR(pclk)) {
 				printk(KERN_ERR "%s cannot get pclk\n",
 				       __func__);

clk_put(xtal);
--
1.7.4.1

Thanks,

Sangbeom