gpiolib: Handle no pin_ranges in gpiochip_generic_config()
authorEmil Renner Berthing <emil.renner.berthing@canonical.com>
Mon, 19 Feb 2024 17:25:13 +0000 (18:25 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Tue, 20 Feb 2024 11:49:14 +0000 (12:49 +0100)
commitae366ba8576da0135d7d3db2dfa6304f3338d0c2
treeadf5b190cbfc06ad86456f747a98c9993b7978c5
parentb401b621758e46812da61fa58a67c3fd8d91de0d
gpiolib: Handle no pin_ranges in gpiochip_generic_config()

Similar to gpiochip_generic_request() and gpiochip_generic_free() the
gpiochip_generic_config() function needs to handle the case where there
are no pinctrl pins mapped to the GPIOs, usually through the gpio-ranges
device tree property.

Commit f34fd6ee1be8 ("gpio: dwapb: Use generic request, free and
set_config") set the .set_config callback to gpiochip_generic_config()
in the dwapb GPIO driver so the GPIO API can set pinctrl configuration
for the corresponding pins. Most boards using the dwapb driver do not
set the gpio-ranges device tree property though, and in this case
gpiochip_generic_config() would return -EPROPE_DEFER rather than the
previous -ENOTSUPP return value. This in turn makes
gpio_set_config_with_argument_optional() fail and propagate the error to
any driver requesting GPIOs.

Fixes: 2956b5d94a76 ("pinctrl / gpio: Introduce .set_config() callback for GPIO chips")
Reported-by: Jisheng Zhang <jszhang@kernel.org>
Closes: https://lore.kernel.org/linux-gpio/ZdC_g3U4l0CJIWzh@xhacker/
Tested-by: Jisheng Zhang <jszhang@kernel.org>
Signed-off-by: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpiolib.c