diff options
author | Alexandre Courbot <acourbot@nvidia.com> | 2014-08-19 13:06:08 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-08-29 02:58:28 -0400 |
commit | e46cf32ced90d00972d5c3d9322cdb848d183338 (patch) | |
tree | 3fe5b06cd1e7f0bb2facb47b2fbcff0b71136d8e /drivers/gpio/gpiolib-acpi.c | |
parent | 5a2533a7478334593c50284fd414c70b3b9217c0 (diff) |
gpio: acpi: normalize use of gpiochip_get_desc()
GPIO descriptors are changing from unique and permanent tokens to
allocated resources. Therefore gpiochip_get_desc() cannot be used as a
way to obtain a global GPIO descriptor anymore.
This patch updates the gpiolib ACPI support code to keep and use the
descriptor returned by a centralized call to gpiochip_get_desc().
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib-acpi.c')
-rw-r--r-- | drivers/gpio/gpiolib-acpi.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index d62eaaa75397..84540025aa08 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -25,10 +25,12 @@ struct acpi_gpio_event { | |||
25 | acpi_handle handle; | 25 | acpi_handle handle; |
26 | unsigned int pin; | 26 | unsigned int pin; |
27 | unsigned int irq; | 27 | unsigned int irq; |
28 | struct gpio_desc *desc; | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | struct acpi_gpio_connection { | 31 | struct acpi_gpio_connection { |
31 | struct list_head node; | 32 | struct list_head node; |
33 | unsigned int pin; | ||
32 | struct gpio_desc *desc; | 34 | struct gpio_desc *desc; |
33 | }; | 35 | }; |
34 | 36 | ||
@@ -197,6 +199,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, | |||
197 | event->handle = evt_handle; | 199 | event->handle = evt_handle; |
198 | event->irq = irq; | 200 | event->irq = irq; |
199 | event->pin = pin; | 201 | event->pin = pin; |
202 | event->desc = desc; | ||
200 | 203 | ||
201 | ret = request_threaded_irq(event->irq, NULL, handler, irqflags, | 204 | ret = request_threaded_irq(event->irq, NULL, handler, irqflags, |
202 | "ACPI:Event", event); | 205 | "ACPI:Event", event); |
@@ -280,7 +283,7 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) | |||
280 | struct gpio_desc *desc; | 283 | struct gpio_desc *desc; |
281 | 284 | ||
282 | free_irq(event->irq, event); | 285 | free_irq(event->irq, event); |
283 | desc = gpiochip_get_desc(chip, event->pin); | 286 | desc = event->desc; |
284 | if (WARN_ON(IS_ERR(desc))) | 287 | if (WARN_ON(IS_ERR(desc))) |
285 | continue; | 288 | continue; |
286 | gpio_unlock_as_irq(chip, event->pin); | 289 | gpio_unlock_as_irq(chip, event->pin); |
@@ -406,24 +409,26 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, | |||
406 | struct gpio_desc *desc; | 409 | struct gpio_desc *desc; |
407 | bool found; | 410 | bool found; |
408 | 411 | ||
409 | desc = gpiochip_get_desc(chip, pin); | ||
410 | if (IS_ERR(desc)) { | ||
411 | status = AE_ERROR; | ||
412 | goto out; | ||
413 | } | ||
414 | |||
415 | mutex_lock(&achip->conn_lock); | 412 | mutex_lock(&achip->conn_lock); |
416 | 413 | ||
417 | found = false; | 414 | found = false; |
418 | list_for_each_entry(conn, &achip->conns, node) { | 415 | list_for_each_entry(conn, &achip->conns, node) { |
419 | if (conn->desc == desc) { | 416 | if (conn->pin == pin) { |
420 | found = true; | 417 | found = true; |
418 | desc = conn->desc; | ||
421 | break; | 419 | break; |
422 | } | 420 | } |
423 | } | 421 | } |
424 | if (!found) { | 422 | if (!found) { |
425 | int ret; | 423 | int ret; |
426 | 424 | ||
425 | desc = gpiochip_get_desc(chip, pin); | ||
426 | if (IS_ERR(desc)) { | ||
427 | status = AE_ERROR; | ||
428 | mutex_unlock(&achip->conn_lock); | ||
429 | goto out; | ||
430 | } | ||
431 | |||
427 | ret = gpiochip_request_own_desc(desc, "ACPI:OpRegion"); | 432 | ret = gpiochip_request_own_desc(desc, "ACPI:OpRegion"); |
428 | if (ret) { | 433 | if (ret) { |
429 | status = AE_ERROR; | 434 | status = AE_ERROR; |
@@ -462,6 +467,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, | |||
462 | goto out; | 467 | goto out; |
463 | } | 468 | } |
464 | 469 | ||
470 | conn->pin = pin; | ||
465 | conn->desc = desc; | 471 | conn->desc = desc; |
466 | list_add_tail(&conn->node, &achip->conns); | 472 | list_add_tail(&conn->node, &achip->conns); |
467 | } | 473 | } |