clk: imx: scu: Use common error handling code in imx_clk_scu_alloc_dev()
authorMarkus Elfring <elfring@users.sourceforge.net>
Fri, 22 Dec 2023 11:56:48 +0000 (12:56 +0100)
committerAbel Vesa <abel.vesa@linaro.org>
Mon, 26 Feb 2024 08:59:46 +0000 (10:59 +0200)
Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/01446ce9-c0e8-4467-8b2d-fd736bc5b8e4@web.de
Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
drivers/clk/imx/clk-scu.c

index e48a904c0013302fbe424c310266d4feea4b9940..b1dd0c08e091b6b61f6972eb630adacaa4f288c2 100644 (file)
@@ -712,17 +712,13 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
        }
 
        ret = platform_device_add_data(pdev, &clk, sizeof(clk));
-       if (ret) {
-               platform_device_put(pdev);
-               return ERR_PTR(ret);
-       }
+       if (ret)
+               goto put_device;
 
        ret = driver_set_override(&pdev->dev, &pdev->driver_override,
                                  "imx-scu-clk", strlen("imx-scu-clk"));
-       if (ret) {
-               platform_device_put(pdev);
-               return ERR_PTR(ret);
-       }
+       if (ret)
+               goto put_device;
 
        ret = imx_clk_scu_attach_pd(&pdev->dev, rsrc_id);
        if (ret)
@@ -730,13 +726,15 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
                        name, ret);
 
        ret = platform_device_add(pdev);
-       if (ret) {
-               platform_device_put(pdev);
-               return ERR_PTR(ret);
-       }
+       if (ret)
+               goto put_device;
 
        /* For API backwards compatiblilty, simply return NULL for success */
        return NULL;
+
+put_device:
+       platform_device_put(pdev);
+       return ERR_PTR(ret);
 }
 
 void imx_clk_scu_unregister(void)