X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=common%2Ffdt_support.c;h=891fcac08e03252e8d6e1d718b6dd4a395198d40;hb=8b07e1565c9e99e8c01614655967a923076f03f0;hp=8266bca7d6489a2ca8fb6f1015064184b137d2dd;hpb=9b416a9f4ca7cf5ac4d5f7143d67edde7f7d7326;p=karo-tx-uboot.git diff --git a/common/fdt_support.c b/common/fdt_support.c index 8266bca7d6..891fcac08e 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -532,7 +532,8 @@ int fdt_shrink_to_minimum(void *blob) ret = fdt_add_mem_rsv(blob, (uintptr_t)blob, actualsize); if (ret < 0) return ret; - + if (getenv("fdtsize")) + setenv_hex("fdtsize", actualsize); return actualsize; } @@ -702,7 +703,7 @@ struct reg_cell { unsigned int r1; }; -int fdt_del_subnodes(const void *blob, int parent_offset) +static int fdt_del_subnodes(const void *blob, int parent_offset) { int off, ndepth; int ret; @@ -710,18 +711,20 @@ int fdt_del_subnodes(const void *blob, int parent_offset) for (ndepth = 0, off = fdt_next_node(blob, parent_offset, &ndepth); (off >= 0) && (ndepth > 0); off = fdt_next_node(blob, off, &ndepth)) { - if (ndepth == 1) { - debug("delete %s: offset: %x\n", - fdt_get_name(blob, off, 0), off); - ret = fdt_del_node((void *)blob, off); - if (ret < 0) { - printf("Can't delete node: %s\n", - fdt_strerror(ret)); - return ret; - } else { - ndepth = 0; - off = parent_offset; - } + if (ndepth != 1) + continue; + if (fdt_getprop(blob, off, "compatible", NULL)) + continue; + debug("delete %s: offset: %x\n", + fdt_get_name(blob, off, 0), off); + ret = fdt_del_node((void *)blob, off); + if (ret < 0) { + printf("Can't delete node: %s\n", + fdt_strerror(ret)); + return ret; + } else { + ndepth = 0; + off = parent_offset; } } return 0; @@ -731,11 +734,14 @@ int fdt_del_partitions(void *blob, int parent_offset) { const void *prop; int ndepth = 0; - int off; + int off = parent_offset; int ret; - off = fdt_next_node(blob, parent_offset, &ndepth); - if (off > 0 && ndepth == 1) { + while ((off = fdt_next_node(blob, off, &ndepth)) > 0) { + if (ndepth != 1) + continue; + if (fdt_getprop(blob, off, "compatible", NULL)) + continue; prop = fdt_getprop(blob, off, "label", NULL); if (prop == NULL) { /* @@ -761,7 +767,7 @@ int fdt_node_set_part_info(void *blob, int parent_offset, struct list_head *pentry; struct part_info *part; struct reg_cell cell; - int off, ndepth = 0; + int off = parent_offset, ndepth = 0; int part_num, ret; char buf[64]; @@ -773,10 +779,14 @@ int fdt_node_set_part_info(void *blob, int parent_offset, * Check if it is nand {}; subnode, adjust * the offset in this case */ - off = fdt_next_node(blob, parent_offset, &ndepth); - if (off > 0 && ndepth == 1) + while ((off = fdt_next_node(blob, off, &ndepth)) > 0) { + if (ndepth != 1) + continue; + if (fdt_getprop(blob, off, "compatible", NULL)) + continue; parent_offset = off; - + break; + } part_num = 0; list_for_each_prev(pentry, &dev->parts) { int newoff; @@ -1085,7 +1095,7 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in goto bail; bus = &of_busses[0]; - /* Cound address cells & copy address locally */ + /* Count address cells & copy address locally */ bus->count_cells(blob, parent, &na, &ns); if (!OF_CHECK_COUNTS(na, ns)) { printf("%s: Bad cell count for %s\n", __FUNCTION__,