diff options
-rw-r--r-- | drivers/gpio/gpiolib-acpi.c | 38 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 4 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.h | 9 |
3 files changed, 41 insertions, 10 deletions
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index d2e8600df02c..d62eaaa75397 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -221,7 +221,7 @@ fail_free_desc: | |||
221 | 221 | ||
222 | /** | 222 | /** |
223 | * acpi_gpiochip_request_interrupts() - Register isr for gpio chip ACPI events | 223 | * acpi_gpiochip_request_interrupts() - Register isr for gpio chip ACPI events |
224 | * @acpi_gpio: ACPI GPIO chip | 224 | * @chip: GPIO chip |
225 | * | 225 | * |
226 | * ACPI5 platforms can use GPIO signaled ACPI events. These GPIO interrupts are | 226 | * ACPI5 platforms can use GPIO signaled ACPI events. These GPIO interrupts are |
227 | * handled by ACPI event methods which need to be called from the GPIO | 227 | * handled by ACPI event methods which need to be called from the GPIO |
@@ -229,11 +229,21 @@ fail_free_desc: | |||
229 | * gpio pins have acpi event methods and assigns interrupt handlers that calls | 229 | * gpio pins have acpi event methods and assigns interrupt handlers that calls |
230 | * the acpi event methods for those pins. | 230 | * the acpi event methods for those pins. |
231 | */ | 231 | */ |
232 | static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *acpi_gpio) | 232 | void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) |
233 | { | 233 | { |
234 | struct gpio_chip *chip = acpi_gpio->chip; | 234 | struct acpi_gpio_chip *acpi_gpio; |
235 | acpi_handle handle; | ||
236 | acpi_status status; | ||
237 | |||
238 | if (!chip->dev || !chip->to_irq) | ||
239 | return; | ||
235 | 240 | ||
236 | if (!chip->to_irq) | 241 | handle = ACPI_HANDLE(chip->dev); |
242 | if (!handle) | ||
243 | return; | ||
244 | |||
245 | status = acpi_get_data(handle, acpi_gpio_chip_dh, (void **)&acpi_gpio); | ||
246 | if (ACPI_FAILURE(status)) | ||
237 | return; | 247 | return; |
238 | 248 | ||
239 | INIT_LIST_HEAD(&acpi_gpio->events); | 249 | INIT_LIST_HEAD(&acpi_gpio->events); |
@@ -243,17 +253,27 @@ static void acpi_gpiochip_request_interrupts(struct acpi_gpio_chip *acpi_gpio) | |||
243 | 253 | ||
244 | /** | 254 | /** |
245 | * acpi_gpiochip_free_interrupts() - Free GPIO ACPI event interrupts. | 255 | * acpi_gpiochip_free_interrupts() - Free GPIO ACPI event interrupts. |
246 | * @acpi_gpio: ACPI GPIO chip | 256 | * @chip: GPIO chip |
247 | * | 257 | * |
248 | * Free interrupts associated with GPIO ACPI event method for the given | 258 | * Free interrupts associated with GPIO ACPI event method for the given |
249 | * GPIO chip. | 259 | * GPIO chip. |
250 | */ | 260 | */ |
251 | static void acpi_gpiochip_free_interrupts(struct acpi_gpio_chip *acpi_gpio) | 261 | void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) |
252 | { | 262 | { |
263 | struct acpi_gpio_chip *acpi_gpio; | ||
253 | struct acpi_gpio_event *event, *ep; | 264 | struct acpi_gpio_event *event, *ep; |
254 | struct gpio_chip *chip = acpi_gpio->chip; | 265 | acpi_handle handle; |
266 | acpi_status status; | ||
267 | |||
268 | if (!chip->dev || !chip->to_irq) | ||
269 | return; | ||
255 | 270 | ||
256 | if (!chip->to_irq) | 271 | handle = ACPI_HANDLE(chip->dev); |
272 | if (!handle) | ||
273 | return; | ||
274 | |||
275 | status = acpi_get_data(handle, acpi_gpio_chip_dh, (void **)&acpi_gpio); | ||
276 | if (ACPI_FAILURE(status)) | ||
257 | return; | 277 | return; |
258 | 278 | ||
259 | list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { | 279 | list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) { |
@@ -525,7 +545,6 @@ void acpi_gpiochip_add(struct gpio_chip *chip) | |||
525 | return; | 545 | return; |
526 | } | 546 | } |
527 | 547 | ||
528 | acpi_gpiochip_request_interrupts(acpi_gpio); | ||
529 | acpi_gpiochip_request_regions(acpi_gpio); | 548 | acpi_gpiochip_request_regions(acpi_gpio); |
530 | } | 549 | } |
531 | 550 | ||
@@ -549,7 +568,6 @@ void acpi_gpiochip_remove(struct gpio_chip *chip) | |||
549 | } | 568 | } |
550 | 569 | ||
551 | acpi_gpiochip_free_regions(acpi_gpio); | 570 | acpi_gpiochip_free_regions(acpi_gpio); |
552 | acpi_gpiochip_free_interrupts(acpi_gpio); | ||
553 | 571 | ||
554 | acpi_detach_data(handle, acpi_gpio_chip_dh); | 572 | acpi_detach_data(handle, acpi_gpio_chip_dh); |
555 | kfree(acpi_gpio); | 573 | kfree(acpi_gpio); |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 18b069e6ba03..330227581a25 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -519,6 +519,8 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) | |||
519 | { | 519 | { |
520 | unsigned int offset; | 520 | unsigned int offset; |
521 | 521 | ||
522 | acpi_gpiochip_free_interrupts(gpiochip); | ||
523 | |||
522 | /* Remove all IRQ mappings and delete the domain */ | 524 | /* Remove all IRQ mappings and delete the domain */ |
523 | if (gpiochip->irqdomain) { | 525 | if (gpiochip->irqdomain) { |
524 | for (offset = 0; offset < gpiochip->ngpio; offset++) | 526 | for (offset = 0; offset < gpiochip->ngpio; offset++) |
@@ -612,6 +614,8 @@ int gpiochip_irqchip_add(struct gpio_chip *gpiochip, | |||
612 | gpiochip->irq_base = irq_base; | 614 | gpiochip->irq_base = irq_base; |
613 | } | 615 | } |
614 | 616 | ||
617 | acpi_gpiochip_request_interrupts(gpiochip); | ||
618 | |||
615 | return 0; | 619 | return 0; |
616 | } | 620 | } |
617 | EXPORT_SYMBOL_GPL(gpiochip_irqchip_add); | 621 | EXPORT_SYMBOL_GPL(gpiochip_irqchip_add); |
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 7fcb645ded4c..9db2b6a71c5d 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h | |||
@@ -31,12 +31,21 @@ struct acpi_gpio_info { | |||
31 | void acpi_gpiochip_add(struct gpio_chip *chip); | 31 | void acpi_gpiochip_add(struct gpio_chip *chip); |
32 | void acpi_gpiochip_remove(struct gpio_chip *chip); | 32 | void acpi_gpiochip_remove(struct gpio_chip *chip); |
33 | 33 | ||
34 | void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); | ||
35 | void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); | ||
36 | |||
34 | struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index, | 37 | struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index, |
35 | struct acpi_gpio_info *info); | 38 | struct acpi_gpio_info *info); |
36 | #else | 39 | #else |
37 | static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } | 40 | static inline void acpi_gpiochip_add(struct gpio_chip *chip) { } |
38 | static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } | 41 | static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { } |
39 | 42 | ||
43 | static inline void | ||
44 | acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } | ||
45 | |||
46 | static inline void | ||
47 | acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } | ||
48 | |||
40 | static inline struct gpio_desc * | 49 | static inline struct gpio_desc * |
41 | acpi_get_gpiod_by_index(struct device *dev, int index, | 50 | acpi_get_gpiod_by_index(struct device *dev, int index, |
42 | struct acpi_gpio_info *info) | 51 | struct acpi_gpio_info *info) |