diff options
author | Thierry Reding <treding@nvidia.com> | 2017-11-07 13:15:50 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-11-08 08:08:46 -0500 |
commit | 39e5f0969514fbfd6c235ac52586c72ca77cee00 (patch) | |
tree | 4b9fdd0fb1eccb99798694a1b300173ace1d308c | |
parent | 3634eeb0fe9176e453c99834749dce21ea1305c1 (diff) |
gpio: Move irq_chained_parent to struct gpio_irq_chip
In order to consolidate the multiple ways to associate an IRQ chip with
a GPIO chip, move more fields into the new struct gpio_irq_chip.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpiolib.c | 17 | ||||
-rw-r--r-- | include/linux/gpio/driver.h | 19 |
2 files changed, 27 insertions, 9 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index d3608cf511de..8eadae73ff20 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1570,7 +1570,8 @@ static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, | |||
1570 | irq_set_chained_handler_and_data(parent_irq, parent_handler, | 1570 | irq_set_chained_handler_and_data(parent_irq, parent_handler, |
1571 | gpiochip); | 1571 | gpiochip); |
1572 | 1572 | ||
1573 | gpiochip->irq_chained_parent = parent_irq; | 1573 | gpiochip->irq.parents = &parent_irq; |
1574 | gpiochip->irq.num_parents = 1; | ||
1574 | } | 1575 | } |
1575 | 1576 | ||
1576 | /* Set the parent IRQ for all affected IRQs */ | 1577 | /* Set the parent IRQ for all affected IRQs */ |
@@ -1719,17 +1720,23 @@ static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) | |||
1719 | */ | 1720 | */ |
1720 | static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) | 1721 | static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) |
1721 | { | 1722 | { |
1722 | unsigned int offset, irq; | 1723 | unsigned int offset; |
1723 | 1724 | ||
1724 | acpi_gpiochip_free_interrupts(gpiochip); | 1725 | acpi_gpiochip_free_interrupts(gpiochip); |
1725 | 1726 | ||
1726 | if (gpiochip->irq_chained_parent) { | 1727 | if (gpiochip->irq.num_parents > 0) { |
1727 | irq_set_chained_handler_and_data( | 1728 | struct gpio_irq_chip *irq = &gpiochip->irq; |
1728 | gpiochip->irq_chained_parent, NULL, NULL); | 1729 | unsigned int i; |
1730 | |||
1731 | for (i = 0; i < irq->num_parents; i++) | ||
1732 | irq_set_chained_handler_and_data(irq->parents[i], | ||
1733 | NULL, NULL); | ||
1729 | } | 1734 | } |
1730 | 1735 | ||
1731 | /* Remove all IRQ mappings and delete the domain */ | 1736 | /* Remove all IRQ mappings and delete the domain */ |
1732 | if (gpiochip->irq.domain) { | 1737 | if (gpiochip->irq.domain) { |
1738 | unsigned int irq; | ||
1739 | |||
1733 | for (offset = 0; offset < gpiochip->ngpio; offset++) { | 1740 | for (offset = 0; offset < gpiochip->ngpio; offset++) { |
1734 | if (!gpiochip_irqchip_irq_valid(gpiochip, offset)) | 1741 | if (!gpiochip_irqchip_irq_valid(gpiochip, offset)) |
1735 | continue; | 1742 | continue; |
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 1367fa94105f..86f00d908e90 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h | |||
@@ -77,6 +77,21 @@ struct gpio_irq_chip { | |||
77 | * interrupt. | 77 | * interrupt. |
78 | */ | 78 | */ |
79 | void *parent_handler_data; | 79 | void *parent_handler_data; |
80 | |||
81 | /** | ||
82 | * @num_parents: | ||
83 | * | ||
84 | * The number of interrupt parents of a GPIO chip. | ||
85 | */ | ||
86 | unsigned int num_parents; | ||
87 | |||
88 | /** | ||
89 | * @parents: | ||
90 | * | ||
91 | * A list of interrupt parents of a GPIO chip. This is owned by the | ||
92 | * driver, so the core will only reference this list, not modify it. | ||
93 | */ | ||
94 | unsigned int *parents; | ||
80 | }; | 95 | }; |
81 | 96 | ||
82 | static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) | 97 | static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) |
@@ -148,9 +163,6 @@ static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip) | |||
148 | * safely. | 163 | * safely. |
149 | * @bgpio_dir: shadowed direction register for generic GPIO to clear/set | 164 | * @bgpio_dir: shadowed direction register for generic GPIO to clear/set |
150 | * direction safely. | 165 | * direction safely. |
151 | * @irq_chained_parent: GPIO IRQ chip parent/bank linux irq number, | ||
152 | * provided by GPIO driver for chained interrupt (not for nested | ||
153 | * interrupts). | ||
154 | * @irq_nested: True if set the interrupt handling is nested. | 166 | * @irq_nested: True if set the interrupt handling is nested. |
155 | * @irq_need_valid_mask: If set core allocates @irq_valid_mask with all | 167 | * @irq_need_valid_mask: If set core allocates @irq_valid_mask with all |
156 | * bits set to one | 168 | * bits set to one |
@@ -226,7 +238,6 @@ struct gpio_chip { | |||
226 | * With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib | 238 | * With CONFIG_GPIOLIB_IRQCHIP we get an irqchip inside the gpiolib |
227 | * to handle IRQs for most practical cases. | 239 | * to handle IRQs for most practical cases. |
228 | */ | 240 | */ |
229 | unsigned int irq_chained_parent; | ||
230 | bool irq_nested; | 241 | bool irq_nested; |
231 | bool irq_need_valid_mask; | 242 | bool irq_need_valid_mask; |
232 | unsigned long *irq_valid_mask; | 243 | unsigned long *irq_valid_mask; |