Merge tag 'gpio-v4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux...
[deliverable/linux.git] / drivers / gpio / gpiolib-acpi.c
index 07e571a1a3775f27aa421667b6dfcb101e44f6ad..540cbc88c7a202f8264c9caa1317953ba11b1c3d 100644 (file)
@@ -418,10 +418,15 @@ static int acpi_find_gpio(struct acpi_resource *ares, void *data)
                 * ActiveLow is only specified for GpioInt resource. If
                 * GpioIo is used then the only way to set the flag is
                 * to use _DSD "gpios" property.
+                * Note: we expect here:
+                * - ACPI_ACTIVE_LOW == GPIO_ACTIVE_LOW
+                * - ACPI_ACTIVE_HIGH == GPIO_ACTIVE_HIGH
                 */
-               if (lookup->info.gpioint)
-                       lookup->info.active_low =
-                               agpio->polarity == ACPI_ACTIVE_LOW;
+               if (lookup->info.gpioint) {
+                       lookup->info.polarity = agpio->polarity;
+                       lookup->info.triggering = agpio->triggering;
+               }
+
        }
 
        return 1;
@@ -448,7 +453,7 @@ static int acpi_gpio_resource_lookup(struct acpi_gpio_lookup *lookup,
        if (info) {
                *info = lookup->info;
                if (lookup->active_low)
-                       info->active_low = lookup->active_low;
+                       info->polarity = lookup->active_low;
        }
        return 0;
 }
@@ -596,6 +601,7 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
 int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
 {
        int idx, i;
+       unsigned int irq_flags;
 
        for (i = 0, idx = 0; idx <= index; i++) {
                struct acpi_gpio_info info;
@@ -604,8 +610,23 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
                desc = acpi_get_gpiod_by_index(adev, NULL, i, &info);
                if (IS_ERR(desc))
                        break;
-               if (info.gpioint && idx++ == index)
-                       return gpiod_to_irq(desc);
+               if (info.gpioint && idx++ == index) {
+                       int irq = gpiod_to_irq(desc);
+
+                       if (irq < 0)
+                               return irq;
+
+                       irq_flags = acpi_dev_get_irq_type(info.triggering,
+                                                         info.polarity);
+
+                       /* Set type if specified and different than the current one */
+                       if (irq_flags != IRQ_TYPE_NONE &&
+                           irq_flags != irq_get_trigger_type(irq))
+                               irq_set_irq_type(irq, irq_flags);
+
+                       return irq;
+               }
+
        }
        return -ENOENT;
 }
This page took 0.030727 seconds and 5 git commands to generate.