mirror of
https://github.com/dgibson/dtc.git
synced 2026-05-12 19:53:02 -04:00
libfdt: Add fdt_next_subnode() to permit easy subnode iteration
Iterating through subnodes with libfdt is a little painful to write as we
need something like this:
for (depth = 0, count = 0,
offset = fdt_next_node(fdt, parent_offset, &depth);
(offset >= 0) && (depth > 0);
offset = fdt_next_node(fdt, offset, &depth)) {
if (depth == 1) {
/* code body */
}
}
Using fdt_next_subnode() we can instead write this, which is shorter and
easier to get right:
for (offset = fdt_first_subnode(fdt, parent_offset);
offset >= 0;
offset = fdt_next_subnode(fdt, offset)) {
/* code body */
}
Also, it doesn't require two levels of indentation for the loop body.
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
a6d55e039f
commit
4e76ec796c
6 changed files with 193 additions and 1 deletions
|
|
@ -20,7 +20,8 @@ LIB_TESTS_L = get_mem_rsv \
|
|||
dtb_reverse dtbs_equal_unordered \
|
||||
add_subnode_with_nops path_offset_aliases \
|
||||
utilfdt_test \
|
||||
integer-expressions
|
||||
integer-expressions \
|
||||
subnode_iterate
|
||||
LIB_TESTS = $(LIB_TESTS_L:%=$(TESTS_PREFIX)%)
|
||||
|
||||
LIBTREE_TESTS_L = truncated_property
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue