diff mbox

gpiolib: cleanup chained handler and data

Message ID 1431450743-25528-1-git-send-email-dbaryshkov@gmail.com
State New
Headers show

Commit Message

Dmitry Baryshkov May 12, 2015, 5:12 p.m. UTC
Clean up chained handler and handler data if they were set by
gpiochip_set_chained_irqchip().

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/gpio/gpiolib.c      | 7 +++++++
 include/linux/gpio/driver.h | 1 +
 2 files changed, 8 insertions(+)

Comments

Linus Walleij May 13, 2015, 11:05 a.m. UTC | #1
On Tue, May 12, 2015 at 7:12 PM, Dmitry Eremin-Solenikov
<dbaryshkov@gmail.com> wrote:

> Clean up chained handler and handler data if they were set by
> gpiochip_set_chained_irqchip().
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

Yep exactly like this :)

Patch applied!

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 59eaa23..0f40a7f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -439,6 +439,8 @@  void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip,
 		 */
 		irq_set_handler_data(parent_irq, gpiochip);
 		irq_set_chained_handler(parent_irq, parent_handler);
+
+		gpiochip->irq_parent = parent_irq;
 	}
 
 	/* Set the parent IRQ for all affected IRQs */
@@ -547,6 +549,11 @@  static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
 
 	acpi_gpiochip_free_interrupts(gpiochip);
 
+	if (gpiochip->irq_parent) {
+		irq_set_chained_handler(gpiochip->irq_parent, NULL);
+		irq_set_handler_data(gpiochip->irq_parent, NULL);
+	}
+
 	/* Remove all IRQ mappings and delete the domain */
 	if (gpiochip->irqdomain) {
 		for (offset = 0; offset < gpiochip->ngpio; offset++)
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index f1b3659..d656577 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -121,6 +121,7 @@  struct gpio_chip {
 	unsigned int		irq_base;
 	irq_flow_handler_t	irq_handler;
 	unsigned int		irq_default_type;
+	int			irq_parent;
 #endif
 
 #if defined(CONFIG_OF_GPIO)