]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Library/FdtLib/fdt.c
EmbeddedPkg/FdtLib: Updated libfdt to 1.4.0
[mirror_edk2.git] / EmbeddedPkg / Library / FdtLib / fdt.c
index 151fcb2ab0475f84e8fdb61d249abfa2bb5094f9..963952820bc6df992e80eac53a77f09ffc02a1fb 100644 (file)
@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
 \r
 uint32_t fdt_next_tag(const void *fdt, int startoffset, int *nextoffset)\r
 {\r
-       const uint32_t *tagp, *lenp;\r
+       const fdt32_t *tagp, *lenp;\r
        uint32_t tag;\r
        int offset = startoffset;\r
        const char *p;\r
@@ -198,6 +198,34 @@ int fdt_next_node(const void *fdt, int offset, int *depth)
        return offset;\r
 }\r
 \r
+int fdt_first_subnode(const void *fdt, int offset)\r
+{\r
+       int depth = 0;\r
+\r
+       offset = fdt_next_node(fdt, offset, &depth);\r
+       if (offset < 0 || depth != 1)\r
+               return -FDT_ERR_NOTFOUND;\r
+\r
+       return offset;\r
+}\r
+\r
+int fdt_next_subnode(const void *fdt, int offset)\r
+{\r
+       int depth = 1;\r
+\r
+       /*\r
+        * With respect to the parent, the depth of the next subnode will be\r
+        * the same as the last.\r
+        */\r
+       do {\r
+               offset = fdt_next_node(fdt, offset, &depth);\r
+               if (offset < 0 || depth < 1)\r
+                       return -FDT_ERR_NOTFOUND;\r
+       } while (depth > 1);\r
+\r
+       return offset;\r
+}\r
+\r
 const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)\r
 {\r
        int len = strlen(s) + 1;\r