lkml.org 
[lkml]   [2023]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH 3/9] regulator/core: of_get_child_regulator: remove goto
From
Because of_node_put() handles NULL properly (like kfree() et al)
we can call it also after the loop ends (due to child == NULL).
This makes the gotos redundant.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a467be1f198b..3703aa3f5636 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -426,18 +426,15 @@ static struct device_node *of_get_child_regulator(struct device_node *parent,

for_each_child_of_node(parent, child) {
regnode = of_parse_phandle(child, prop_name, 0);
+ if (regnode)
+ break;

- if (!regnode) {
- regnode = of_get_child_regulator(child, prop_name);
- if (regnode)
- goto err_node_put;
- } else {
- goto err_node_put;
- }
+ regnode = of_get_child_regulator(child, prop_name);
+ if (regnode)
+ break;
}
- return NULL;

-err_node_put:
+ /* Release the node if the loop was exited early. */
of_node_put(child);
return regnode;
}
--
2.39.2
\
 
 \ /
  Last update: 2023-08-31 00:58    [W:0.103 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site