Skip to contentSkip to conversation

ASoC: Use gpio_is_valid()

PATCH In review Arvind Yadav 3 participants 7 messages Apr 27, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Use gpio_is_valid()

Replace the manual validity checks for the GPIO with the gpio_is_valid().

Arvind Yadav (3):
[PATCH 1/3] ASoC: tlv320dac33: Use gpio_is_valid() [PATCH 2/3] ASoC: tpa6130a2: Use gpio_is_valid() [PATCH 3/3] ASoC: samsung: Use gpio_is_valid()

 sound/soc/codecs/tlv320dac33.c     | 10 +++++-----
 sound/soc/codecs/tpa6130a2.c       |  8 ++++----
 sound/soc/samsung/s3c24xx_simtec.c | 10 +++++-----
 3 files changed, 14 insertions(+), 14 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 ASoC: tlv320dac33: Use gpio_is_valid()

Replace the manual validity checks for the GPIO with the gpio_is_valid().

---
 sound/soc/codecs/tlv320dac33.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/tlv320dac33.c +5 -5
index a957eae..c23b9db 100644
@@ -397,13 +397,13 @@ static int dac33_hard_power(struct snd_soc_component *component, int power)
 				goto exit;
 		}
 
-		if (dac33->power_gpio >= 0)
+		if (gpio_is_valid(dac33->power_gpio))
 			gpio_set_value(dac33->power_gpio, 1);
 
 		dac33->chip_power = 1;
 	} else {
 		dac33_soft_power(component, 0);
-		if (dac33->power_gpio >= 0)
+		if (gpio_is_valid(dac33->power_gpio))
 			gpio_set_value(dac33->power_gpio, 0);
 
 		ret = regulator_bulk_disable(ARRAY_SIZE(dac33->supplies),
@@ -1519,7 +1519,7 @@ static int dac33_i2c_probe(struct i2c_client *client,
 	dac33->fifo_mode = DAC33_FIFO_BYPASS;
 
 	/* Check if the reset GPIO number is valid and request it */
-	if (dac33->power_gpio >= 0) {
+	if (gpio_is_valid(dac33->power_gpio)) {
 		ret = gpio_request(dac33->power_gpio, "tlv320dac33 reset");
 		if (ret < 0) {
 			dev_err(&client->dev,
@@ -1548,7 +1548,7 @@ static int dac33_i2c_probe(struct i2c_client *client,
 
 	return ret;
 err_get:
-	if (dac33->power_gpio >= 0)
+	if (gpio_is_valid(dac33->power_gpio))
 		gpio_free(dac33->power_gpio);
 err_gpio:
 	return ret;
@@ -1561,7 +1561,7 @@ static int dac33_i2c_remove(struct i2c_client *client)
 	if (unlikely(dac33->chip_power))
 		dac33_hard_power(dac33->component, 0);
 
-	if (dac33->power_gpio >= 0)
+	if (gpio_is_valid(dac33->power_gpio))
 		gpio_free(dac33->power_gpio);
 
 	return 0;
Signature · 1 line
1.9.1
Acked-by on v1 1/3
#2 lore raw

Re: [alsa-devel] [PATCH 1/3] ASoC: tlv320dac33: Use gpio_is_valid()

Quoted 2 lines · Arvind Yadav

Replace the manual validity checks for the GPIO with the gpio_is_valid().

Quoted 45 lines
---
 sound/soc/codecs/tlv320dac33.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/codecs/tlv320dac33.c +4 -4
index a957eae..c23b9db 100644
@@ -397,13 +397,13 @@ static int dac33_hard_power(struct snd_soc_component *component, int power)
 				goto exit;
 		}
 
-		if (dac33->power_gpio >= 0)
+		if (gpio_is_valid(dac33->power_gpio))
 			gpio_set_value(dac33->power_gpio, 1);
 
 		dac33->chip_power = 1;
 	} else {
 		dac33_soft_power(component, 0);
-		if (dac33->power_gpio >= 0)
+		if (gpio_is_valid(dac33->power_gpio))
 			gpio_set_value(dac33->power_gpio, 0);
 
 		ret = regulator_bulk_disable(ARRAY_SIZE(dac33->supplies),
@@ -1519,7 +1519,7 @@ static int dac33_i2c_probe(struct i2c_client *client,
 	dac33->fifo_mode = DAC33_FIFO_BYPASS;
 
 	/* Check if the reset GPIO number is valid and request it */
-	if (dac33->power_gpio >= 0) {
+	if (gpio_is_valid(dac33->power_gpio)) {
 		ret = gpio_request(dac33->power_gpio, "tlv320dac33 reset");
 		if (ret < 0) {
 			dev_err(&client->dev,
@@ -1548,7 +1548,7 @@ static int dac33_i2c_probe(struct i2c_client *client,
 
 	return ret;
 err_get:
-	if (dac33->power_gpio >= 0)
+	if (gpio_is_valid(dac33->power_gpio))
 		gpio_free(dac33->power_gpio);
 err_gpio:
 	return ret;

sound/soc/codecs/tlv320dac33.c static int dac33_i2c_remove(struct i2c_client *client) · line 1567

Quoted 8 lines
sound/soc/codecs/tlv320dac33.c +1 -1
@@ -1561,7 +1561,7 @@ static int dac33_i2c_remove(struct i2c_client *client)
 	if (unlikely(dac33->chip_power))
 		dac33_hard_power(dac33->component, 0);
 
-	if (dac33->power_gpio >= 0)
+	if (gpio_is_valid(dac33->power_gpio))
 		gpio_free(dac33->power_gpio);
 
 	return 0;

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw

PATCH 2/3 ASoC: tpa6130a2: Use gpio_is_valid()

In reply to Arvind Yadav

Replace the manual validity checks for the GPIO with the gpio_is_valid().

---
 sound/soc/codecs/tpa6130a2.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/tpa6130a2.c +4 -4
index 616cd4b..18f32b9 100644
@@ -62,7 +62,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
 			return ret;
 		}
 		/* Power on */
-		if (data->power_gpio >= 0)
+		if (gpio_is_valid(data->power_gpio))
 			gpio_set_value(data->power_gpio, 1);
 
 		/* Sync registers */
@@ -72,7 +72,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
 			dev_err(data->dev,
 				"Failed to sync registers: %d\n", ret);
 			regcache_cache_only(data->regmap, true);
-			if (data->power_gpio >= 0)
+			if (gpio_is_valid(data->power_gpio))
 				gpio_set_value(data->power_gpio, 0);
 			ret2 = regulator_disable(data->supply);
 			if (ret2 != 0)
@@ -89,7 +89,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
 		regcache_cache_only(data->regmap, true);
 
 		/* Power off */
-		if (data->power_gpio >= 0)
+		if (gpio_is_valid(data->power_gpio))
 			gpio_set_value(data->power_gpio, 0);
 
 		ret = regulator_disable(data->supply);
@@ -259,7 +259,7 @@ static int tpa6130a2_probe(struct i2c_client *client,
 
 	data->id = id->driver_data;
 
-	if (data->power_gpio >= 0) {
+	if (gpio_is_valid(data->power_gpio)) {
 		ret = devm_gpio_request(dev, data->power_gpio,
 					"tpa6130a2 enable");
 		if (ret < 0) {
Signature · 1 line
1.9.1
Acked-by on v1 2/3
#4 lore raw

Re: [alsa-devel] [PATCH 2/3] ASoC: tpa6130a2: Use gpio_is_valid()

Quoted 2 lines · Arvind Yadav

Replace the manual validity checks for the GPIO with the gpio_is_valid().

Quoted 38 lines
---
 sound/soc/codecs/tpa6130a2.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/tpa6130a2.c +3 -3
index 616cd4b..18f32b9 100644
@@ -62,7 +62,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
 			return ret;
 		}
 		/* Power on */
-		if (data->power_gpio >= 0)
+		if (gpio_is_valid(data->power_gpio))
 			gpio_set_value(data->power_gpio, 1);
 
 		/* Sync registers */
@@ -72,7 +72,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
 			dev_err(data->dev,
 				"Failed to sync registers: %d\n", ret);
 			regcache_cache_only(data->regmap, true);
-			if (data->power_gpio >= 0)
+			if (gpio_is_valid(data->power_gpio))
 				gpio_set_value(data->power_gpio, 0);
 			ret2 = regulator_disable(data->supply);
 			if (ret2 != 0)
@@ -89,7 +89,7 @@ static int tpa6130a2_power(struct tpa6130a2_data *data, bool enable)
 		regcache_cache_only(data->regmap, true);
 
 		/* Power off */
-		if (data->power_gpio >= 0)
+		if (gpio_is_valid(data->power_gpio))
 			gpio_set_value(data->power_gpio, 0);
 
 		ret = regulator_disable(data->supply);

sound/soc/codecs/tpa6130a2.c static int tpa6130a2_probe(struct i2c_client *client, · line 265

Quoted 8 lines
sound/soc/codecs/tpa6130a2.c +1 -1
@@ -259,7 +259,7 @@ static int tpa6130a2_probe(struct i2c_client *client,
 
 	data->id = id->driver_data;
 
-	if (data->power_gpio >= 0) {
+	if (gpio_is_valid(data->power_gpio)) {
 		ret = devm_gpio_request(dev, data->power_gpio,
 					"tpa6130a2 enable");
 		if (ret < 0) {

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw

PATCH 3/3 ASoC: samsung: Use gpio_is_valid()

In reply to Arvind Yadav

Replace the manual validity checks for the GPIO with the gpio_is_valid().

---
 sound/soc/samsung/s3c24xx_simtec.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
sound/soc/samsung/s3c24xx_simtec.c +5 -5
index 6de63f3..23e8ef9d 100644
@@ -229,7 +229,7 @@ static int attach_gpio_amp(struct device *dev,
 	int ret;
 
 	/* attach gpio amp gain (if any) */
-	if (pdata->amp_gain[0] > 0) {
+	if (gpio_is_valid(pdata->amp_gain[0])) {
 		ret = gpio_request(pd->amp_gain[0], "gpio-amp-gain0");
 		if (ret) {
 			dev_err(dev, "cannot get amp gpio gain0\n");
@@ -248,7 +248,7 @@ static int attach_gpio_amp(struct device *dev,
 	}
 
 	/* note, currently we assume GPA0 isn't valid amp */
-	if (pdata->amp_gpio > 0) {
+	if (gpio_is_valid(pdata->amp_gpio)) {
 		ret = gpio_request(pd->amp_gpio, "gpio-amp");
 		if (ret) {
 			dev_err(dev, "cannot get amp gpio %d (%d)\n",
@@ -263,7 +263,7 @@ static int attach_gpio_amp(struct device *dev,
 	return 0;
 
 err_amp:
-	if (pd->amp_gain[0] > 0) {
+	if (gpio_is_valid(pd->amp_gain[0])) {
 		gpio_free(pd->amp_gain[0]);
 		gpio_free(pd->amp_gain[1]);
 	}
@@ -273,12 +273,12 @@ static int attach_gpio_amp(struct device *dev,
 
 static void detach_gpio_amp(struct s3c24xx_audio_simtec_pdata *pd)
 {
-	if (pd->amp_gain[0] > 0) {
+	if (gpio_is_valid(pd->amp_gain[0])) {
 		gpio_free(pd->amp_gain[0]);
 		gpio_free(pd->amp_gain[1]);
 	}
 
-	if (pd->amp_gpio > 0)
+	if (gpio_is_valid(pd->amp_gpio))
 		gpio_free(pd->amp_gpio);
 }
 
Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH 3/3] ASoC: samsung: Use gpio_is_valid()

Hi Arvind,

Quoted 4 lines · Arvind Yadav

Replace the manual validity checks for the GPIO with the gpio_is_valid().

The patch looks good to me but you need to send it directly to the ASoC maintainers to have it applied.

Signature · 2 lines
Regards,
Sylwester