gpio: acpi: Ignore -EPROBE_DEFER for unselected gpioints
authorHans de Goede <hdegoede@redhat.com>
Mon, 13 Mar 2017 22:04:21 +0000 (23:04 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 16 Mar 2017 20:52:13 +0000 (21:52 +0100)
When acpi_dev_gpio_irq_get gets called with an index of say 2, it should
not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER.

This allows drivers which request a gpioint with index > 0 to function
if there is no gpiochip driver (loaded) for gpioints with a lower index.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib-acpi.c

index a5b84d40e60c20db45da5489c30cee1f6cb8189c..56a6b1be3a17e9695685c178a2c1a98e02b6fdb0 100644 (file)
@@ -684,20 +684,24 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 {
        int idx, i;
        unsigned int irq_flags;
-       int ret = -ENOENT;
 
        for (i = 0, idx = 0; idx <= index; i++) {
                struct acpi_gpio_info info;
                struct gpio_desc *desc;
 
                desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
-               if (IS_ERR(desc)) {
-                       ret = PTR_ERR(desc);
-                       break;
-               }
+
+               /* Ignore -EPROBE_DEFER, it only matters if idx matches */
+               if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER)
+                       return PTR_ERR(desc);
+
                if (info.gpioint && idx++ == index) {
-                       int irq = gpiod_to_irq(desc);
+                       int irq;
+
+                       if (IS_ERR(desc))
+                               return PTR_ERR(desc);
 
+                       irq = gpiod_to_irq(desc);
                        if (irq < 0)
                                return irq;
 
@@ -713,7 +717,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
                }
 
        }
-       return ret;
+       return -ENOENT;
 }
 EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get);