Commit ec2ccead authored by Bartosz Golaszewski's avatar Bartosz Golaszewski
Browse files

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



Commit 86ef402d ("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: 86ef402d ("gpiolib: sanitize the return value of gpio_chip::get()")
Reported-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Closes: https://lore.kernel.org/all/aZSkqGTqMp_57qC7@google.com/


Reviewed-by: default avatarLinus Walleij <linusw@kernel.org>
Reviewed-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://patch.msgid.link/20260219-gpiolib-set-normalize-v2-1-f84630e45796@oss.qualcomm.com


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
parent 32e0a7ad
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -3267,8 +3267,12 @@ static int gpiochip_get(struct gpio_chip *gc, unsigned int offset)

	/* Make sure this is called after checking for gc->get(). */
	ret = gc->get(gc, offset);
	if (ret > 1)
		ret = -EBADE;
	if (ret > 1) {
		gpiochip_warn(gc,
			"invalid return value from gc->get(): %d, consider fixing the driver\n",
			ret);
		ret = !!ret;
	}

	return ret;
}