[PATCH] USB: of: Simplify with scoped for each OF child loop

Hans Zhang posted 1 patch 2 months, 1 week ago
drivers/usb/core/of.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
[PATCH] USB: of: Simplify with scoped for each OF child loop
Posted by Hans Zhang 2 months, 1 week ago
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