diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2023-01-13 23:53:49 +0200 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2023-01-26 13:38:55 +0100 |
commit | c40aa80dd4569848ac89454321fa035a6ca26976 (patch) | |
tree | 31bd37a9e4e9966afe8393cfc35abbf3b951090f /drivers/gpio/gpiolib.c | |
parent | 6eea5a80d2ae9bc1df5664bcf7851306df96e9dc (diff) | |
download | lwn-c40aa80dd4569848ac89454321fa035a6ca26976.tar.gz lwn-c40aa80dd4569848ac89454321fa035a6ca26976.zip |
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 <andriy.shevchenko@linux.intel.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20230113215352.44272-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5a66d9616d7c..8a8551af8063 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -531,6 +531,14 @@ static void gpiochip_free_valid_mask(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) return gc->add_pin_ranges(gc); |