aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass2017-08-05 15:45:54 -0600
committerSimon Glass2017-09-11 21:43:58 -0600
commit3991f42ed2e38aff28ba3c24369bfbd90620bea7 (patch)
tree4e91056bedde884d7bec42bf45a32e6a1fcd01e0 /drivers
parent8639f69a61b47971dba47ab5ed72e47436729bb1 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/ofnode.c9
-rw-r--r--drivers/misc/cros_ec.c3
-rw-r--r--drivers/power/pmic/pmic-uclass.c4
3 files changed, 7 insertions, 9 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 0685b689d84..c6ca13fabf1 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -390,10 +390,11 @@ int ofnode_decode_display_timing(ofnode parent, int index,
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;
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index feaa5d85676..eefaaa53ad4 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -1038,8 +1038,7 @@ int cros_ec_decode_ec_flash(struct udevice *dev, struct fdt_cros_ec *config)
config->flash_erase_value = ofnode_read_s32_default(flash_node,
"erase-value", -1);
- for (node = ofnode_first_subnode(flash_node); ofnode_valid(node);
- node = ofnode_next_subnode(node)) {
+ ofnode_for_each_subnode(node, flash_node) {
const char *name = ofnode_get_name(node);
enum ec_flash_region region;
diff --git a/drivers/power/pmic/pmic-uclass.c b/drivers/power/pmic/pmic-uclass.c
index 953bbe50269..64964e4e963 100644
--- a/drivers/power/pmic/pmic-uclass.c
+++ b/drivers/power/pmic/pmic-uclass.c
@@ -34,9 +34,7 @@ int pmic_bind_children(struct udevice *pmic, ofnode parent,
debug("%s for '%s' at node offset: %d\n", __func__, pmic->name,
dev_of_offset(pmic));
- for (node = ofnode_first_subnode(parent);
- ofnode_valid(node);
- node = ofnode_next_subnode(node)) {
+ ofnode_for_each_subnode(node, parent) {
node_name = ofnode_get_name(node);
debug("* Found child node: '%s'\n", node_name);