Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpiolib: normalize the return value of gc->get() on behalf of buggy drivers

Commit 86ef402d805d ("gpiolib: sanitize the return value of
gpio_chip::get()") started checking the return value of the .get()
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@vger.kernel.org
Fixes: 86ef402d805d ("gpiolib: sanitize the return value of gpio_chip::get()")
Reported-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Closes: https://lore.kernel.org/all/aZSkqGTqMp_57qC7@google.com/
Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://patch.msgid.link/20260219-gpiolib-set-normalize-v2-1-f84630e45796@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

+6 -2
+6 -2
drivers/gpio/gpiolib.c
··· 3267 3267 3268 3268 /* Make sure this is called after checking for gc->get(). */ 3269 3269 ret = gc->get(gc, offset); 3270 - if (ret > 1) 3271 - ret = -EBADE; 3270 + if (ret > 1) { 3271 + gpiochip_warn(gc, 3272 + "invalid return value from gc->get(): %d, consider fixing the driver\n", 3273 + ret); 3274 + ret = !!ret; 3275 + } 3272 3276 3273 3277 return ret; 3274 3278 }