]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/gpio/gpiolib-acpi.c
Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / drivers / gpio / gpiolib-acpi.c
index 143a9bdbaa53e1ba056a02549e521ccd6efc2220..bbcac3af2a7ab84804fa862fe6a31869ca35aca3 100644 (file)
@@ -304,7 +304,6 @@ void acpi_gpiochip_request_interrupts(struct gpio_chip *chip)
        if (ACPI_FAILURE(status))
                return;
 
-       INIT_LIST_HEAD(&acpi_gpio->events);
        acpi_walk_resources(handle, "_AEI",
                            acpi_gpiochip_request_interrupt, acpi_gpio);
 }
@@ -603,6 +602,25 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
                                break;
                        }
                }
+
+               /*
+                * The same GPIO can be shared between operation region and
+                * event but only if the access here is ACPI_READ. In that
+                * case we "borrow" the event GPIO instead.
+                */
+               if (!found && agpio->sharable == ACPI_SHARED &&
+                    function == ACPI_READ) {
+                       struct acpi_gpio_event *event;
+
+                       list_for_each_entry(event, &achip->events, node) {
+                               if (event->pin == pin) {
+                                       desc = event->desc;
+                                       found = true;
+                                       break;
+                               }
+                       }
+               }
+
                if (!found) {
                        desc = gpiochip_request_own_desc(chip, pin,
                                                         "ACPI:OpRegion");
@@ -719,6 +737,7 @@ void acpi_gpiochip_add(struct gpio_chip *chip)
        }
 
        acpi_gpio->chip = chip;
+       INIT_LIST_HEAD(&acpi_gpio->events);
 
        status = acpi_attach_data(handle, acpi_gpio_chip_dh, acpi_gpio);
        if (ACPI_FAILURE(status)) {