@@ -1202,6 +1202,14 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
struct gpio_desc *desc = &gdev->descs[i];
desc->gdev = gdev;
+
+ if (chip->request) {
+ status = chip->request(chip, i);
+ if (status < 0)
+ /* The GPIO is unavailable, so skip it */
+ continue;
+ }
+
/*
* REVISIT: most hardware initializes GPIOs as inputs
* (often with pullups enabled) so power usage is
@@ -1227,6 +1235,9 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
*/
set_bit(FLAG_IS_OUT, &desc->flags);
}
+
+ if (chip->free)
+ chip->free(chip, i);
}
#ifdef CONFIG_PINCTRL
Before querying a GPIO to determine its direction, the GPIO should be formally requested. This allows the GPIO driver to block access to unavailable GPIOs, which makes it easier for some drivers to support sparse GPIO maps. Signed-off-by: Timur Tabi <timur@codeaurora.org> --- drivers/gpio/gpiolib.c | 11 +++++++++++ 1 file changed, 11 insertions(+)