summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorTimur Tabi <timur@codeaurora.org>2017-07-27 13:19:23 -0500
committerLinus Walleij <linus.walleij@linaro.org>2017-08-14 15:01:12 +0200
commit108d23e322a247d9f89ba2e2742520ead0944cc9 (patch)
treeb11bd287e24c911d7e1b048de232a02431c43259 /drivers/gpio
parentb2dc4110cbf83be72e8bdf75bcf88831bf7dd0fe (diff)
downloadblackbird-op-linux-108d23e322a247d9f89ba2e2742520ead0944cc9.tar.gz
blackbird-op-linux-108d23e322a247d9f89ba2e2742520ead0944cc9.zip
gpiolib: request the gpio before querying its direction
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> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index cd003b74512f..bd90737dce77 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1201,6 +1201,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
@@ -1226,6 +1234,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
OpenPOWER on IntegriCloud