aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2013-11-23 05:34:50 -0500
committerLinus Walleij <linus.walleij@linaro.org>2013-12-03 07:10:48 -0500
commit35c5d7fdc4eed4409f9193bf7651315849cc6aa3 (patch)
tree66c2782a2c9dd545d8ec1d094d3c3bb00dd1c267 /drivers/gpio/gpiolib.c
parent56a39aac593a7e855bed357b1ce43eeb7a99e7e2 (diff)
gpiolib: use platform GPIO mappings as fallback
For platforms that use device tree or ACPI as the standard way to look GPIOs up, allow the platform-defined GPIO mappings to be used as a fallback. This may be useful for platforms that need extra GPIOs mappings not defined by the firmware. Signed-off-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b73c39f99858..dbddace5df42 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2418,7 +2418,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2418 const char *con_id, 2418 const char *con_id,
2419 unsigned int idx) 2419 unsigned int idx)
2420{ 2420{
2421 struct gpio_desc *desc; 2421 struct gpio_desc *desc = NULL;
2422 int status; 2422 int status;
2423 enum gpio_lookup_flags flags = 0; 2423 enum gpio_lookup_flags flags = 0;
2424 2424
@@ -2431,9 +2431,19 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
2431 } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) { 2431 } else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) {
2432 dev_dbg(dev, "using ACPI for GPIO lookup\n"); 2432 dev_dbg(dev, "using ACPI for GPIO lookup\n");
2433 desc = acpi_find_gpio(dev, con_id, idx, &flags); 2433 desc = acpi_find_gpio(dev, con_id, idx, &flags);
2434 } else { 2434 }
2435
2436 /*
2437 * Either we are not using DT or ACPI, or their lookup did not return
2438 * a result. In that case, use platform lookup as a fallback.
2439 */
2440 if (!desc || IS_ERR(desc)) {
2441 struct gpio_desc *pdesc;
2435 dev_dbg(dev, "using lookup tables for GPIO lookup"); 2442 dev_dbg(dev, "using lookup tables for GPIO lookup");
2436 desc = gpiod_find(dev, con_id, idx, &flags); 2443 pdesc = gpiod_find(dev, con_id, idx, &flags);
2444 /* If used as fallback, do not replace the previous error */
2445 if (!IS_ERR(pdesc) || !desc)
2446 desc = pdesc;
2437 } 2447 }
2438 2448
2439 if (IS_ERR(desc)) { 2449 if (IS_ERR(desc)) {