2018-04-27 08:57:58

by Arvind Yadav

[permalink] [raw]
Subject: [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(-)

--
1.9.1



2018-04-27 08:58:01

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 1/3] ASoC: tlv320dac33: Use gpio_is_valid()

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

Signed-off-by: Arvind Yadav <[email protected]>
---
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;
--
1.9.1


2018-04-27 08:58:03

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 3/3] ASoC: samsung: Use gpio_is_valid()

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

Signed-off-by: Arvind Yadav <[email protected]>
---
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);
}

--
1.9.1


2018-04-27 08:58:38

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 2/3] ASoC: tpa6130a2: Use gpio_is_valid()

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

Signed-off-by: Arvind Yadav <[email protected]>
---
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) {
--
1.9.1


2018-04-27 09:34:52

by Peter Ujfalusi

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



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 <[email protected]>

> Signed-off-by: Arvind Yadav <[email protected]>
> ---
> 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

2018-04-27 09:36:01

by Peter Ujfalusi

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



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 <[email protected]>

> Signed-off-by: Arvind Yadav <[email protected]>
> ---
> 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

2018-04-27 09:36:18

by Sylwester Nawrocki

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

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 <[email protected]>

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

--
Regards,
Sylwester