Skip to content

Commit ae366ba

Browse files
esmilBartosz Golaszewski
authored andcommitted
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 f34fd6e ("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: 2956b5d ("pinctrl / gpio: Introduce .set_config() callback for GPIO chips") Reported-by: Jisheng Zhang <[email protected]> Closes: https://lore.kernel.org/linux-gpio/ZdC_g3U4l0CJIWzh@xhacker/ Tested-by: Jisheng Zhang <[email protected]> Signed-off-by: Emil Renner Berthing <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent b401b62 commit ae366ba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/gpio/gpiolib.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,11 @@ EXPORT_SYMBOL_GPL(gpiochip_generic_free);
20422042
int gpiochip_generic_config(struct gpio_chip *gc, unsigned int offset,
20432043
unsigned long config)
20442044
{
2045+
#ifdef CONFIG_PINCTRL
2046+
if (list_empty(&gc->gpiodev->pin_ranges))
2047+
return -ENOTSUPP;
2048+
#endif
2049+
20452050
return pinctrl_gpio_set_config(gc, offset, config);
20462051
}
20472052
EXPORT_SYMBOL_GPL(gpiochip_generic_config);

0 commit comments

Comments
 (0)