diff mbox series

[03/15] gpio: bd71815: use new line value setter callbacks

Message ID 20250310-gpiochip-set-conversion-v1-3-03798bb833eb@linaro.org (mailing list archive)
State New
Delegated to: Geert Uytterhoeven
Headers show
Series gpio: more gpio_chip setter conversions | expand

Commit Message

Bartosz Golaszewski March 10, 2025, 12:40 p.m. UTC
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the driver to using
them.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/gpio/gpio-bd71815.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Comments

Matti Vaittinen March 10, 2025, 1:16 p.m. UTC | #1
On 10/03/2025 14:40, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> struct gpio_chip now has callbacks for setting line values that return
> an integer, allowing to indicate failures. Convert the driver to using
> them.
> 
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

Thanks!

> ---
>   drivers/gpio/gpio-bd71815.c | 15 ++++++---------
>   1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-bd71815.c b/drivers/gpio/gpio-bd71815.c
> index 08ff2857256f..36701500925e 100644
> --- a/drivers/gpio/gpio-bd71815.c
> +++ b/drivers/gpio/gpio-bd71815.c
> @@ -37,21 +37,18 @@ static int bd71815gpo_get(struct gpio_chip *chip, unsigned int offset)
>   	return (val >> offset) & 1;
>   }
>   
> -static void bd71815gpo_set(struct gpio_chip *chip, unsigned int offset,
> -			   int value)
> +static int bd71815gpo_set(struct gpio_chip *chip, unsigned int offset,
> +			  int value)
>   {
>   	struct bd71815_gpio *bd71815 = gpiochip_get_data(chip);
> -	int ret, bit;
> +	int bit;
>   
>   	bit = BIT(offset);
>   
>   	if (value)
> -		ret = regmap_set_bits(bd71815->regmap, BD71815_REG_GPO, bit);
> -	else
> -		ret = regmap_clear_bits(bd71815->regmap, BD71815_REG_GPO, bit);
> +		return regmap_set_bits(bd71815->regmap, BD71815_REG_GPO, bit);
>   
> -	if (ret)
> -		dev_warn(bd71815->dev, "failed to toggle GPO\n");
> +	return regmap_clear_bits(bd71815->regmap, BD71815_REG_GPO, bit);
>   }
>   
>   static int bd71815_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
> @@ -88,7 +85,7 @@ static const struct gpio_chip bd71815gpo_chip = {
>   	.owner			= THIS_MODULE,
>   	.get			= bd71815gpo_get,
>   	.get_direction		= bd71815gpo_direction_get,
> -	.set			= bd71815gpo_set,
> +	.set_rv			= bd71815gpo_set,
>   	.set_config		= bd71815_gpio_set_config,
>   	.can_sleep		= true,
>   };
>
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-bd71815.c b/drivers/gpio/gpio-bd71815.c
index 08ff2857256f..36701500925e 100644
--- a/drivers/gpio/gpio-bd71815.c
+++ b/drivers/gpio/gpio-bd71815.c
@@ -37,21 +37,18 @@  static int bd71815gpo_get(struct gpio_chip *chip, unsigned int offset)
 	return (val >> offset) & 1;
 }
 
-static void bd71815gpo_set(struct gpio_chip *chip, unsigned int offset,
-			   int value)
+static int bd71815gpo_set(struct gpio_chip *chip, unsigned int offset,
+			  int value)
 {
 	struct bd71815_gpio *bd71815 = gpiochip_get_data(chip);
-	int ret, bit;
+	int bit;
 
 	bit = BIT(offset);
 
 	if (value)
-		ret = regmap_set_bits(bd71815->regmap, BD71815_REG_GPO, bit);
-	else
-		ret = regmap_clear_bits(bd71815->regmap, BD71815_REG_GPO, bit);
+		return regmap_set_bits(bd71815->regmap, BD71815_REG_GPO, bit);
 
-	if (ret)
-		dev_warn(bd71815->dev, "failed to toggle GPO\n");
+	return regmap_clear_bits(bd71815->regmap, BD71815_REG_GPO, bit);
 }
 
 static int bd71815_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -88,7 +85,7 @@  static const struct gpio_chip bd71815gpo_chip = {
 	.owner			= THIS_MODULE,
 	.get			= bd71815gpo_get,
 	.get_direction		= bd71815gpo_direction_get,
-	.set			= bd71815gpo_set,
+	.set_rv			= bd71815gpo_set,
 	.set_config		= bd71815_gpio_set_config,
 	.can_sleep		= true,
 };