Skip to contentSkip to conversation

ASoC: uda1380: Return proper error in uda1380_modinit failure path

PATCH Applied Axel Lin 3 participants 9 messages Dec 4, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/3 ASoC: uda1380: Return proper error in uda1380_modinit failure path

Return proper error for uda1380_modinit if i2c_add_driver() fails.

---
 sound/soc/codecs/uda1380.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/uda1380.c +2 -2
index 6b933ef..3a238cb 100644
@@ -863,13 +863,13 @@ static struct i2c_driver uda1380_i2c_driver = {
 
 static int __init uda1380_modinit(void)
 {
-	int ret;
+	int ret = 0;
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	ret = i2c_add_driver(&uda1380_i2c_driver);
 	if (ret != 0)
 		pr_err("Failed to register UDA1380 I2C driver: %d\n", ret);
 #endif
-	return 0;
+	return ret;
 }
 module_init(uda1380_modinit);
 
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/3 ASoC: uda1380: Fix missed uda1380_reset call if pdata->gpio_power is a valid gpio

Current code does not call uda1380_reset() in uda1380_probe() if pdata->gpio_power is a valid gpio. Fix it.

Also remove a redundant "Failed to issue reset" error message. We already show error message in uda1380_reset() error path.

---
I don't has this hardware, I'd appreciate if someone can test this patch. Axel

 sound/soc/codecs/uda1380.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
sound/soc/codecs/uda1380.c +4 -6
index 3a238cb..7ebfbeb 100644
@@ -747,14 +747,12 @@ static int uda1380_probe(struct snd_soc_codec *codec)
 		ret = gpio_direction_output(pdata->gpio_power, 0);
 		if (ret)
 			goto err_gpio_power_conf;
-	} else {
-		ret = uda1380_reset(codec);
-		if (ret) {
-			dev_err(codec->dev, "Failed to issue reset\n");
-			goto err_reset;
-		}
 	}
 
+	ret = uda1380_reset(codec);
+	if (ret)
+		goto err_reset;
+
 	INIT_WORK(&uda1380->work, uda1380_flush_work);
 
 	/* power on device */
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [PATCH 2/3] ASoC: uda1380: Fix missed uda1380_reset call if pdata->gpio_power is a valid gpio

Quoted 2 lines · Axel Lin

Current code does not call uda1380_reset() in uda1380_probe() if pdata->gpio_power is a valid gpio. Fix it.

This doesn't look like a problem - what's happening is that when the driver has control over the CODEC power it's powering it off which has the effect of restoring the device to the power on defaults. It only needs to issue a reset if the device is powered up.

#3 lore raw

Re: [PATCH 2/3] ASoC: uda1380: Fix missed uda1380_reset call if pdata->gpio_power is a valid gpio

In reply to Axel Lin

2011/12/4 Axel Lin <[email protected]>:

Quoted 7 lines

Current code does not call uda1380_reset() in uda1380_probe() if pdata->gpio_power is a valid gpio. Fix it.

Also remove a redundant "Failed to issue reset" error message. We already show error message in uda1380_reset() error path.

NAK. Issuing reset command when codec is powered off does not look as a sane thing
to me.

Quoted 34 lines

---
I don't has this hardware, I'd appreciate if someone can test this patch. Axel
 sound/soc/codecs/uda1380.c |   10 ++++------

 1 files changed, 4 insertions(+), 6 deletions(-)
sound/soc/codecs/uda1380.c +4 -7
index 3a238cb..7ebfbeb 100644
@@ -747,14 +747,12 @@ static int uda1380_probe(struct snd_soc_codec *codec)
                ret = gpio_direction_output(pdata->gpio_power, 0);
                if (ret)
                        goto err_gpio_power_conf;
-       } else {
-               ret = uda1380_reset(codec);
-               if (ret) {
-                       dev_err(codec->dev, "Failed to issue reset\n");
-                       goto err_reset;
-               }
        }
 
+       ret = uda1380_reset(codec);
+       if (ret)
+               goto err_reset;
+
        INIT_WORK(&uda1380->work, uda1380_flush_work);
 
        /* power on device */
--

1.7.5.4

Quoted 4 lines

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author
#4 lore raw

PATCH 3/3 ASoC: uda1380: Convert to gpio_request_one()

In reply to Axel Lin
---
 sound/soc/codecs/uda1380.c |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)
sound/soc/codecs/uda1380.c +4 -10
index 7ebfbeb..17ae60f 100644
@@ -732,21 +732,17 @@ static int uda1380_probe(struct snd_soc_codec *codec)
 		return -EINVAL;
 
 	if (gpio_is_valid(pdata->gpio_reset)) {
-		ret = gpio_request(pdata->gpio_reset, "uda1380 reset");
+		ret = gpio_request_one(pdata->gpio_reset, GPIOF_OUT_INIT_LOW,
+				       "uda1380 reset");
 		if (ret)
 			goto err_out;
-		ret = gpio_direction_output(pdata->gpio_reset, 0);
-		if (ret)
-			goto err_gpio_reset_conf;
 	}
 
 	if (gpio_is_valid(pdata->gpio_power)) {
-		ret = gpio_request(pdata->gpio_power, "uda1380 power");
+		ret = gpio_request_one(pdata->gpio_power, GPIOF_OUT_INIT_LOW,
+				       "uda1380 power");
 		if (ret)
 			goto err_gpio;
-		ret = gpio_direction_output(pdata->gpio_power, 0);
-		if (ret)
-			goto err_gpio_power_conf;
 	}
 
 	ret = uda1380_reset(codec);
@@ -775,11 +771,9 @@ static int uda1380_probe(struct snd_soc_codec *codec)
 	return 0;
 
 err_reset:
-err_gpio_power_conf:
 	if (gpio_is_valid(pdata->gpio_power))
 		gpio_free(pdata->gpio_power);
 
-err_gpio_reset_conf:
 err_gpio:
 	if (gpio_is_valid(pdata->gpio_reset))
 		gpio_free(pdata->gpio_reset);
Signature · 1 line
1.7.5.4
#6 lore raw
In reply to Axel Lin

sound/soc/codecs/uda1380.c static struct i2c_driver uda1380_i2c_driver = { · line 872

Quoted 8 lines · Axel Lin
sound/soc/codecs/uda1380.c +2 -1
+	int ret = 0;
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	ret = i2c_add_driver(&uda1380_i2c_driver);
 	if (ret != 0)
 		pr_err("Failed to register UDA1380 I2C driver: %d\n", ret);
 #endif
-	return 0;
+	return ret;

In cases like this where only I2C is supported it's best to just remove all the ifdefs for I2C completely.

author
#7 lore raw

2011/12/4 Mark Brown <[email protected]>:

Quoted 11 lines · Axel Lin
Quoted 9 lines

+     int ret = 0;
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
      ret = i2c_add_driver(&uda1380_i2c_driver);
      if (ret != 0)
              pr_err("Failed to register UDA1380 I2C driver: %d\n", ret); #endif
-     return 0;
+     return ret;

Quoted 2 lines

In cases like this where only I2C is supported it's best to just remove all the ifdefs for I2C completely.

The datasheet says:
The UDA1380 supports I2C-bus microcontroller interface mode as well as the L3-bus mode.