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

Reply via email to