mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clk: imx: scu: Use common error handling code in imx_clk_scu_alloc_dev()
@ 2023-12-22 12:03 Markus Elfring
  2024-01-09  6:06 ` Peng Fan
  2024-02-26  9:16 ` Abel Vesa
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Elfring @ 2023-12-22 12:03 UTC (permalink / raw)
  To: Abel Vesa, Fabio Estevam, Michael Turquette, Peng Fan,
	Sascha Hauer, Shawn Guo, Stephen Boyd, kernel, linux-imx,
	linux-clk, linux-arm-kernel, kernel-janitors
  Cc: LKML, cocci, Kuan-Wei Chiu

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 22 Dec 2023 12:56:48 +0100

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>
---
 drivers/clk/imx/clk-scu.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
index e48a904c0013..b1dd0c08e091 100644
--- a/drivers/clk/imx/clk-scu.c
+++ b/drivers/clk/imx/clk-scu.c
@@ -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)
--
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-26  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-22 12:03 [PATCH] clk: imx: scu: Use common error handling code in imx_clk_scu_alloc_dev() Markus Elfring
2024-01-09  6:06 ` Peng Fan
2024-02-26  9:16 ` Abel Vesa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®