dm: core: Add ofnode_for_each_subnode()
Add a convenience macro to iterate over subnodes of a node. Make use of
this where appropriate in the code.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 0685b68..c6ca13f 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -390,10 +390,11 @@
if (!ofnode_valid(timings))
return -EINVAL;
- for (i = 0, node = ofnode_first_subnode(timings);
- ofnode_valid(node) && i != index;
- node = ofnode_first_subnode(node))
- i++;
+ i = 0;
+ ofnode_for_each_subnode(node, timings) {
+ if (i++ == index)
+ break;
+ }
if (!ofnode_valid(node))
return -EINVAL;