diff mbox series

macintosh: Use common error handling code in via_pmu_led_init()

Message ID 189b93e2-4e81-438d-9c77-cbe4d9d7a0d9@web.de (mailing list archive)
State Accepted
Commit 352268dc6da7b422022541c2cf846663110f775c
Headers show
Series macintosh: Use common error handling code in via_pmu_led_init() | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 21 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 5 jobs.

Commit Message

Markus Elfring Oct. 3, 2024, 7:15 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 3 Oct 2024 21:06:42 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/macintosh/via-pmu-led.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

--
2.46.1

Comments

Michael Ellerman Nov. 17, 2024, 12:09 p.m. UTC | #1
On Thu, 03 Oct 2024 21:15:45 +0200, Markus Elfring wrote:
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function implementation.
> 
> This issue was detected by using the Coccinelle software.
> 
> 

Applied to powerpc/next.

[1/1] macintosh: Use common error handling code in via_pmu_led_init()
      https://git.kernel.org/powerpc/c/352268dc6da7b422022541c2cf846663110f775c

cheers
diff mbox series

Patch

diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index a4fb16d7db3c..fc1af74b6596 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -92,18 +92,15 @@  static int __init via_pmu_led_init(void)
 	if (dt == NULL)
 		return -ENODEV;
 	model = of_get_property(dt, "model", NULL);
-	if (model == NULL) {
-		of_node_put(dt);
-		return -ENODEV;
-	}
+	if (!model)
+		goto put_node;
+
 	if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
 	    strncmp(model, "iBook", strlen("iBook")) != 0 &&
 	    strcmp(model, "PowerMac7,2") != 0 &&
-	    strcmp(model, "PowerMac7,3") != 0) {
-		of_node_put(dt);
-		/* ignore */
-		return -ENODEV;
-	}
+	    strcmp(model, "PowerMac7,3") != 0)
+		goto put_node;
+
 	of_node_put(dt);

 	spin_lock_init(&pmu_blink_lock);
@@ -112,6 +109,10 @@  static int __init via_pmu_led_init(void)
 	pmu_blink_req.done = pmu_req_done;

 	return led_classdev_register(NULL, &pmu_led);
+
+put_node:
+	of_node_put(dt);
+	return -ENODEV;
 }

 late_initcall(via_pmu_led_init);