diff options
author | Simon Glass <sjg@chromium.org> | 2013-05-07 06:11:50 +0000 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2013-05-14 15:37:25 -0400 |
commit | 88f95bbadda89bfaf6a8e817bb66fd114afc1caf (patch) | |
tree | 17a3c26a6ef0df9a2469c55848a3949bebd3b3d8 /include/fdt_support.h | |
parent | 816cb037adf94ead77593812ccd3244d506175fa (diff) | |
download | u-boot-imx-88f95bbadda89bfaf6a8e817bb66fd114afc1caf.zip u-boot-imx-88f95bbadda89bfaf6a8e817bb66fd114afc1caf.tar.gz u-boot-imx-88f95bbadda89bfaf6a8e817bb66fd114afc1caf.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>
(Cherry-picked from dtc commit 4e76ec79)
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
Diffstat (limited to 'include/fdt_support.h')
0 files changed, 0 insertions, 0 deletions