]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: axp209: use new GPIO line value setter callbacks
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Thu, 24 Apr 2025 08:35:25 +0000 (10:35 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 29 Apr 2025 08:34:19 +0000 (10:34 +0200)
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: Chen-Yu Tsai <wens@csie.org>
Link: https://lore.kernel.org/20250424-gpiochip-set-rv-pinctrl-part2-v1-2-504f91120b99@linaro.org
[Drop unnecessary curly braces]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pinctrl-axp209.c

index 2b4805e74eed32bd5a5d3e20143bb80571ffa349..fff408b60c4acfe1ac98845c56c94908c81bac3b 100644 (file)
@@ -192,34 +192,30 @@ static int axp20x_gpio_get_direction(struct gpio_chip *chip,
 static int axp20x_gpio_output(struct gpio_chip *chip, unsigned int offset,
                              int value)
 {
-       chip->set(chip, offset, value);
-
-       return 0;
+       return chip->set_rv(chip, offset, value);
 }
 
-static void axp20x_gpio_set(struct gpio_chip *chip, unsigned int offset,
-                           int value)
+static int axp20x_gpio_set(struct gpio_chip *chip, unsigned int offset,
+                          int value)
 {
        struct axp20x_pctl *pctl = gpiochip_get_data(chip);
        int reg;
 
        /* AXP209 has GPIO3 status sharing the settings register */
-       if (offset == 3) {
-               regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL,
-                                  AXP20X_GPIO3_FUNCTIONS,
-                                  value ? AXP20X_GPIO3_FUNCTION_OUT_HIGH :
-                                  AXP20X_GPIO3_FUNCTION_OUT_LOW);
-               return;
-       }
+       if (offset == 3)
+               return regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL,
+                                         AXP20X_GPIO3_FUNCTIONS,
+                                         value ?
+                                               AXP20X_GPIO3_FUNCTION_OUT_HIGH :
+                                               AXP20X_GPIO3_FUNCTION_OUT_LOW);
 
        reg = axp20x_gpio_get_reg(offset);
        if (reg < 0)
-               return;
+               return reg;
 
-       regmap_update_bits(pctl->regmap, reg,
-                          AXP20X_GPIO_FUNCTIONS,
-                          value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
-                          AXP20X_GPIO_FUNCTION_OUT_LOW);
+       return regmap_update_bits(pctl->regmap, reg, AXP20X_GPIO_FUNCTIONS,
+                                 value ? AXP20X_GPIO_FUNCTION_OUT_HIGH :
+                                         AXP20X_GPIO_FUNCTION_OUT_LOW);
 }
 
 static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
@@ -229,12 +225,11 @@ static int axp20x_pmx_set(struct pinctrl_dev *pctldev, unsigned int offset,
        int reg;
 
        /* AXP209 GPIO3 settings have a different layout */
-       if (offset == 3) {
+       if (offset == 3)
                return regmap_update_bits(pctl->regmap, AXP20X_GPIO3_CTRL,
                                   AXP20X_GPIO3_FUNCTIONS,
                                   config == AXP20X_MUX_GPIO_OUT ? AXP20X_GPIO3_FUNCTION_OUT_LOW :
                                   AXP20X_GPIO3_FUNCTION_INPUT);
-       }
 
        reg = axp20x_gpio_get_reg(offset);
        if (reg < 0)
@@ -468,7 +463,7 @@ static int axp20x_pctl_probe(struct platform_device *pdev)
        pctl->chip.owner                = THIS_MODULE;
        pctl->chip.get                  = axp20x_gpio_get;
        pctl->chip.get_direction        = axp20x_gpio_get_direction;
-       pctl->chip.set                  = axp20x_gpio_set;
+       pctl->chip.set_rv               = axp20x_gpio_set;
        pctl->chip.direction_input      = pinctrl_gpio_direction_input;
        pctl->chip.direction_output     = axp20x_gpio_output;