Re: [PATCH v13 08/13] gpio: regmap: remove gpiochip before tearing down irqchip

From: Andy Shevchenko

Date: Tue Nov 03 2026 - 12:46:55 EST


On Mon, Nov 02, 2026 at 02:46:01PM +0800, Long Zhao via B4 Relay wrote:

> gpio_regmap_unregister() currently calls regmap_del_irq_chip() before
> gpiochip_remove(). That disposes the mapped virtual IRQs and frees the
> irq_domain while ACPI GPIO-signaled events may still be requested and
> while gpiod_free_irqs() still needs gc->irq.domain.
>
> Remove the gpio_chip first so ACPI teardown and USED_AS_IRQ cleanup run
> against a live domain, then delete the regmap irqchip. Use the same
> order on the registration error path, which previously leaked the
> irqchip when gpiochip_irqchip_add_domain() failed after
> regmap_add_irq_chip_fwnode().

...

> Cc: Michael Walle <mwalle@xxxxxxxxxx>

Use --cc in the command line for `git format-patch` or at least move Cc list to
be after the --- line. This will reduce a noise in the commit message.

...

> +#ifdef CONFIG_REGMAP_IRQ
> + if (gpio->irq_chip_data)
> + regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
> +#endif

> #ifdef CONFIG_REGMAP_IRQ
> if (gpio->irq_chip_data)
> regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
> #endif

Now it seems a dup, make it a helper, like

static void gpio_regmap_del_irq_chip(... *gpio)
{
#ifdef CONFIG_REGMAP_IRQ
if (gpio->irq_chip_data)
regmap_del_irq_chip(gpio->regmap_irq_line, gpio->irq_chip_data);
#endif
}

--
With Best Regards,
Andy Shevchenko