]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: reg: use new GPIO line value setter callbacks
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 23 Jun 2025 07:57:16 +0000 (09:57 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 7 Jul 2025 07:21:52 +0000 (09:21 +0200)
struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. Convert the legacy generic
gpio-reg module to using them. We have to update the two legacy ARM
platforms that use it at the same time as they call the set_multiple()
callbacks directly (they shouldn't but it's old technical debt I
suppose).

Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20250623-gpiochip-set-rv-gpio-v3-1-90f0e170a846@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
arch/arm/mach-sa1100/assabet.c
arch/arm/mach-sa1100/neponset.c
drivers/gpio/gpio-reg.c

index 2b833aa0212b294eecd7a8177d58c7cb50fe6c61..bad8aa661e9d0998e8238b6559757ec83bff4cb1 100644 (file)
@@ -80,7 +80,7 @@ void ASSABET_BCR_frob(unsigned int mask, unsigned int val)
 {
        unsigned long m = mask, v = val;
 
-       assabet_bcr_gc->set_multiple(assabet_bcr_gc, &m, &v);
+       assabet_bcr_gc->set_multiple_rv(assabet_bcr_gc, &m, &v);
 }
 EXPORT_SYMBOL(ASSABET_BCR_frob);
 
index 88fe79f0a4ed36a3bcae349fd037b52d0f9964d9..6516598c8a713bc5ca055be0934a03be73c07403 100644 (file)
@@ -126,7 +126,7 @@ void neponset_ncr_frob(unsigned int mask, unsigned int val)
        unsigned long m = mask, v = val;
 
        if (nep)
-               n->gpio[0]->set_multiple(n->gpio[0], &m, &v);
+               n->gpio[0]->set_multiple_rv(n->gpio[0], &m, &v);
        else
                WARN(1, "nep unset\n");
 }
index 73c7260d89c083a702b1d914ddca7a573a37de4a..d8da99f973850e5f4afa36d97c685f477837e665 100644 (file)
@@ -46,7 +46,7 @@ static int gpio_reg_direction_output(struct gpio_chip *gc, unsigned offset,
        if (r->direction & BIT(offset))
                return -ENOTSUPP;
 
-       gc->set(gc, offset, value);
+       gc->set_rv(gc, offset, value);
        return 0;
 }
 
@@ -57,7 +57,7 @@ static int gpio_reg_direction_input(struct gpio_chip *gc, unsigned offset)
        return r->direction & BIT(offset) ? 0 : -ENOTSUPP;
 }
 
-static void gpio_reg_set(struct gpio_chip *gc, unsigned offset, int value)
+static int gpio_reg_set(struct gpio_chip *gc, unsigned int offset, int value)
 {
        struct gpio_reg *r = to_gpio_reg(gc);
        unsigned long flags;
@@ -72,6 +72,8 @@ static void gpio_reg_set(struct gpio_chip *gc, unsigned offset, int value)
        r->out = val;
        writel_relaxed(val, r->reg);
        spin_unlock_irqrestore(&r->lock, flags);
+
+       return 0;
 }
 
 static int gpio_reg_get(struct gpio_chip *gc, unsigned offset)
@@ -92,8 +94,8 @@ static int gpio_reg_get(struct gpio_chip *gc, unsigned offset)
        return !!(val & mask);
 }
 
-static void gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long *mask,
-       unsigned long *bits)
+static int gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long *mask,
+                                unsigned long *bits)
 {
        struct gpio_reg *r = to_gpio_reg(gc);
        unsigned long flags;
@@ -102,6 +104,8 @@ static void gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long *mask,
        r->out = (r->out & ~*mask) | (*bits & *mask);
        writel_relaxed(r->out, r->reg);
        spin_unlock_irqrestore(&r->lock, flags);
+
+       return 0;
 }
 
 static int gpio_reg_to_irq(struct gpio_chip *gc, unsigned offset)
@@ -157,9 +161,9 @@ struct gpio_chip *gpio_reg_init(struct device *dev, void __iomem *reg,
        r->gc.get_direction = gpio_reg_get_direction;
        r->gc.direction_input = gpio_reg_direction_input;
        r->gc.direction_output = gpio_reg_direction_output;
-       r->gc.set = gpio_reg_set;
+       r->gc.set_rv = gpio_reg_set;
        r->gc.get = gpio_reg_get;
-       r->gc.set_multiple = gpio_reg_set_multiple;
+       r->gc.set_multiple_rv = gpio_reg_set_multiple;
        if (irqs)
                r->gc.to_irq = gpio_reg_to_irq;
        r->gc.base = base;