diff options
author | Simon Glass <sjg@chromium.org> | 2013-04-26 05:43:31 -0700 |
---|---|---|
committer | Jon Loeliger <jdl@jdl.com> | 2013-04-28 07:30:49 -0500 |
commit | 4e76ec796c90d44d417f82d9db2d67cfe575f8ed (patch) | |
tree | d74894ae6551eaec1a1ee1b322ba3e051fe0f58d /util.c | |
parent | a6d55e039fd22048687fe061b4609e2807efe764 (diff) | |
download | dtc-4e76ec796c90d44d417f82d9db2d67cfe575f8ed.zip dtc-4e76ec796c90d44d417f82d9db2d67cfe575f8ed.tar.gz dtc-4e76ec796c90d44d417f82d9db2d67cfe575f8ed.tar.bz2 |
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>
Diffstat (limited to 'util.c')
0 files changed, 0 insertions, 0 deletions