Re: [PATCH] gpiolib: normalize the return value of gc->set() on behalf of buggy drivers
From: Dmitry Torokhov
Date: Thu Feb 19 2026 - 03:58:09 EST
On February 19, 2026 12:52:37 AM PST, Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx> wrote:
>Commit 86ef402d805d ("gpiolib: sanitize the return value of
>gpio_chip::get()") started checking the return value of the .set()
>callback in struct gpio_chip. Now - almost a year later - it turns out
>that there are quite a few drivers in tree that can break with this
>change. Partially revert it: normalize the return value in GPIO core but
>also emit a warning.
>
>Cc: stable@xxxxxxxxxxxxxxx
>Fixes: 86ef402d805d ("gpiolib: sanitize the return value of gpio_chip::get()")
>Reported-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
>Closes: https://lore.kernel.org/all/aZSkqGTqMp_57qC7@xxxxxxxxxx/
>Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
>---
> drivers/gpio/gpiolib.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>index c52200eaaaff82b12f22dd1ee8459bdd8ec10d81..9f7a1a1ebd8365fe933c989caf9e8c544fd9ba0f 100644
>--- a/drivers/gpio/gpiolib.c
>+++ b/drivers/gpio/gpiolib.c
>@@ -2914,8 +2914,12 @@ static int gpiochip_set(struct gpio_chip *gc, unsigned int offset, int value)
> return -EOPNOTSUPP;
>
> ret = gc->set(gc, offset, value);
>- if (ret > 0)
>- ret = -EBADE;
>+ if (ret > 0) {
>+ gpiochip_warn(gc,
>+ "invalid return value from gc->set(): %d, consider fixing the driver\n",
>+ ret);
>+ ret = !!ret;
>+ }
>
> return ret;
> }
You want to patch gpiochip_get(). It could be that set() is similarly troublesome, but the report is about get() not working.
Thanks.
Hi Bartosz,
--
Dmitry