* [PATCH] gpio: rcar: Use new line value setter callbacks
@ 2025-06-13 8:09 Geert Uytterhoeven
2025-06-13 9:00 ` Wolfram Sang
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2025-06-13 8:09 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Magnus Damm
Cc: linux-gpio, linux-renesas-soc, Geert Uytterhoeven
struct gpio_chip now has callbacks for setting line values that return
integers, so they can indicate failures. Convert the driver to using
them.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/gpio/gpio-rcar.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 4fc7cad5032a7a80..130aa0cac186d0cb 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -359,7 +359,7 @@ static int gpio_rcar_get_multiple(struct gpio_chip *chip, unsigned long *mask,
return 0;
}
-static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)
+static int gpio_rcar_set(struct gpio_chip *chip, unsigned int offset, int value)
{
struct gpio_rcar_priv *p = gpiochip_get_data(chip);
unsigned long flags;
@@ -367,10 +367,12 @@ static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)
raw_spin_lock_irqsave(&p->lock, flags);
gpio_rcar_modify_bit(p, OUTDT, offset, value);
raw_spin_unlock_irqrestore(&p->lock, flags);
+
+ return 0;
}
-static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
- unsigned long *bits)
+static int gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
+ unsigned long *bits)
{
struct gpio_rcar_priv *p = gpiochip_get_data(chip);
unsigned long flags;
@@ -378,7 +380,7 @@ static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0);
if (!bankmask)
- return;
+ return 0;
raw_spin_lock_irqsave(&p->lock, flags);
val = gpio_rcar_read(p, OUTDT);
@@ -386,6 +388,8 @@ static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask,
val |= (bankmask & bits[0]);
gpio_rcar_write(p, OUTDT, val);
raw_spin_unlock_irqrestore(&p->lock, flags);
+
+ return 0;
}
static int gpio_rcar_direction_output(struct gpio_chip *chip, unsigned offset,
@@ -537,8 +541,8 @@ static int gpio_rcar_probe(struct platform_device *pdev)
gpio_chip->get = gpio_rcar_get;
gpio_chip->get_multiple = gpio_rcar_get_multiple;
gpio_chip->direction_output = gpio_rcar_direction_output;
- gpio_chip->set = gpio_rcar_set;
- gpio_chip->set_multiple = gpio_rcar_set_multiple;
+ gpio_chip->set_rv = gpio_rcar_set;
+ gpio_chip->set_multiple_rv = gpio_rcar_set_multiple;
gpio_chip->label = name;
gpio_chip->parent = dev;
gpio_chip->owner = THIS_MODULE;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: rcar: Use new line value setter callbacks
2025-06-13 8:09 [PATCH] gpio: rcar: Use new line value setter callbacks Geert Uytterhoeven
@ 2025-06-13 9:00 ` Wolfram Sang
2025-06-13 12:02 ` Geert Uytterhoeven
0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2025-06-13 9:00 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linus Walleij, Bartosz Golaszewski, Magnus Damm, linux-gpio,
linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 222 bytes --]
> bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0);
> if (!bankmask)
> - return;
> + return 0;
Doesn't that mean that the mask is invalid and we could return an error
here? Or is '!bankmask' an expected use-case?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: rcar: Use new line value setter callbacks
2025-06-13 9:00 ` Wolfram Sang
@ 2025-06-13 12:02 ` Geert Uytterhoeven
2025-06-17 9:06 ` Bartosz Golaszewski
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2025-06-13 12:02 UTC (permalink / raw)
To: Wolfram Sang
Cc: Linus Walleij, Bartosz Golaszewski, Magnus Damm, linux-gpio,
linux-renesas-soc
Hi Wolfram,
On Fri, 13 Jun 2025 at 13:42, Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> > bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0);
> > if (!bankmask)
> > - return;
> > + return 0;
>
> Doesn't that mean that the mask is invalid and we could return an error
> here? Or is '!bankmask' an expected use-case?
That is a good question!
I _think_ this really can't happen anymore, as the GPIO core is supposed
to check this against the valid mask? Or isn't it?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: rcar: Use new line value setter callbacks
2025-06-13 12:02 ` Geert Uytterhoeven
@ 2025-06-17 9:06 ` Bartosz Golaszewski
2025-06-17 9:12 ` Geert Uytterhoeven
0 siblings, 1 reply; 6+ messages in thread
From: Bartosz Golaszewski @ 2025-06-17 9:06 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Wolfram Sang, Linus Walleij, Magnus Damm, linux-gpio,
linux-renesas-soc
On Fri, Jun 13, 2025 at 2:02 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Wolfram,
>
> On Fri, 13 Jun 2025 at 13:42, Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> > > bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0);
> > > if (!bankmask)
> > > - return;
> > > + return 0;
> >
> > Doesn't that mean that the mask is invalid and we could return an error
> > here? Or is '!bankmask' an expected use-case?
>
> That is a good question!
>
> I _think_ this really can't happen anymore, as the GPIO core is supposed
> to check this against the valid mask? Or isn't it?
>
Yes but this doesn't seem to have anything to do with the valid_mask?
If it's about the number of GPIOs then that too is verified by GPIO
core.
Bart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: rcar: Use new line value setter callbacks
2025-06-17 9:06 ` Bartosz Golaszewski
@ 2025-06-17 9:12 ` Geert Uytterhoeven
2025-06-17 9:13 ` Bartosz Golaszewski
0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2025-06-17 9:12 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Wolfram Sang, Linus Walleij, Magnus Damm, linux-gpio,
linux-renesas-soc
Hi Bartosz,
On Tue, 17 Jun 2025 at 11:06, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> On Fri, Jun 13, 2025 at 2:02 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Fri, 13 Jun 2025 at 13:42, Wolfram Sang
> > <wsa+renesas@sang-engineering.com> wrote:
> > > > bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0);
> > > > if (!bankmask)
> > > > - return;
> > > > + return 0;
> > >
> > > Doesn't that mean that the mask is invalid and we could return an error
> > > here? Or is '!bankmask' an expected use-case?
> >
> > That is a good question!
> >
> > I _think_ this really can't happen anymore, as the GPIO core is supposed
> > to check this against the valid mask? Or isn't it?
>
> Yes but this doesn't seem to have anything to do with the valid_mask?
> If it's about the number of GPIOs then that too is verified by GPIO
> core.
Sure, about the collection of valid GPIO offsets. So it cannot really
happen, and just bailing out with zero sounds fine to me?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: rcar: Use new line value setter callbacks
2025-06-17 9:12 ` Geert Uytterhoeven
@ 2025-06-17 9:13 ` Bartosz Golaszewski
0 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2025-06-17 9:13 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Wolfram Sang, Linus Walleij, Magnus Damm, linux-gpio,
linux-renesas-soc
On Tue, Jun 17, 2025 at 11:12 AM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>
> Hi Bartosz,
>
> On Tue, 17 Jun 2025 at 11:06, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> > On Fri, Jun 13, 2025 at 2:02 PM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > > On Fri, 13 Jun 2025 at 13:42, Wolfram Sang
> > > <wsa+renesas@sang-engineering.com> wrote:
> > > > > bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0);
> > > > > if (!bankmask)
> > > > > - return;
> > > > > + return 0;
> > > >
> > > > Doesn't that mean that the mask is invalid and we could return an error
> > > > here? Or is '!bankmask' an expected use-case?
> > >
> > > That is a good question!
> > >
> > > I _think_ this really can't happen anymore, as the GPIO core is supposed
> > > to check this against the valid mask? Or isn't it?
> >
> > Yes but this doesn't seem to have anything to do with the valid_mask?
> > If it's about the number of GPIOs then that too is verified by GPIO
> > core.
>
> Sure, about the collection of valid GPIO offsets. So it cannot really
> happen, and just bailing out with zero sounds fine to me?
>
If this cannot happen, then why not drop the check?
Bart
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-17 9:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-13 8:09 [PATCH] gpio: rcar: Use new line value setter callbacks Geert Uytterhoeven
2025-06-13 9:00 ` Wolfram Sang
2025-06-13 12:02 ` Geert Uytterhoeven
2025-06-17 9:06 ` Bartosz Golaszewski
2025-06-17 9:12 ` Geert Uytterhoeven
2025-06-17 9:13 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox