Commit c40aa80d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Walleij

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Acked-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20230113215352.44272-2-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 6eea5a80
...@@ -531,6 +531,14 @@ static void gpiochip_free_valid_mask(struct gpio_chip *gc) ...@@ -531,6 +531,14 @@ static void gpiochip_free_valid_mask(struct gpio_chip *gc)
static int gpiochip_add_pin_ranges(struct gpio_chip *gc) static int gpiochip_add_pin_ranges(struct gpio_chip *gc)
{ {
/*
* Device Tree platforms are supposed to use "gpio-ranges"
* property. This check ensures that the ->add_pin_ranges()
* won't be called for them.
*/
if (device_property_present(&gc->gpiodev->dev, "gpio-ranges"))
return 0;
if (gc->add_pin_ranges) if (gc->add_pin_ranges)
return gc->add_pin_ranges(gc); return gc->add_pin_ranges(gc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment