Skip to content

Commit

Permalink
gpiolib: use platform GPIO mappings as fallback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexandre Courbot authored and Linus Walleij committed Dec 3, 2013
1 parent 56a39aa commit 35c5d7f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
const char *con_id,
unsigned int idx)
{
struct gpio_desc *desc;
struct gpio_desc *desc = NULL;
int status;
enum gpio_lookup_flags flags = 0;

Expand All @@ -2431,9 +2431,19 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
} else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) {
dev_dbg(dev, "using ACPI for GPIO lookup\n");
desc = acpi_find_gpio(dev, con_id, idx, &flags);
} else {
}

/*
* Either we are not using DT or ACPI, or their lookup did not return
* a result. In that case, use platform lookup as a fallback.
*/
if (!desc || IS_ERR(desc)) {
struct gpio_desc *pdesc;
dev_dbg(dev, "using lookup tables for GPIO lookup");
desc = gpiod_find(dev, con_id, idx, &flags);
pdesc = gpiod_find(dev, con_id, idx, &flags);
/* If used as fallback, do not replace the previous error */
if (!IS_ERR(pdesc) || !desc)
desc = pdesc;
}

if (IS_ERR(desc)) {
Expand Down

0 comments on commit 35c5d7f

Please sign in to comment.