--- zzzz-none-000/linux-3.10.107/scripts/dtc/libfdt/fdt.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/scripts/dtc/libfdt/fdt.c 2021-02-04 17:41:59.000000000 +0000 @@ -78,7 +78,15 @@ { const char *p; - if (fdt_version(fdt) >= 0x11) + if (fdt_version(fdt) >= 0x11 +#ifdef CONFIG_OF_AVM_DT + /* In case the dt was build in v17 but without offset + * information, we verify that the offset contains a non + * zero value. + */ + && fdt_size_dt_struct(fdt) +#endif + ) if (((offset + len) < offset) || ((offset + len) > fdt_size_dt_struct(fdt))) return NULL; @@ -92,7 +100,7 @@ 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; @@ -197,6 +205,34 @@ 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) {