Skip to content

Commit 9a8881a

Browse files
Hans Zhanggregkh
authored andcommitted
USB: of: Simplify with scoped for each OF child loop
Use scoped for-each loop when iterating over device nodes to make code a bit simpler. Signed-off-by: Hans Zhang <18255117159@163.com> Link: https://patch.msgid.link/20260407013122.1296818-1-18255117159@163.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2ab833a commit 9a8881a

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

  • drivers/usb/core

drivers/usb/core/of.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,13 @@ EXPORT_SYMBOL_GPL(usb_of_has_combined_node);
7979
static bool usb_of_has_devices_or_graph(const struct usb_device *hub)
8080
{
8181
const struct device_node *np = hub->dev.of_node;
82-
struct device_node *child;
8382

8483
if (of_graph_is_present(np))
8584
return true;
8685

87-
for_each_child_of_node(np, child) {
88-
if (of_property_present(child, "reg")) {
89-
of_node_put(child);
86+
for_each_child_of_node_scoped(np, child)
87+
if (of_property_present(child, "reg"))
9088
return true;
91-
}
92-
}
9389

9490
return false;
9591
}

0 commit comments

Comments
 (0)