[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4a82fe70-b07c-4878-bd31-6ae07b61f522@web.de>
Date: Tue, 17 Sep 2024 14:34:54 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: linux-clk@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Claudiu Beznea <claudiu.beznea@...on.dev>,
Michael Turquette <mturquette@...libre.com>,
Nicolas Ferre <nicolas.ferre@...rochip.com>, Stephen Boyd <sboyd@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] clk: at91: pmc: Use common error handling code in
pmc_register_ops()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 17 Sep 2024 14:28:22 +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@...rs.sourceforge.net>
---
drivers/clk/at91/pmc.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 5aa9c1f1c886..040b70e1ffbc 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -162,20 +162,18 @@ static int __init pmc_register_ops(void)
if (!np)
return -ENODEV;
- if (!of_device_is_available(np)) {
- of_node_put(np);
- return -ENODEV;
- }
+ if (!of_device_is_available(np))
+ goto put_node;
+
of_node_put(np);
np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam");
if (!np)
return -ENODEV;
- if (!of_device_is_available(np)) {
- of_node_put(np);
- return -ENODEV;
- }
+ if (!of_device_is_available(np))
+ goto put_node;
+
of_node_put(np);
at91_pmc_backup_suspend = of_iomap(np, 0);
@@ -187,6 +185,10 @@ static int __init pmc_register_ops(void)
register_syscore_ops(&pmc_syscore_ops);
return 0;
+
+put_node:
+ of_node_put(np);
+ return -ENODEV;
}
/* This has to happen before arch_initcall because of the tcb_clksrc driver */
postcore_initcall(pmc_register_ops);
--
2.46.0
Powered by blists - more mailing lists