]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
gpio / ACPI: Use pin index and bit length
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tue, 23 Sep 2014 02:35:54 +0000 (10:35 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 24 Sep 2014 20:58:09 +0000 (22:58 +0200)
Fix code when the operation region callback is for an gpio, which
is not at index 0 and for partial pins in a GPIO definition.
For example:
Name (GMOD, ResourceTemplate ()
{
//3 Outputs that define the Power mode of the device
GpioIo (Exclusive, PullDown, , , , "\\_SB.GPI2") {10, 11, 12}
})
}

If opregion callback calls is for:
- Set pin 10, then address = 0 and bit length = 1
- Set pin 11, then address = 1 and bit length = 1
- Set for both pin 11 and pin 12, then address = 1, bit length = 2

This change requires updated ACPICA gpio operation handler code to
send the pin index and bit length.

Fixes: 473ed7be0da0 (gpio / ACPI: Add support for ACPI GPIO operation regions)
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: 3.15+ <stable@vger.kernel.org> # 3.15+: 75ec6e55f138 ACPICA: Update to GPIO region handler interface.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/gpio/gpiolib-acpi.c

index d62eaaa753978598e4eb119f86179af857aaf0a7..687476fb39e311b0d09ac0a5b20458fb94e2c605 100644 (file)
@@ -377,8 +377,10 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
        struct gpio_chip *chip = achip->chip;
        struct acpi_resource_gpio *agpio;
        struct acpi_resource *ares;
+       int pin_index = (int)address;
        acpi_status status;
        bool pull_up;
+       int length;
        int i;
 
        status = acpi_buffer_to_resource(achip->conn_info.connection,
@@ -400,7 +402,8 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
                return AE_BAD_PARAMETER;
        }
 
-       for (i = 0; i < agpio->pin_table_length; i++) {
+       length = min(agpio->pin_table_length, (u16)(pin_index + bits));
+       for (i = pin_index; i < length; ++i) {
                unsigned pin = agpio->pin_table[i];
                struct acpi_gpio_connection *conn;
                struct gpio_desc *desc;