]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - common/fdt_support.c
fdt_support: fix obiwan error in OF_CHECK_COUNTS()
[karo-tx-uboot.git] / common / fdt_support.c
index 5d8eb12f10737a5eedf4d814a0406611284e7fb8..1353651c5c5ab5fcc2009d3d9f176c5af7560fa4 100644 (file)
@@ -436,7 +436,7 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks)
        /* find or create "/memory" node. */
        nodeoffset = fdt_find_or_add_subnode(blob, 0, "memory");
        if (nodeoffset < 0)
-                       return nodeoffset;
+               return nodeoffset;
 
        err = fdt_setprop(blob, nodeoffset, "device_type", "memory",
                        sizeof("memory"));
@@ -949,7 +949,7 @@ void fdt_del_node_and_alias(void *blob, const char *alias)
 #define OF_MAX_ADDR_CELLS      4
 #define OF_BAD_ADDR    FDT_ADDR_T_NONE
 #define OF_CHECK_COUNTS(na, ns)        ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
-                       (ns) > 0)
+                       (ns) >= 0)
 
 /* Debug utility */
 #ifdef DEBUG
@@ -997,8 +997,8 @@ static void of_dump_addr(const char *s, const fdt32_t *addr, int na) { }
 struct of_bus {
        const char      *name;
        const char      *addresses;
-       int             (*match)(void *blob, int parentoffset);
-       void            (*count_cells)(void *blob, int parentoffset,
+       int             (*match)(const void *blob, int parentoffset);
+       void            (*count_cells)(const void *blob, int parentoffset,
                                int *addrc, int *sizec);
        u64             (*map)(fdt32_t *addr, const fdt32_t *range,
                                int na, int ns, int pna);
@@ -1006,7 +1006,7 @@ struct of_bus {
 };
 
 /* Default translator (generic bus) */
-void of_bus_default_count_cells(void *blob, int parentoffset,
+void of_bus_default_count_cells(const void *blob, int parentoffset,
                                        int *addrc, int *sizec)
 {
        const fdt32_t *prop;
@@ -1055,7 +1055,7 @@ static int of_bus_default_translate(fdt32_t *addr, u64 offset, int na)
 #ifdef CONFIG_OF_ISA_BUS
 
 /* ISA bus translator */
-static int of_bus_isa_match(void *blob, int parentoffset)
+static int of_bus_isa_match(const void *blob, int parentoffset)
 {
        const char *name;
 
@@ -1066,7 +1066,7 @@ static int of_bus_isa_match(void *blob, int parentoffset)
        return !strcmp(name, "isa");
 }
 
-static void of_bus_isa_count_cells(void *blob, int parentoffset,
+static void of_bus_isa_count_cells(const void *blob, int parentoffset,
                                   int *addrc, int *sizec)
 {
        if (addrc)
@@ -1126,7 +1126,7 @@ static struct of_bus of_busses[] = {
        },
 };
 
-static struct of_bus *of_match_bus(void *blob, int parentoffset)
+static struct of_bus *of_match_bus(const void *blob, int parentoffset)
 {
        struct of_bus *bus;
 
@@ -1148,7 +1148,7 @@ static struct of_bus *of_match_bus(void *blob, int parentoffset)
        return NULL;
 }
 
-static int of_translate_one(void * blob, int parent, struct of_bus *bus,
+static int of_translate_one(const void *blob, int parent, struct of_bus *bus,
                            struct of_bus *pbus, fdt32_t *addr,
                            int na, int ns, int pna, const char *rprop)
 {
@@ -1211,8 +1211,8 @@ static int of_translate_one(void * blob, int parent, struct of_bus *bus,
  * that can be mapped to a cpu physical address). This is not really specified
  * that way, but this is traditionally the way IBM at least do things
  */
-static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in_addr,
-                                 const char *rprop)
+static u64 __of_translate_address(const void *blob, int node_offset,
+                                 const fdt32_t *in_addr, const char *rprop)
 {
        int parent;
        struct of_bus *bus, *pbus;
@@ -1229,11 +1229,11 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in
                goto bail;
        bus = of_match_bus(blob, parent);
 
-       /* 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__,
-                      fdt_get_name(blob, node_offset, NULL));
+               printf("%s: Bad cell count #address-cells=%d #size-cells=%d for %s\n", __FUNCTION__,
+                       na, ns, fdt_get_name(blob, node_offset, NULL));
                goto bail;
        }
        memcpy(addr, in_addr, na * 4);
@@ -1259,8 +1259,8 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in
                pbus = of_match_bus(blob, parent);
                pbus->count_cells(blob, parent, &pna, &pns);
                if (!OF_CHECK_COUNTS(pna, pns)) {
-                       printf("%s: Bad cell count for %s\n", __FUNCTION__,
-                               fdt_get_name(blob, node_offset, NULL));
+                       printf("%s: Bad cell count #address-cells=%d #size-cells=%d for %s\n", __FUNCTION__,
+                               pna, pns, fdt_get_name(blob, node_offset, NULL));
                        break;
                }
 
@@ -1284,7 +1284,8 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in
        return result;
 }
 
-u64 fdt_translate_address(void *blob, int node_offset, const fdt32_t *in_addr)
+u64 fdt_translate_address(const void *blob, int node_offset,
+                         const fdt32_t *in_addr)
 {
        return __of_translate_address(blob, node_offset, in_addr, "ranges");
 }