summaryrefslogtreecommitdiffstats
path: root/scripts/dtc/fdt.c
diff options
context:
space:
mode:
authorJan Luebbe <jlu@pengutronix.de>2015-03-04 10:29:31 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-03-05 08:46:05 +0100
commit12888ae902abf9659f80c8f0d3207e009f341dee (patch)
tree081b3915b71180a1603170b15efe7c15379ab544 /scripts/dtc/fdt.c
parentc1ab1e22c71f5cc57306c6a3bfe55f6111505d6b (diff)
downloadbarebox-12888ae902abf9659f80c8f0d3207e009f341dee.tar.gz
barebox-12888ae902abf9659f80c8f0d3207e009f341dee.tar.xz
scripts/dtc: Update to upstream version 1.4.1
Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts/dtc/fdt.c')
-rw-r--r--scripts/dtc/fdt.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/scripts/dtc/fdt.c b/scripts/dtc/fdt.c
index e56833ae9b..2ce6a44179 100644
--- a/scripts/dtc/fdt.c
+++ b/scripts/dtc/fdt.c
@@ -92,7 +92,7 @@ const void *fdt_offset_ptr(const void *fdt, int offset, unsigned int len)
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;
@@ -198,6 +198,34 @@ int fdt_next_node(const void *fdt, int offset, int *depth)
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)
{
int len = strlen(s) + 1;