Commit ace1c4b5 authored by 권오훈's avatar 권오훈 Committed by Rob Herring

of: base: remove unnecessary for loop

In __of_get_next_child function, loop iteration for getting next node is
unnecessary.

for loop is already checking if next is NULL or not, and
of_node_get(next) always returns next itself.

Therefore checking return value in the if clause always evaluates to
true, and thus it always breaks out from for loop in the first iteration.

Remove the unnecessary for loop for readability.

I tested the code as below, and it showed that BUG was never called.

-       for (; next; next = next->sibling)
+       for (; next; next = next->sibling) {
                if (of_node_get(next))
                        break;
+               BUG();
+       }
Signed-off-by: default avatarOhhoon Kwon <ohoono.kwon@samsung.com>
Link: https://lore.kernel.org/r/20210701140328epcms1p85149318b6c18fa18b3c7c8e966c14db0@epcms1p8Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 2720b991
......@@ -708,9 +708,7 @@ static struct device_node *__of_get_next_child(const struct device_node *node,
return NULL;
next = prev ? prev->sibling : node->child;
for (; next; next = next->sibling)
if (of_node_get(next))
break;
of_node_get(next);
of_node_put(prev);
return next;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment