Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Hans Zhang and committed by
Greg Kroah-Hartman
9a8881aa 2ab833a1

+2 -6
+2 -6
drivers/usb/core/of.c
··· 79 79 static bool usb_of_has_devices_or_graph(const struct usb_device *hub) 80 80 { 81 81 const struct device_node *np = hub->dev.of_node; 82 - struct device_node *child; 83 82 84 83 if (of_graph_is_present(np)) 85 84 return true; 86 85 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")) 90 88 return true; 91 - } 92 - } 93 89 94 90 return false; 95 91 }