[alsa-devel] [PATCH 0/3] 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(-)
Replace the manual validity checks for the GPIO with the gpio_is_valid().
Signed-off-by: Arvind Yadav arvind.yadav.cs@gmail.com --- sound/soc/codecs/tlv320dac33.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index a957eae..c23b9db 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -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;
On 2018-04-27 11:56, Arvind Yadav wrote:
Replace the manual validity checks for the GPIO with the gpio_is_valid().
Acked-by: Peter Ujfalusi peter.ujfalusi@ti.com
Signed-off-by: Arvind Yadav arvind.yadav.cs@gmail.com
sound/soc/codecs/tlv320dac33.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index a957eae..c23b9db 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -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;
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Replace the manual validity checks for the GPIO with the gpio_is_valid().
Signed-off-by: Arvind Yadav arvind.yadav.cs@gmail.com --- sound/soc/codecs/tpa6130a2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 616cd4b..18f32b9 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -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) {
On 2018-04-27 11:56, Arvind Yadav wrote:
Replace the manual validity checks for the GPIO with the gpio_is_valid().
Acked-by: Peter Ujfalusi peter.ujfalusi@ti.com
Signed-off-by: Arvind Yadav arvind.yadav.cs@gmail.com
sound/soc/codecs/tpa6130a2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 616cd4b..18f32b9 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -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) {
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Replace the manual validity checks for the GPIO with the gpio_is_valid().
Signed-off-by: Arvind Yadav arvind.yadav.cs@gmail.com --- sound/soc/samsung/s3c24xx_simtec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/samsung/s3c24xx_simtec.c b/sound/soc/samsung/s3c24xx_simtec.c index 6de63f3..23e8ef9d 100644 --- a/sound/soc/samsung/s3c24xx_simtec.c +++ b/sound/soc/samsung/s3c24xx_simtec.c @@ -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); }
Hi Arvind,
On 04/27/2018 10:56 AM, Arvind Yadav wrote:
Replace the manual validity checks for the GPIO with the gpio_is_valid().
Signed-off-by: Arvind Yadav arvind.yadav.cs@gmail.com
The patch looks good to me but you need to send it directly to the ASoC maintainers to have it applied.
participants (3)
-
Arvind Yadav
-
Peter Ujfalusi
-
Sylwester Nawrocki