Skip to content

Commit c40aa80

Browse files
andy-shevlinusw
authored andcommitted
gpiolib: Check "gpio-ranges" before calling ->add_pin_ranges()
The ->add_pin_ranges() is supposed to be called for the backward compatiblity on Device Tree platforms or non-DT ones. Ensure that by checking presense of the "gpio-ranges" property. This allows to clean up a few existing drivers to avoid duplication of the check. Signed-off-by: Andy Shevchenko <[email protected]> Tested-by: Stefan Wahren <[email protected]> Tested-by: Florian Fainelli <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Acked-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 6eea5a8 commit c40aa80

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/gpio/gpiolib.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,14 @@ static void gpiochip_free_valid_mask(struct gpio_chip *gc)
531531

532532
static int gpiochip_add_pin_ranges(struct gpio_chip *gc)
533533
{
534+
/*
535+
* Device Tree platforms are supposed to use "gpio-ranges"
536+
* property. This check ensures that the ->add_pin_ranges()
537+
* won't be called for them.
538+
*/
539+
if (device_property_present(&gc->gpiodev->dev, "gpio-ranges"))
540+
return 0;
541+
534542
if (gc->add_pin_ranges)
535543
return gc->add_pin_ranges(gc);
536544

0 commit comments

Comments
 (0)