Skip to contentSkip to conversation

pinctrl: renesas: rza1: normalize return value of gpio_get

PATCH In review Dmitry Torokhov 5 participants 6 messages Feb 18 – Mar 10

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: renesas: rza1: normalize return value of gpio_get

The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by rza1_gpio_get() is normalized to the [0, 1] range.

---
 drivers/pinctrl/renesas/pinctrl-rza1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/renesas/pinctrl-rza1.c +1 -1
index 3cfa4c8be80e..d83c7d8ee82c 100644
@@ -589,7 +589,7 @@ static inline unsigned int rza1_get_bit(struct rza1_port *port,
 {
 	void __iomem *mem = RZA1_ADDR(port->base, reg, port->id);
 
-	return ioread16(mem) & BIT(bit);
+	return !!(ioread16(mem) & BIT(bit));
 }
 
 /**
Signature · 5 lines
2.53.0.335.g19a08e0c02-goog


-- 
Dmitry
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Dmitry Torokhov

The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by rza1_gpio_get() is normalized to the [0, 1] range.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Dmitry Torokhov
Quoted 26 lines · Dmitry Torokhov

The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by rza1_gpio_get() is normalized to the [0, 1] range.

---
 drivers/pinctrl/renesas/pinctrl-rza1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/renesas/pinctrl-rza1.c +1 -2
index 3cfa4c8be80e..d83c7d8ee82c 100644
@@ -589,7 +589,7 @@ static inline unsigned int rza1_get_bit(struct rza1_port *port,
 {
 	void __iomem *mem = RZA1_ADDR(port->base, reg, port->id);
 
-	return ioread16(mem) & BIT(bit);
+	return !!(ioread16(mem) & BIT(bit));
 }
 
 /**
--

2.53.0.335.g19a08e0c02-goog

Quoted 3 lines

--
Dmitry

#4 lore raw
Quoted 7 lines · Linus Walleij
Quoted 4 lines · Dmitry Torokhov

The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by rza1_gpio_get() is normalized to the [0, 1] range.

Quoted 5 lines
Quoted 1 line

I expect Geert will pick this up, else tell me & I'll queue it.

Geert, will you pick it up please?

Thanks.

Signature · 1 line
Dmitry
Reviewed-by
#5 lore raw

Hi Dmitry,

Quoted 8 lines · Dmitry Torokhov
Quoted 7 lines · Linus Walleij
Quoted 4 lines · Dmitry Torokhov

The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by rza1_gpio_get() is normalized to the [0, 1] range.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

I expect Geert will pick this up, else tell me & I'll queue it.

Geert, will you pick it up please?

Sorry, I am seriously running behind with patch review. I hadn't realized this is a serious issue, but apparently the 0/1 behavior is enforced since commit 86ef402d805d606a ("gpiolib: sanitize the return value of gpio_chip::get()"), thus rendering the RZ/A1 GPIO driver broken since v6.15-rc1. Unfortunately this doesn't show up in my limited boot testing of RSK+RZA1 :-(

So:

Fixes 86ef402d805d606a ("gpiolib: sanitize the return value of

gpio_chip::get()")

Oh, that got relaxed again in commit ec2cceadfae72304 ("gpiolib:
normalize the return value of gc->get() on behalf of buggy drivers") in v7.0-rc3, so apparently we're not the only ones...

BTW, that's all info I would have liked to see before ;-)

i.e. will queue in renesas-pinctrl-fixes for v7.0.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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