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

From: Peng Fan (OSS)

Date: Sat Oct 03 2026 - 08:10:45 EST


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;
}

+ 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