[PATCH v14 03/14] gpio: regmap: remove gpiochip before tearing down irqchip

From: Long Zhao via B4 Relay

Date: Mon Nov 09 2026 - 23:41:21 EST


From: Long Zhao <longzhao@xxxxxxxxxxxxx>

gpiochip_remove() calls acpi_gpiochip_free_interrupts() and
gpiod_free_irqs(). Both still need the irq domain.
regmap_del_irq_chip() removes that domain, so remove the
gpiochip first.

Fixes: 553b75d4bfe9 ("gpio: regmap: Allow to allocate regmap-irq device")
Signed-off-by: Long Zhao <longzhao@xxxxxxxxxxxxx>
---
drivers/gpio/gpio-regmap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 0a44deae3d01..1bfdb00dad95 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -445,12 +445,19 @@ EXPORT_SYMBOL_GPL(gpio_regmap_register);
*/
void gpio_regmap_unregister(struct gpio_regmap *gpio)
{
+ /*
+ * gpiochip_remove() runs acpi_gpiochip_free_interrupts() and
+ * gpiod_free_irqs(). Both still need the irq domain.
+ * regmap_del_irq_chip() removes that domain, so remove the
+ * gpiochip first.
+ */
+ gpiochip_remove(&gpio->gpio_chip);
+
#ifdef CONFIG_REGMAP_IRQ
if (gpio->irq_chip_data)
regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
#endif

- gpiochip_remove(&gpio->gpio_chip);
bitmap_free(gpio->fixed_direction_output);
bitmap_free(gpio->fixed_direction_mask);
kfree(gpio);

--
2.34.1