]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - libfdt/fdt_wip.c
ARM: compiler options cleanup - improve tool chain support
[karo-tx-uboot.git] / libfdt / fdt_wip.c
index 88e24b8318f449e4ab7902fc27b4e7345948299d..e373677c504d1d854af0151f535ce508b1eeddfc 100644 (file)
  */
 #include "libfdt_env.h"
 
+#ifndef USE_HOSTCC
 #include <fdt.h>
 #include <libfdt.h>
+#else
+#include "fdt_host.h"
+#endif
 
 #include "libfdt_internal.h"
 
@@ -72,11 +76,11 @@ int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name,
        return 0;
 }
 
-static void nop_region(void *start, int len)
+static void _fdt_nop_region(void *start, int len)
 {
        uint32_t *p;
 
-       for (p = start; (void *)p < (start + len); p++)
+       for (p = start; (char *)p < ((char *)start + len); p++)
                *p = cpu_to_fdt32(FDT_NOP);
 }
 
@@ -89,46 +93,19 @@ int fdt_nop_property(void *fdt, int nodeoffset, const char *name)
        if (! prop)
                return len;
 
-       nop_region(prop, len + sizeof(*prop));
+       _fdt_nop_region(prop, len + sizeof(*prop));
 
        return 0;
 }
 
-int _fdt_node_end_offset(void *fdt, int nodeoffset)
+int _fdt_node_end_offset(void *fdt, int offset)
 {
-       int level = 0;
-       uint32_t tag;
-       int offset, nextoffset;
-
-       tag = fdt_next_tag(fdt, nodeoffset, &nextoffset);
-       if (tag != FDT_BEGIN_NODE)
-               return -FDT_ERR_BADOFFSET;
-       do {
-               offset = nextoffset;
-               tag = fdt_next_tag(fdt, offset, &nextoffset);
-
-               switch (tag) {
-               case FDT_END:
-                       return offset;
-
-               case FDT_BEGIN_NODE:
-                       level++;
-                       break;
-
-               case FDT_END_NODE:
-                       level--;
-                       break;
-
-               case FDT_PROP:
-               case FDT_NOP:
-                       break;
-
-               default:
-                       return -FDT_ERR_BADSTRUCTURE;
-               }
-       } while (level >= 0);
-
-       return nextoffset;
+       int depth = 0;
+
+       while ((offset >= 0) && (depth >= 0))
+               offset = fdt_next_node(fdt, offset, &depth);
+
+       return offset;
 }
 
 int fdt_nop_node(void *fdt, int nodeoffset)
@@ -139,6 +116,7 @@ int fdt_nop_node(void *fdt, int nodeoffset)
        if (endoffset < 0)
                return endoffset;
 
-       nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0), endoffset - nodeoffset);
+       _fdt_nop_region(fdt_offset_ptr_w(fdt, nodeoffset, 0),
+                       endoffset - nodeoffset);
        return 0;
 }