lkml.org 
[lkml]   [2026]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] USB: of: Simplify with scoped for each OF child loop
Date
Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/usb/core/of.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/core/of.c b/drivers/usb/core/of.c
index 763e4122ed5b..a6ee20d8774e 100644
--- a/drivers/usb/core/of.c
+++ b/drivers/usb/core/of.c
@@ -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;
}
base-commit: 591cd656a1bf5ea94a222af5ef2ee76df029c1d2
--
2.34.1


\
 
 \ /
  Last update: 2026-04-07 03:32    [W:0.050 / U:3.070 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog