diff options
author | Grant Likely <grant.likely@linaro.org> | 2015-06-30 14:28:52 +0100 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2015-06-30 14:28:52 +0100 |
commit | becfc3c86df963491ff1d5ffc6131a06af6bb851 (patch) | |
tree | 4b60fb962445166025724b84ce13e7f1762df8a1 /scripts/dtc/libfdt/fdt.c | |
parent | ce32f859646bab2ed724393398b90aa50149bb44 (diff) | |
parent | 0b34c1a489f6f018c4fbfbd12657acaa0b4f4ca9 (diff) |
Merge remote-tracking branch 'robh/for-next' into devicetree/next
Diffstat (limited to 'scripts/dtc/libfdt/fdt.c')
-rw-r--r-- | scripts/dtc/libfdt/fdt.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/scripts/dtc/libfdt/fdt.c b/scripts/dtc/libfdt/fdt.c index e56833ae9b6f..2ce6a44179de 100644 --- a/scripts/dtc/libfdt/fdt.c +++ b/scripts/dtc/libfdt/fdt.c @@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len) uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset) { - const uint32_t *tagp, *lenp; + const fdt32_t *tagp, *lenp; uint32_t tag; int offset = startoffset; const char *p; @@ -198,6 +198,34 @@ int fdt_next_node(const void *fdt, int offset, int *depth) return offset; } +int fdt_first_subnode(const void *fdt, int offset) +{ + int depth = 0; + + offset = fdt_next_node(fdt, offset, &depth); + if (offset < 0 || depth != 1) + return -FDT_ERR_NOTFOUND; + + return offset; +} + +int fdt_next_subnode(const void *fdt, int offset) +{ + int depth = 1; + + /* + * With respect to the parent, the depth of the next subnode will be + * the same as the last. + */ + do { + offset = fdt_next_node(fdt, offset, &depth); + if (offset < 0 || depth < 1) + return -FDT_ERR_NOTFOUND; + } while (depth > 1); + + return offset; +} + const char *_fdt_find_string(const char *strtab, int tabsize, const char *s) { int len = strlen(s) + 1; |