]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
gpio: shared: call gpio_chip::of_xlate() if set
authorBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Wed, 18 Mar 2026 14:00:53 +0000 (15:00 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Mon, 23 Mar 2026 08:54:24 +0000 (09:54 +0100)
commit710abda58055ed5eaa8958107633cc12a365c328
tree9e33d548834d3336c55ade7efe1f34efc892cca0
parent09c8ef6236004601b930965dfed432ac0e683b7e
gpio: shared: call gpio_chip::of_xlate() if set

OF-based GPIO controller drivers may provide a translation function that
calculates the real chip offset from whatever devicetree sources
provide. We need to take this into account in the shared GPIO management
and call of_xlate() if it's provided and adjust the entry->offset we
initially set when scanning the tree.

To that end: modify the shared GPIO API to take the GPIO chip as
argument on setup (to avoid having to rcu_dereference() it from the GPIO
device) and protect the access to entry->offset with the existing lock.

Fixes: a060b8c511ab ("gpiolib: implement low-level, shared GPIO support")
Reported-by: Jon Hunter <jonathanh@nvidia.com>
Closes: https://lore.kernel.org/all/921ba8ce-b18e-4a99-966d-c763d22081e2@nvidia.com/
Reviewed-by: Linus Walleij <linusw@kernel.org>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Link: https://patch.msgid.link/20260318-gpio-shared-xlate-v2-1-0ce34c707e81@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpiolib-shared.c
drivers/gpio/gpiolib-shared.h
drivers/gpio/gpiolib.c