]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
irqchip/renesas-rzv2h: Simplify rzv2h_icu_init()
authorBiju Das <biju.das.jz@bp.renesas.com>
Mon, 24 Feb 2025 13:11:20 +0000 (13:11 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 26 Feb 2025 10:59:49 +0000 (11:59 +0100)
Use devm_add_action_or_reset() for calling put_device in error path of
rzv2h_icu_init() to simplify the code by using the recently added devm_*
helpers.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/all/20250224131253.134199-5-biju.das.jz@bp.renesas.com
drivers/irqchip/irq-renesas-rzv2h.c

index 0573062c89c45f61a92d48bd86d914f6c841cc27..d724f32dde8f2b93d4df50e15e1fa030cbe6b885 100644 (file)
@@ -419,6 +419,11 @@ static int rzv2h_icu_parse_interrupts(struct rzv2h_icu_priv *priv, struct device
        return 0;
 }
 
+static void rzv2h_icu_put_device(void *data)
+{
+       put_device(data);
+}
+
 static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
 {
        struct irq_domain *irq_domain, *parent_domain;
@@ -431,41 +436,39 @@ static int rzv2h_icu_init(struct device_node *node, struct device_node *parent)
        if (!pdev)
                return -ENODEV;
 
+       ret = devm_add_action_or_reset(&pdev->dev, rzv2h_icu_put_device,
+                                      &pdev->dev);
+       if (ret < 0)
+               return ret;
+
        parent_domain = irq_find_host(parent);
        if (!parent_domain) {
                dev_err(&pdev->dev, "cannot find parent domain\n");
-               ret = -ENODEV;
-               goto put_dev;
+               return -ENODEV;
        }
 
        rzv2h_icu_data = devm_kzalloc(&pdev->dev, sizeof(*rzv2h_icu_data), GFP_KERNEL);
-       if (!rzv2h_icu_data) {
-               ret = -ENOMEM;
-               goto put_dev;
-       }
+       if (!rzv2h_icu_data)
+               return -ENOMEM;
 
        rzv2h_icu_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL);
-       if (IS_ERR(rzv2h_icu_data->base)) {
-               ret = PTR_ERR(rzv2h_icu_data->base);
-               goto put_dev;
-       }
+       if (IS_ERR(rzv2h_icu_data->base))
+               return PTR_ERR(rzv2h_icu_data->base);
 
        ret = rzv2h_icu_parse_interrupts(rzv2h_icu_data, node);
        if (ret) {
                dev_err(&pdev->dev, "cannot parse interrupts: %d\n", ret);
-               goto put_dev;
+               return ret;
        }
 
        resetn = devm_reset_control_get_exclusive(&pdev->dev, NULL);
-       if (IS_ERR(resetn)) {
-               ret = PTR_ERR(resetn);
-               goto put_dev;
-       }
+       if (IS_ERR(resetn))
+               return PTR_ERR(resetn);
 
        ret = reset_control_deassert(resetn);
        if (ret) {
                dev_err(&pdev->dev, "failed to deassert resetn pin, %d\n", ret);
-               goto put_dev;
+               return ret;
        }
 
        pm_runtime_enable(&pdev->dev);
@@ -496,8 +499,6 @@ pm_put:
 pm_disable:
        pm_runtime_disable(&pdev->dev);
        reset_control_assert(resetn);
-put_dev:
-       put_device(&pdev->dev);
 
        return ret;
 }