Re: [PATCH 4/9] gpio: mxc: use devm action for irq_domain cleanup

From: Frank Li

Date: Sat Oct 03 2026 - 23:32:34 EST


On Sat, Oct 03, 2026 at 08:06:46PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@xxxxxxx>
>
> Replace the manual irq_domain_remove() error path with
> devm_add_action_or_reset(), so the IRQ domain is cleaned up
> automatically on both probe failure to eliminate the
> out_irqdomain_remove goto label.
>
> Assisted-by: LLM
> Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
> ---
> drivers/gpio/gpio-mxc.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
> index 1c27232f6a80..3c395c82d7d4 100644
> --- a/drivers/gpio/gpio-mxc.c
> +++ b/drivers/gpio/gpio-mxc.c
> @@ -417,6 +417,13 @@ static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enab
> }
> }
>
> +static void mxc_gpio_irq_domain_remove(void *data)
> +{
> + struct irq_domain *domain = data;
> +
> + irq_domain_remove(domain);
> +}
> +
> static int mxc_gpio_probe(struct platform_device *pdev)
> {
> struct gpio_generic_chip_config config = { };
> @@ -526,12 +533,16 @@ static int mxc_gpio_probe(struct platform_device *pdev)
> goto out_bgio;
> }
>

No sure why not irq_domain_create_linear(),
https://lore.kernel.org/imx/aoW8V84mQ7UZhpaC@SMW015318/

Thomas Gleixner accept add devm_irq_domain_create_linear().

Frank

> + err = devm_add_action_or_reset(&pdev->dev, mxc_gpio_irq_domain_remove, port->domain);
> + if (err)
> + goto out_bgio;
> +
> irq_domain_set_pm_device(port->domain, &pdev->dev);
>
> /* gpio-mxc can be a generic irq chip */
> err = mxc_gpio_init_gc(port, irq_base);
> if (err < 0)
> - goto out_irqdomain_remove;
> + goto out_bgio;
>
> list_add_tail(&port->node, &mxc_gpio_ports);
>
> @@ -542,8 +553,6 @@ static int mxc_gpio_probe(struct platform_device *pdev)
>
> return 0;
>
> -out_irqdomain_remove:
> - irq_domain_remove(port->domain);
> out_bgio:
> pm_runtime_disable(&pdev->dev);
> pm_runtime_put_noidle(&pdev->dev);
>
> --
> 2.51.0
>
>