staging: greybus: use new GPIO line value setter callbacks
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 7 Apr 2025 07:14:52 +0000 (09:14 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Apr 2025 14:26:48 +0000 (16:26 +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: Alex Elder <elder@riscstar.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20250407-gpiochip-set-rv-greybus-v1-1-9d4f721db7ca@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/gpio.c

index 16bcf7fc8158659284dff900d33befa3b65fe7be..f81c34160f720b7dcb55b5f6acb9da890dbafce2 100644 (file)
@@ -185,8 +185,8 @@ static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc,
        return 0;
 }
 
-static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
-                                       u8 which, bool value_high)
+static int gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
+                                      u8 which, bool value_high)
 {
        struct device *dev = &ggc->gbphy_dev->dev;
        struct gb_gpio_set_value_request request;
@@ -195,7 +195,7 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
        if (ggc->lines[which].direction == 1) {
                dev_warn(dev, "refusing to set value of input gpio %u\n",
                         which);
-               return;
+               return -EPERM;
        }
 
        request.which = which;
@@ -204,10 +204,12 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc,
                                &request, sizeof(request), NULL, 0);
        if (ret) {
                dev_err(dev, "failed to set value of gpio %u\n", which);
-               return;
+               return ret;
        }
 
        ggc->lines[which].value = request.value;
+
+       return 0;
 }
 
 static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc,
@@ -457,11 +459,11 @@ static int gb_gpio_get(struct gpio_chip *chip, unsigned int offset)
        return ggc->lines[which].value;
 }
 
-static void gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
+static int gb_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
 {
        struct gb_gpio_controller *ggc = gpiochip_get_data(chip);
 
-       gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
+       return gb_gpio_set_value_operation(ggc, (u8)offset, !!value);
 }
 
 static int gb_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -555,7 +557,7 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev,
        gpio->direction_input = gb_gpio_direction_input;
        gpio->direction_output = gb_gpio_direction_output;
        gpio->get = gb_gpio_get;
-       gpio->set = gb_gpio_set;
+       gpio->set_rv = gb_gpio_set;
        gpio->set_config = gb_gpio_set_config;
        gpio->base = -1;                /* Allocate base dynamically */
        gpio->ngpio = ggc->line_max + 1;