]> git.ipfire.org Git - thirdparty/linux.git/commit
gpiolib: add gpiod_is_single_ended() helper
authorJie Li <lj29312931@gmail.com>
Mon, 11 May 2026 11:37:25 +0000 (13:37 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Mon, 11 May 2026 12:25:25 +0000 (14:25 +0200)
commitb5fafa01bdaade5253bd39317f5455d13e6efc7d
tree9d69eb5044f41cf70461740e7c945980f58ca9b0
parent254f49634ee16a731174d2ae34bc50bd5f45e731
gpiolib: add gpiod_is_single_ended() helper

The direction of a single-ended (open-drain or open-source) GPIO line
cannot always be reliably determined by reading hardware registers.
In true open-drain implementations, the "high" state is achieved by
entering a high-impedance mode, which many hardware controllers report
as "input" even if the software intends to use it as an output.

This creates issues for consumer drivers (like I2C) that rely on
gpiod_get_direction() to decide if a line can be driven.

Introduce gpiod_is_single_ended() to allow consumers to check the
software configuration (GPIO_FLAG_OPEN_DRAIN/GPIO_FLAG_OPEN_SOURCE) of
a descriptor. This provides a robust way to identify lines that are
capable of being driven, regardless of their instantaneous hardware state.

Signed-off-by: Jie Li <jie.i.li@nokia.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260511113726.49041-2-jie.i.li@nokia.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpiolib.c
include/linux/gpio/consumer.h