When using the irqchip helper inside the gpiolib, make sure the IRQs are unmapped/disposed before the irqdomain is removed as part of removing the gpiochip.
···13991399 return 0;14001400}1401140114021402+static void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq)14031403+{14041404+#ifdef CONFIG_ARM14051405+ set_irq_flags(irq, 0);14061406+#endif14071407+ irq_set_chip_and_handler(irq, NULL, NULL);14081408+ irq_set_chip_data(irq, NULL);14091409+}14101410+14021411static const struct irq_domain_ops gpiochip_domain_ops = {14031412 .map = gpiochip_irq_map,14131413+ .unmap = gpiochip_irq_unmap,14041414 /* Virtually all GPIO irqchips are twocell:ed */14051415 .xlate = irq_domain_xlate_twocell,14061416};···14481438 */14491439static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)14501440{14511451- if (gpiochip->irqdomain)14411441+ unsigned int offset;14421442+14431443+ /* Remove all IRQ mappings and delete the domain */14441444+ if (gpiochip->irqdomain) {14451445+ for (offset = 0; offset < gpiochip->ngpio; offset++)14461446+ irq_dispose_mapping(gpiochip->irq_base + offset);14521447 irq_domain_remove(gpiochip->irqdomain);14481448+ }1453144914541450 if (gpiochip->irqchip) {14551451 gpiochip->irqchip->irq_request_resources = NULL;···14831467 * translation. The gpiochip will need to be initialized and registered14841468 * before calling this function.14851469 *14861486- * This function will handle two cell:ed simple IRQs. Everything else14701470+ * This function will handle two cell:ed simple IRQs and assumes all14711471+ * the pins on the gpiochip can generate a unique IRQ. Everything else14871472 * need to be open coded.14881473 */14891474int gpiochip_irqchip_add(struct gpio_chip *gpiochip,···14951478{14961479 struct device_node *of_node;14971480 unsigned int offset;14811481+ unsigned irq_base = 0;1498148214991483 if (!gpiochip || !irqchip)15001484 return -EINVAL;···15321514 * any gpiochip calls. If the first_irq was zero, this is15331515 * necessary to allocate descriptors for all IRQs.15341516 */15351535- for (offset = 0; offset < gpiochip->ngpio; offset++)15361536- irq_create_mapping(gpiochip->irqdomain, offset);15171517+ for (offset = 0; offset < gpiochip->ngpio; offset++) {15181518+ irq_base = irq_create_mapping(gpiochip->irqdomain, offset);15191519+ if (offset == 0)15201520+ /*15211521+ * Store the base into the gpiochip to be used when15221522+ * unmapping the irqs.15231523+ */15241524+ gpiochip->irq_base = irq_base;15251525+ }1537152615381527 return 0;15391528}
+1
include/linux/gpio/driver.h
···107107 */108108 struct irq_chip *irqchip;109109 struct irq_domain *irqdomain;110110+ unsigned int irq_base;110111 irq_flow_handler_t irq_handler;111112 unsigned int irq_default_type;112113#endif