[PATCH] gpiolib: normalize the return value of gc->set() on behalf of buggy drivers
From: Bartosz Golaszewski
Date: Thu Feb 19 2026 - 03:53:01 EST
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;
}
---
base-commit: 50f68cc7be0a2cbf54d8f6aaf17df32fb01acc3f
change-id: 20260219-gpiolib-set-normalize-1080e2eda113
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>