diff options
author | Thierry Reding <treding@nvidia.com> | 2016-07-27 14:55:53 +0200 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2016-07-28 15:27:57 +1000 |
commit | 902d0f0953d0074b329a2780a4b637fae0d776da (patch) | |
tree | b949e0bd1468a5c583680b6c59501ab0abe85a2f /tests | |
parent | c539075ba8ba61fffbf7e005ce2e834868a9e0ab (diff) | |
download | dtc-902d0f0953d0074b329a2780a4b637fae0d776da.zip dtc-902d0f0953d0074b329a2780a4b637fae0d776da.tar.gz dtc-902d0f0953d0074b329a2780a4b637fae0d776da.tar.bz2 |
libfdt: Add a subnodes iterator macro
The fdt_for_each_subnode() iterator macro provided by this patch can be
used to iterate over a device tree node's subnodes. At each iteration a
loop variable will be set to the next subnode.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/subnode_iterate.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/tests/subnode_iterate.c b/tests/subnode_iterate.c index b9f379d..0fb5c90 100644 --- a/tests/subnode_iterate.c +++ b/tests/subnode_iterate.c @@ -48,9 +48,7 @@ static void test_node(void *fdt, int parent_offset) subnodes = cpu_to_fdt32(*prop); count = 0; - for (offset = fdt_first_subnode(fdt, parent_offset); - offset >= 0; - offset = fdt_next_subnode(fdt, offset)) + fdt_for_each_subnode(offset, fdt, parent_offset) count++; if (count != subnodes) { @@ -65,9 +63,7 @@ static void check_fdt_next_subnode(void *fdt) int offset; int count = 0; - for (offset = fdt_first_subnode(fdt, 0); - offset >= 0; - offset = fdt_next_subnode(fdt, offset)) { + fdt_for_each_subnode(offset, fdt, 0) { test_node(fdt, offset); count++; } |