]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
USB: of: Simplify with scoped for each OF child loop
authorHans Zhang <18255117159@163.com>
Tue, 7 Apr 2026 01:31:22 +0000 (09:31 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 7 Apr 2026 11:49:48 +0000 (13:49 +0200)
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>
drivers/usb/core/of.c

index 763e4122ed5b3c2ae3ec37bb1d3c2e67968c8125..a6ee20d8774e32e73544f3236b6d469d2521f6e2 100644 (file)
@@ -79,17 +79,13 @@ EXPORT_SYMBOL_GPL(usb_of_has_combined_node);
 static bool usb_of_has_devices_or_graph(const struct usb_device *hub)
 {
        const struct device_node *np = hub->dev.of_node;
-       struct device_node *child;
 
        if (of_graph_is_present(np))
                return true;
 
-       for_each_child_of_node(np, child) {
-               if (of_property_present(child, "reg")) {
-                       of_node_put(child);
+       for_each_child_of_node_scoped(np, child)
+               if (of_property_present(child, "reg"))
                        return true;
-               }
-       }
 
        return false;
 }