public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt
@ 2008-08-20  2:30 gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 1/7] dtc: Enable and fix -Wpointer-arith warnings gvb.uboot at gmail.com
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

The following changesets resynchronize u-boot with the master libfdt.

Best regards,
gvb

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 1/7] dtc: Enable and fix -Wpointer-arith warnings
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
@ 2008-08-20  2:30 ` gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 2/7] dtc: Enable and fix -Wcast-qual warnings gvb.uboot at gmail.com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

From: David Gibson <david@gibson.dropbear.id.au>

This patch turns on the -Wpointer-arith option in the dtc Makefile,
and fixes the resulting warnings due to using (void *) in pointer
arithmetic.  While convenient, pointer arithmetic on void * is not
portable, so it's better that we avoid it, particularly in libfdt.

Also add necessary definition of uintptr_t needed by David Gibson's
changeset "dtc: Enable and fix -Wpointer-arith warnings" (the definition
comes from stdint.h, which u-boot doesn't have). -- gvb

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---
 include/libfdt_env.h     |   12 +++++++++++
 libfdt/fdt.c             |    2 +-
 libfdt/fdt_ro.c          |    4 +-
 libfdt/fdt_rw.c          |   49 +++++++++++++++++++++++++--------------------
 libfdt/fdt_sw.c          |    2 +-
 libfdt/fdt_wip.c         |    2 +-
 libfdt/libfdt_internal.h |    6 ++--
 7 files changed, 47 insertions(+), 30 deletions(-)

diff --git a/include/libfdt_env.h b/include/libfdt_env.h
index a7fd2f8..671c3a8 100644
--- a/include/libfdt_env.h
+++ b/include/libfdt_env.h
@@ -38,4 +38,16 @@ extern struct fdt_header *working_fdt;  /* Pointer to the working fdt */
 #define fdt64_to_cpu(x)		__be64_to_cpu(x)
 #define cpu_to_fdt64(x)		__cpu_to_be64(x)
 
+/*
+ * Types for `void *' pointers.
+ *
+ * Note: libfdt uses this definition from /usr/include/stdint.h.
+ * Define it here rather than pulling in all of stdint.h.
+ */
+#if __WORDSIZE == 64
+typedef unsigned long int       uintptr_t;
+#else
+typedef unsigned int            uintptr_t;
+#endif
+
 #endif /* _LIBFDT_ENV_H */
diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index cb08ba0..18e8d3c 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -80,7 +80,7 @@ int fdt_check_header(const void *fdt)
 
 const void *fdt_offset_ptr(const void *fdt, int offset, int len)
 {
-	const void *p;
+	const char *p;
 
 	if (fdt_version(fdt) >= 0x11)
 		if (((offset + len) < offset)
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 69af7bb..8382afd 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -412,10 +412,10 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
 					     &phandle, sizeof(phandle));
 }
 
-int _stringlist_contains(const void *strlist, int listlen, const char *str)
+int _stringlist_contains(const char *strlist, int listlen, const char *str)
 {
 	int len = strlen(str);
-	const void *p;
+	const char *p;
 
 	while (listlen >= len) {
 		if (memcmp(str, strlist, len+1) == 0)
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 95a5c2c..4a16014 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -98,13 +98,14 @@ static inline int _blob_data_size(void *fdt)
 	return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
 }
 
-static int _blob_splice(void *fdt, void *p, int oldlen, int newlen)
+static int _blob_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
 {
-	void *end = fdt + _blob_data_size(fdt);
+	char *p = splicepoint;
+	char *end = (char *)fdt + _blob_data_size(fdt);
 
 	if (((p + oldlen) < p) || ((p + oldlen) > end))
 		return -FDT_ERR_BADOFFSET;
-	if ((end - oldlen + newlen) > (fdt + fdt_totalsize(fdt)))
+	if ((end - oldlen + newlen) > ((char *)fdt + fdt_totalsize(fdt)))
 		return -FDT_ERR_NOSPACE;
 	memmove(p + newlen, p + oldlen, end - p - oldlen);
 	return 0;
@@ -139,7 +140,8 @@ static int _blob_splice_struct(void *fdt, void *p,
 
 static int _blob_splice_string(void *fdt, int newlen)
 {
-	void *p = fdt + fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
+	void *p = (char *)fdt
+		+ fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
 	int err;
 
 	if ((err = _blob_splice(fdt, p, 0, newlen)))
@@ -342,7 +344,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
 	memset(nh->name, 0, ALIGN(namelen+1, FDT_TAGSIZE));
 	memcpy(nh->name, name, namelen);
-	endtag = (uint32_t *)((void *)nh + nodelen - FDT_TAGSIZE);
+	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
 
 	return offset;
@@ -367,7 +369,7 @@ int fdt_del_node(void *fdt, int nodeoffset)
 				   endoffset - nodeoffset, 0);
 }
 
-static void _packblocks(const void *fdt, void *buf,
+static void _packblocks(const char *old, char *new,
 		       int mem_rsv_size, int struct_size)
 {
 	int mem_rsv_off, struct_off, strings_off;
@@ -376,17 +378,17 @@ static void _packblocks(const void *fdt, void *buf,
 	struct_off = mem_rsv_off + mem_rsv_size;
 	strings_off = struct_off + struct_size;
 
-	memmove(buf + mem_rsv_off, fdt + fdt_off_mem_rsvmap(fdt), mem_rsv_size);
-	fdt_set_off_mem_rsvmap(buf, mem_rsv_off);
+	memmove(new + mem_rsv_off, old + fdt_off_mem_rsvmap(old), mem_rsv_size);
+	fdt_set_off_mem_rsvmap(new, mem_rsv_off);
 
-	memmove(buf + struct_off, fdt + fdt_off_dt_struct(fdt), struct_size);
-	fdt_set_off_dt_struct(buf, struct_off);
-	fdt_set_size_dt_struct(buf, struct_size);
+	memmove(new + struct_off, old + fdt_off_dt_struct(old), struct_size);
+	fdt_set_off_dt_struct(new, struct_off);
+	fdt_set_size_dt_struct(new, struct_size);
 
-	memmove(buf + strings_off, fdt + fdt_off_dt_strings(fdt),
-		fdt_size_dt_strings(fdt));
-	fdt_set_off_dt_strings(buf, strings_off);
-	fdt_set_size_dt_strings(buf, fdt_size_dt_strings(fdt));
+	memmove(new + strings_off, old + fdt_off_dt_strings(old),
+		fdt_size_dt_strings(old));
+	fdt_set_off_dt_strings(new, strings_off);
+	fdt_set_size_dt_strings(new, fdt_size_dt_strings(old));
 }
 
 int fdt_open_into(const void *fdt, void *buf, int bufsize)
@@ -394,7 +396,9 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 	int err;
 	int mem_rsv_size, struct_size;
 	int newsize;
-	void *tmp;
+	const char *fdtstart = fdt;
+	const char *fdtend = fdtstart + fdt_totalsize(fdt);
+	char *tmp;
 
 	CHECK_HEADER(fdt);
 
@@ -427,12 +431,13 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 	if (bufsize < newsize)
 		return -FDT_ERR_NOSPACE;
 
-	if (((buf + newsize) <= fdt)
-	    || (buf >= (fdt + fdt_totalsize(fdt)))) {
-		tmp = buf;
-	} else {
-		tmp = (void *)fdt + fdt_totalsize(fdt);
-		if ((tmp + newsize) > (buf + bufsize))
+	/* First attempt to build converted tree at beginning of buffer */
+	tmp = buf;
+	/* But if that overlaps with the old tree... */
+	if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
+		/* Try right after the old tree instead */
+		tmp = (char *)fdtend;
+		if ((tmp + newsize) > ((char *)buf + bufsize))
 			return -FDT_ERR_NOSPACE;
 	}
 
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index df09876..92f8f0b 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -121,7 +121,7 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
 	if ((offset + sizeof(*re)) > fdt_totalsize(fdt))
 		return -FDT_ERR_NOSPACE;
 
-	re = (struct fdt_reserve_entry *)(fdt + offset);
+	re = (struct fdt_reserve_entry *)((char *)fdt + offset);
 	re->address = cpu_to_fdt64(addr);
 	re->size = cpu_to_fdt64(size);
 
diff --git a/libfdt/fdt_wip.c b/libfdt/fdt_wip.c
index 24e1724..b336113 100644
--- a/libfdt/fdt_wip.c
+++ b/libfdt/fdt_wip.c
@@ -80,7 +80,7 @@ static void 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);
 }
 
diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
index f72e70d..2ba30db 100644
--- a/libfdt/libfdt_internal.h
+++ b/libfdt/libfdt_internal.h
@@ -72,7 +72,7 @@ int _fdt_node_end_offset(void *fdt, int nodeoffset);
 
 static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
 {
-	return fdt + fdt_off_dt_struct(fdt) + offset;
+	return (const char *)fdt + fdt_off_dt_struct(fdt) + offset;
 }
 
 static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
@@ -82,8 +82,8 @@ static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
 
 static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
 {
-	const struct fdt_reserve_entry *rsv_table =
-		fdt + fdt_off_mem_rsvmap(fdt);
+	const struct fdt_reserve_entry *rsv_table = (struct fdt_reserve_entry *)
+		((const char *)fdt + fdt_off_mem_rsvmap(fdt));
 
 	return rsv_table + n;
 }
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 2/7] dtc: Enable and fix -Wcast-qual warnings
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 1/7] dtc: Enable and fix -Wpointer-arith warnings gvb.uboot at gmail.com
@ 2008-08-20  2:30 ` gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 3/7] libfdt: Increase namespace-pollution paranoia gvb.uboot at gmail.com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

From: David Gibson <david@gibson.dropbear.id.au>

Enabling -Wcast-qual warnings in dtc shows up a number of places where
we are incorrectly discarding a const qualification.  There are also
some places where we are intentionally discarding the 'const', and we
need an ugly cast through uintptr_t to suppress the warning.  However,
most of these are pretty well isolated with the *_w() functions.  So
in the interests of maximum safety with const qualifications, this
patch enables the warnings and fixes the existing complaints.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
---
 include/libfdt.h         |    8 ++++----
 libfdt/fdt_ro.c          |    2 +-
 libfdt/fdt_rw.c          |    4 ++--
 libfdt/libfdt_internal.h |    7 ++++---
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index 2a2b23d..7e043ef 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -125,7 +125,7 @@
 const void *fdt_offset_ptr(const void *fdt, int offset, int checklen);
 static inline void *fdt_offset_ptr_w(void *fdt, int offset, int checklen)
 {
-	return (void *)fdt_offset_ptr(fdt, offset, checklen);
+	return (void *)(uintptr_t)fdt_offset_ptr(fdt, offset, checklen);
 }
 
 uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset);
@@ -375,8 +375,8 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
 						      const char *name,
 						      int *lenp)
 {
-	return (struct fdt_property *)fdt_get_property(fdt, nodeoffset,
-						       name, lenp);
+	return (struct fdt_property *)(uintptr_t)
+		fdt_get_property(fdt, nodeoffset, name, lenp);
 }
 
 /**
@@ -411,7 +411,7 @@ const void *fdt_getprop(const void *fdt, int nodeoffset,
 static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
 				  const char *name, int *lenp)
 {
-	return (void *)fdt_getprop(fdt, nodeoffset, name, lenp);
+	return (void *)(uintptr_t)fdt_getprop(fdt, nodeoffset, name, lenp);
 }
 
 /**
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 8382afd..1c897c5 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -81,7 +81,7 @@ static int nodename_eq(const void *fdt, int offset,
 
 const char *fdt_string(const void *fdt, int stroffset)
 {
-	return (char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
+	return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
 }
 
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 4a16014..6837fb1 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -261,7 +261,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
 
 	RW_CHECK_HEADER(fdt);
 
-	namep = (char *)fdt_get_name(fdt, nodeoffset, &oldlen);
+	namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
 	if (!namep)
 		return oldlen;
 
@@ -436,7 +436,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 	/* But if that overlaps with the old tree... */
 	if (((tmp + newsize) > fdtstart) && (tmp < fdtend)) {
 		/* Try right after the old tree instead */
-		tmp = (char *)fdtend;
+		tmp = (char *)(uintptr_t)fdtend;
 		if ((tmp + newsize) > ((char *)buf + bufsize))
 			return -FDT_ERR_NOSPACE;
 	}
diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
index 2ba30db..549e345 100644
--- a/libfdt/libfdt_internal.h
+++ b/libfdt/libfdt_internal.h
@@ -77,19 +77,20 @@ static inline const void *_fdt_offset_ptr(const void *fdt, int offset)
 
 static inline void *_fdt_offset_ptr_w(void *fdt, int offset)
 {
-	return (void *)_fdt_offset_ptr(fdt, offset);
+	return (void *)(uintptr_t)_fdt_offset_ptr(fdt, offset);
 }
 
 static inline const struct fdt_reserve_entry *_fdt_mem_rsv(const void *fdt, int n)
 {
-	const struct fdt_reserve_entry *rsv_table = (struct fdt_reserve_entry *)
+	const struct fdt_reserve_entry *rsv_table =
+		(const struct fdt_reserve_entry *)
 		((const char *)fdt + fdt_off_mem_rsvmap(fdt));
 
 	return rsv_table + n;
 }
 static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
 {
-	return (void *)_fdt_mem_rsv(fdt, n);
+	return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
 }
 
 #define SW_MAGIC		(~FDT_MAGIC)
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 3/7] libfdt: Increase namespace-pollution paranoia
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 1/7] dtc: Enable and fix -Wpointer-arith warnings gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 2/7] dtc: Enable and fix -Wcast-qual warnings gvb.uboot at gmail.com
@ 2008-08-20  2:30 ` gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 4/7] libfdt: Improve documentation in libfdt.h gvb.uboot at gmail.com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

From: David Gibson <david@gibson.dropbear.id.au>

libfdt is supposed to easy to embed in projects all and sundry.
Often, it won't be practical to separate the embedded libfdt's
namespace from that of the surrounding project.  Which means there can
be namespace conflicts between even libfdt's internal/static functions
and functions or macros coming from the surrounding project's headers
via libfdt_env.h.

This patch, therefore, renames a bunch of libfdt internal functions
and macros and makes a few other chances to reduce the chances of
namespace collisions with embedding projects.  Specifically:
	- Internal functions (even static ones) are now named _fdt_*()

	- The type and (static) global for the error table in
          fdt_strerror() gain an fdt_ prefix

	- The unused macro PALIGN is removed

	- The memeq and streq macros are removed and open-coded in the
          users (they were only used once each)

	- Other macros gain an FDT_ prefix

	- To save some of the bulk from the previous change, an
          FDT_TAGALIGN() macro is introduced, where FDT_TAGALIGN(x) ==
          FDT_ALIGN(x, FDT_TAGSIZE)

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 libfdt/fdt.c             |    8 ++--
 libfdt/fdt_ro.c          |   22 ++++----
 libfdt/fdt_rw.c          |  121 +++++++++++++++++++++++-----------------------
 libfdt/fdt_strerror.c    |   34 +++++++-------
 libfdt/fdt_sw.c          |   38 +++++++-------
 libfdt/fdt_wip.c         |    7 ++-
 libfdt/libfdt_internal.h |   11 ++---
 7 files changed, 119 insertions(+), 122 deletions(-)

diff --git a/libfdt/fdt.c b/libfdt/fdt.c
index 18e8d3c..732103b 100644
--- a/libfdt/fdt.c
+++ b/libfdt/fdt.c
@@ -67,7 +67,7 @@ int fdt_check_header(const void *fdt)
 			return -FDT_ERR_BADVERSION;
 		if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION)
 			return -FDT_ERR_BADVERSION;
-	} else if (fdt_magic(fdt) == SW_MAGIC) {
+	} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
 		/* Unfinished sequential-write blob */
 		if (fdt_size_dt_struct(fdt) == 0)
 			return -FDT_ERR_BADSTATE;
@@ -128,7 +128,7 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int *nextoffset)
 	}
 
 	if (nextoffset)
-		*nextoffset = ALIGN(offset, FDT_TAGSIZE);
+		*nextoffset = FDT_TAGALIGN(offset);
 
 	return tag;
 }
@@ -188,14 +188,14 @@ const char *_fdt_find_string(const char *strtab, int tabsize, const char *s)
 	const char *p;
 
 	for (p = strtab; p <= last; p++)
-		if (memeq(p, s, len))
+		if (memcmp(p, s, len) == 0)
 			return p;
 	return NULL;
 }
 
 int fdt_move(const void *fdt, void *buf, int bufsize)
 {
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	if (fdt_totalsize(fdt) > bufsize)
 		return -FDT_ERR_NOSPACE;
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 1c897c5..326d19c 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -59,8 +59,8 @@
 
 #include "libfdt_internal.h"
 
-static int nodename_eq(const void *fdt, int offset,
-		       const char *s, int len)
+static int _fdt_nodename_eq(const void *fdt, int offset,
+			    const char *s, int len)
 {
 	const char *p = fdt_offset_ptr(fdt, offset + FDT_TAGSIZE, len+1);
 
@@ -86,7 +86,7 @@ const char *fdt_string(const void *fdt, int stroffset)
 
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
 {
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 	*address = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->address);
 	*size = fdt64_to_cpu(_fdt_mem_rsv(fdt, n)->size);
 	return 0;
@@ -106,7 +106,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
 {
 	int depth;
 
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	for (depth = 0;
 	     offset >= 0;
@@ -114,7 +114,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int offset,
 		if (depth < 0)
 			return -FDT_ERR_NOTFOUND;
 		else if ((depth == 1)
-			 && nodename_eq(fdt, offset, name, namelen))
+			 && _fdt_nodename_eq(fdt, offset, name, namelen))
 			return offset;
 	}
 
@@ -133,7 +133,7 @@ int fdt_path_offset(const void *fdt, const char *path)
 	const char *p = path;
 	int offset = 0;
 
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	if (*path != '/')
 		return -FDT_ERR_BADPATH;
@@ -214,7 +214,7 @@ const struct fdt_property *fdt_get_property(const void *fdt,
 			if (! prop)
 				goto fail;
 			namestroff = fdt32_to_cpu(prop->nameoff);
-			if (streq(fdt_string(fdt, namestroff), name)) {
+			if (strcmp(fdt_string(fdt, namestroff), name) == 0) {
 				/* Found it! */
 				int len = fdt32_to_cpu(prop->len);
 				prop = fdt_offset_ptr(fdt, offset,
@@ -272,7 +272,7 @@ int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
 	int offset, depth, namelen;
 	const char *name;
 
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	if (buflen < 2)
 		return -FDT_ERR_NOSPACE;
@@ -325,7 +325,7 @@ int fdt_supernode_atdepth_offset(const void *fdt, int nodeoffset,
 	int offset, depth;
 	int supernodeoffset = -FDT_ERR_INTERNAL;
 
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	if (supernodedepth < 0)
 		return -FDT_ERR_NOTFOUND;
@@ -384,7 +384,7 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
 	const void *val;
 	int len;
 
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	/* FIXME: The algorithm here is pretty horrible: we scan each
 	 * property of a node in fdt_getprop(), then if that didn't
@@ -449,7 +449,7 @@ int fdt_node_offset_by_compatible(const void *fdt, int startoffset,
 {
 	int offset, err;
 
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	/* FIXME: The algorithm here is pretty horrible: we scan each
 	 * property of a node in fdt_node_check_compatible(), then if
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 6837fb1..cd06178 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -59,10 +59,10 @@
 
 #include "libfdt_internal.h"
 
-static int _blocks_misordered(const void *fdt,
+static int _fdt_blocks_misordered(const void *fdt,
 			      int mem_rsv_size, int struct_size)
 {
-	return (fdt_off_mem_rsvmap(fdt) < ALIGN(sizeof(struct fdt_header), 8))
+	return (fdt_off_mem_rsvmap(fdt) < FDT_ALIGN(sizeof(struct fdt_header), 8))
 		|| (fdt_off_dt_struct(fdt) <
 		    (fdt_off_mem_rsvmap(fdt) + mem_rsv_size))
 		|| (fdt_off_dt_strings(fdt) <
@@ -71,14 +71,14 @@ static int _blocks_misordered(const void *fdt,
 		    (fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt)));
 }
 
-static int rw_check_header(void *fdt)
+static int _fdt_rw_check_header(void *fdt)
 {
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	if (fdt_version(fdt) < 17)
 		return -FDT_ERR_BADVERSION;
-	if (_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
-			       fdt_size_dt_struct(fdt)))
+	if (_fdt_blocks_misordered(fdt, sizeof(struct fdt_reserve_entry),
+				   fdt_size_dt_struct(fdt)))
 		return -FDT_ERR_BADLAYOUT;
 	if (fdt_version(fdt) > 17)
 		fdt_set_version(fdt, 17);
@@ -86,22 +86,22 @@ static int rw_check_header(void *fdt)
 	return 0;
 }
 
-#define RW_CHECK_HEADER(fdt) \
+#define FDT_RW_CHECK_HEADER(fdt) \
 	{ \
 		int err; \
-		if ((err = rw_check_header(fdt)) != 0) \
+		if ((err = _fdt_rw_check_header(fdt)) != 0) \
 			return err; \
 	}
 
-static inline int _blob_data_size(void *fdt)
+static inline int _fdt_data_size(void *fdt)
 {
 	return fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
 }
 
-static int _blob_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
+static int _fdt_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
 {
 	char *p = splicepoint;
-	char *end = (char *)fdt + _blob_data_size(fdt);
+	char *end = (char *)fdt + _fdt_data_size(fdt);
 
 	if (((p + oldlen) < p) || ((p + oldlen) > end))
 		return -FDT_ERR_BADOFFSET;
@@ -111,12 +111,12 @@ static int _blob_splice(void *fdt, void *splicepoint, int oldlen, int newlen)
 	return 0;
 }
 
-static int _blob_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
-				int oldn, int newn)
+static int _fdt_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
+			       int oldn, int newn)
 {
 	int delta = (newn - oldn) * sizeof(*p);
 	int err;
-	err = _blob_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
+	err = _fdt_splice(fdt, p, oldn * sizeof(*p), newn * sizeof(*p));
 	if (err)
 		return err;
 	fdt_set_off_dt_struct(fdt, fdt_off_dt_struct(fdt) + delta);
@@ -124,13 +124,13 @@ static int _blob_splice_mem_rsv(void *fdt, struct fdt_reserve_entry *p,
 	return 0;
 }
 
-static int _blob_splice_struct(void *fdt, void *p,
-			       int oldlen, int newlen)
+static int _fdt_splice_struct(void *fdt, void *p,
+			      int oldlen, int newlen)
 {
 	int delta = newlen - oldlen;
 	int err;
 
-	if ((err = _blob_splice(fdt, p, oldlen, newlen)))
+	if ((err = _fdt_splice(fdt, p, oldlen, newlen)))
 		return err;
 
 	fdt_set_size_dt_struct(fdt, fdt_size_dt_struct(fdt) + delta);
@@ -138,20 +138,20 @@ static int _blob_splice_struct(void *fdt, void *p,
 	return 0;
 }
 
-static int _blob_splice_string(void *fdt, int newlen)
+static int _fdt_splice_string(void *fdt, int newlen)
 {
 	void *p = (char *)fdt
 		+ fdt_off_dt_strings(fdt) + fdt_size_dt_strings(fdt);
 	int err;
 
-	if ((err = _blob_splice(fdt, p, 0, newlen)))
+	if ((err = _fdt_splice(fdt, p, 0, newlen)))
 		return err;
 
 	fdt_set_size_dt_strings(fdt, fdt_size_dt_strings(fdt) + newlen);
 	return 0;
 }
 
-static int _find_add_string(void *fdt, const char *s)
+static int _fdt_find_add_string(void *fdt, const char *s)
 {
 	char *strtab = (char *)fdt + fdt_off_dt_strings(fdt);
 	const char *p;
@@ -165,7 +165,7 @@ static int _find_add_string(void *fdt, const char *s)
 		return (p - strtab);
 
 	new = strtab + fdt_size_dt_strings(fdt);
-	err = _blob_splice_string(fdt, len);
+	err = _fdt_splice_string(fdt, len);
 	if (err)
 		return err;
 
@@ -178,10 +178,10 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size)
 	struct fdt_reserve_entry *re;
 	int err;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
 	re = _fdt_mem_rsv_w(fdt, fdt_num_mem_rsv(fdt));
-	err = _blob_splice_mem_rsv(fdt, re, 0, 1);
+	err = _fdt_splice_mem_rsv(fdt, re, 0, 1);
 	if (err)
 		return err;
 
@@ -195,19 +195,19 @@ int fdt_del_mem_rsv(void *fdt, int n)
 	struct fdt_reserve_entry *re = _fdt_mem_rsv_w(fdt, n);
 	int err;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
 	if (n >= fdt_num_mem_rsv(fdt))
 		return -FDT_ERR_NOTFOUND;
 
-	err = _blob_splice_mem_rsv(fdt, re, 1, 0);
+	err = _fdt_splice_mem_rsv(fdt, re, 1, 0);
 	if (err)
 		return err;
 	return 0;
 }
 
-static int _resize_property(void *fdt, int nodeoffset, const char *name, int len,
-			    struct fdt_property **prop)
+static int _fdt_resize_property(void *fdt, int nodeoffset, const char *name,
+				int len, struct fdt_property **prop)
 {
 	int oldlen;
 	int err;
@@ -216,17 +216,16 @@ static int _resize_property(void *fdt, int nodeoffset, const char *name, int len
 	if (! (*prop))
 		return oldlen;
 
-	if ((err = _blob_splice_struct(fdt, (*prop)->data,
-				       ALIGN(oldlen, FDT_TAGSIZE),
-				       ALIGN(len, FDT_TAGSIZE))))
+	if ((err = _fdt_splice_struct(fdt, (*prop)->data, FDT_TAGALIGN(oldlen),
+				      FDT_TAGALIGN(len))))
 		return err;
 
 	(*prop)->len = cpu_to_fdt32(len);
 	return 0;
 }
 
-static int _add_property(void *fdt, int nodeoffset, const char *name, int len,
-			 struct fdt_property **prop)
+static int _fdt_add_property(void *fdt, int nodeoffset, const char *name,
+			     int len, struct fdt_property **prop)
 {
 	int proplen;
 	int nextoffset;
@@ -236,14 +235,14 @@ static int _add_property(void *fdt, int nodeoffset, const char *name, int len,
 	if ((nextoffset = _fdt_check_node_offset(fdt, nodeoffset)) < 0)
 		return nextoffset;
 
-	namestroff = _find_add_string(fdt, name);
+	namestroff = _fdt_find_add_string(fdt, name);
 	if (namestroff < 0)
 		return namestroff;
 
 	*prop = _fdt_offset_ptr_w(fdt, nextoffset);
-	proplen = sizeof(**prop) + ALIGN(len, FDT_TAGSIZE);
+	proplen = sizeof(**prop) + FDT_TAGALIGN(len);
 
-	err = _blob_splice_struct(fdt, *prop, 0, proplen);
+	err = _fdt_splice_struct(fdt, *prop, 0, proplen);
 	if (err)
 		return err;
 
@@ -259,7 +258,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
 	int oldlen, newlen;
 	int err;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
 	namep = (char *)(uintptr_t)fdt_get_name(fdt, nodeoffset, &oldlen);
 	if (!namep)
@@ -267,8 +266,8 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
 
 	newlen = strlen(name);
 
-	err = _blob_splice_struct(fdt, namep, ALIGN(oldlen+1, FDT_TAGSIZE),
-				  ALIGN(newlen+1, FDT_TAGSIZE));
+	err = _fdt_splice_struct(fdt, namep, FDT_TAGALIGN(oldlen+1),
+				 FDT_TAGALIGN(newlen+1));
 	if (err)
 		return err;
 
@@ -282,11 +281,11 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 	struct fdt_property *prop;
 	int err;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
-	err = _resize_property(fdt, nodeoffset, name, len, &prop);
+	err = _fdt_resize_property(fdt, nodeoffset, name, len, &prop);
 	if (err == -FDT_ERR_NOTFOUND)
-		err = _add_property(fdt, nodeoffset, name, len, &prop);
+		err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
 	if (err)
 		return err;
 
@@ -299,14 +298,14 @@ int fdt_delprop(void *fdt, int nodeoffset, const char *name)
 	struct fdt_property *prop;
 	int len, proplen;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
 	prop = fdt_get_property_w(fdt, nodeoffset, name, &len);
 	if (! prop)
 		return len;
 
-	proplen = sizeof(*prop) + ALIGN(len, FDT_TAGSIZE);
-	return _blob_splice_struct(fdt, prop, proplen, 0);
+	proplen = sizeof(*prop) + FDT_TAGALIGN(len);
+	return _fdt_splice_struct(fdt, prop, proplen, 0);
 }
 
 int fdt_add_subnode_namelen(void *fdt, int parentoffset,
@@ -319,7 +318,7 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	uint32_t tag;
 	uint32_t *endtag;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
 	offset = fdt_subnode_offset_namelen(fdt, parentoffset, name, namelen);
 	if (offset >= 0)
@@ -335,14 +334,14 @@ int fdt_add_subnode_namelen(void *fdt, int parentoffset,
 	} while ((tag == FDT_PROP) || (tag == FDT_NOP));
 
 	nh = _fdt_offset_ptr_w(fdt, offset);
-	nodelen = sizeof(*nh) + ALIGN(namelen+1, FDT_TAGSIZE) + FDT_TAGSIZE;
+	nodelen = sizeof(*nh) + FDT_TAGALIGN(namelen+1) + FDT_TAGSIZE;
 
-	err = _blob_splice_struct(fdt, nh, 0, nodelen);
+	err = _fdt_splice_struct(fdt, nh, 0, nodelen);
 	if (err)
 		return err;
 
 	nh->tag = cpu_to_fdt32(FDT_BEGIN_NODE);
-	memset(nh->name, 0, ALIGN(namelen+1, FDT_TAGSIZE));
+	memset(nh->name, 0, FDT_TAGALIGN(namelen+1));
 	memcpy(nh->name, name, namelen);
 	endtag = (uint32_t *)((char *)nh + nodelen - FDT_TAGSIZE);
 	*endtag = cpu_to_fdt32(FDT_END_NODE);
@@ -359,22 +358,22 @@ int fdt_del_node(void *fdt, int nodeoffset)
 {
 	int endoffset;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
 	endoffset = _fdt_node_end_offset(fdt, nodeoffset);
 	if (endoffset < 0)
 		return endoffset;
 
-	return _blob_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset),
-				   endoffset - nodeoffset, 0);
+	return _fdt_splice_struct(fdt, _fdt_offset_ptr_w(fdt, nodeoffset),
+				  endoffset - nodeoffset, 0);
 }
 
-static void _packblocks(const char *old, char *new,
-		       int mem_rsv_size, int struct_size)
+static void _fdt_packblocks(const char *old, char *new,
+			    int mem_rsv_size, int struct_size)
 {
 	int mem_rsv_off, struct_off, strings_off;
 
-	mem_rsv_off = ALIGN(sizeof(struct fdt_header), 8);
+	mem_rsv_off = FDT_ALIGN(sizeof(struct fdt_header), 8);
 	struct_off = mem_rsv_off + mem_rsv_size;
 	strings_off = struct_off + struct_size;
 
@@ -400,7 +399,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 	const char *fdtend = fdtstart + fdt_totalsize(fdt);
 	char *tmp;
 
-	CHECK_HEADER(fdt);
+	FDT_CHECK_HEADER(fdt);
 
 	mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
 		* sizeof(struct fdt_reserve_entry);
@@ -413,7 +412,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 			;
 	}
 
-	if (!_blocks_misordered(fdt, mem_rsv_size, struct_size)) {
+	if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) {
 		/* no further work necessary */
 		err = fdt_move(fdt, buf, bufsize);
 		if (err)
@@ -425,7 +424,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 	}
 
 	/* Need to reorder */
-	newsize = ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size
+	newsize = FDT_ALIGN(sizeof(struct fdt_header), 8) + mem_rsv_size
 		+ struct_size + fdt_size_dt_strings(fdt);
 
 	if (bufsize < newsize)
@@ -441,7 +440,7 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 			return -FDT_ERR_NOSPACE;
 	}
 
-	_packblocks(fdt, tmp, mem_rsv_size, struct_size);
+	_fdt_packblocks(fdt, tmp, mem_rsv_size, struct_size);
 	memmove(buf, tmp, newsize);
 
 	fdt_set_magic(buf, FDT_MAGIC);
@@ -457,12 +456,12 @@ int fdt_pack(void *fdt)
 {
 	int mem_rsv_size;
 
-	RW_CHECK_HEADER(fdt);
+	FDT_RW_CHECK_HEADER(fdt);
 
 	mem_rsv_size = (fdt_num_mem_rsv(fdt)+1)
 		* sizeof(struct fdt_reserve_entry);
-	_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
-	fdt_set_totalsize(fdt, _blob_data_size(fdt));
+	_fdt_packblocks(fdt, fdt, mem_rsv_size, fdt_size_dt_struct(fdt));
+	fdt_set_totalsize(fdt, _fdt_data_size(fdt));
 
 	return 0;
 }
diff --git a/libfdt/fdt_strerror.c b/libfdt/fdt_strerror.c
index abf792e..9b00c3a 100644
--- a/libfdt/fdt_strerror.c
+++ b/libfdt/fdt_strerror.c
@@ -59,29 +59,29 @@
 
 #include "libfdt_internal.h"
 
-struct errtabent {
+struct fdt_errtabent {
 	const char *str;
 };
 
-#define ERRTABENT(val) \
+#define FDT_ERRTABENT(val) \
 	[(val)] = { .str = #val, }
 
-static struct errtabent errtable[] = {
-	ERRTABENT(FDT_ERR_NOTFOUND),
-	ERRTABENT(FDT_ERR_EXISTS),
-	ERRTABENT(FDT_ERR_NOSPACE),
+static struct fdt_errtabent fdt_errtable[] = {
+	FDT_ERRTABENT(FDT_ERR_NOTFOUND),
+	FDT_ERRTABENT(FDT_ERR_EXISTS),
+	FDT_ERRTABENT(FDT_ERR_NOSPACE),
 
-	ERRTABENT(FDT_ERR_BADOFFSET),
-	ERRTABENT(FDT_ERR_BADPATH),
-	ERRTABENT(FDT_ERR_BADSTATE),
+	FDT_ERRTABENT(FDT_ERR_BADOFFSET),
+	FDT_ERRTABENT(FDT_ERR_BADPATH),
+	FDT_ERRTABENT(FDT_ERR_BADSTATE),
 
-	ERRTABENT(FDT_ERR_TRUNCATED),
-	ERRTABENT(FDT_ERR_BADMAGIC),
-	ERRTABENT(FDT_ERR_BADVERSION),
-	ERRTABENT(FDT_ERR_BADSTRUCTURE),
-	ERRTABENT(FDT_ERR_BADLAYOUT),
+	FDT_ERRTABENT(FDT_ERR_TRUNCATED),
+	FDT_ERRTABENT(FDT_ERR_BADMAGIC),
+	FDT_ERRTABENT(FDT_ERR_BADVERSION),
+	FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
+	FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
 };
-#define ERRTABSIZE	(sizeof(errtable) / sizeof(errtable[0]))
+#define FDT_ERRTABSIZE	(sizeof(fdt_errtable) / sizeof(fdt_errtable[0]))
 
 const char *fdt_strerror(int errval)
 {
@@ -89,8 +89,8 @@ const char *fdt_strerror(int errval)
 		return "<valid offset/length>";
 	else if (errval == 0)
 		return "<no error>";
-	else if (errval > -ERRTABSIZE) {
-		const char *s = errtable[-errval].str;
+	else if (errval > -FDT_ERRTABSIZE) {
+		const char *s = fdt_errtable[-errval].str;
 
 		if (s)
 			return s;
diff --git a/libfdt/fdt_sw.c b/libfdt/fdt_sw.c
index 92f8f0b..698329e 100644
--- a/libfdt/fdt_sw.c
+++ b/libfdt/fdt_sw.c
@@ -55,22 +55,22 @@
 
 #include "libfdt_internal.h"
 
-static int sw_check_header(void *fdt)
+static int _fdt_sw_check_header(void *fdt)
 {
-	if (fdt_magic(fdt) != SW_MAGIC)
+	if (fdt_magic(fdt) != FDT_SW_MAGIC)
 		return -FDT_ERR_BADMAGIC;
 	/* FIXME: should check more details about the header state */
 	return 0;
 }
 
-#define SW_CHECK_HEADER(fdt) \
+#define FDT_SW_CHECK_HEADER(fdt) \
 	{ \
 		int err; \
-		if ((err = sw_check_header(fdt)) != 0) \
+		if ((err = _fdt_sw_check_header(fdt)) != 0) \
 			return err; \
 	}
 
-static void *grab_space(void *fdt, int len)
+static void *_fdt_grab_space(void *fdt, int len)
 {
 	int offset = fdt_size_dt_struct(fdt);
 	int spaceleft;
@@ -94,13 +94,13 @@ int fdt_create(void *buf, int bufsize)
 
 	memset(buf, 0, bufsize);
 
-	fdt_set_magic(fdt, SW_MAGIC);
+	fdt_set_magic(fdt, FDT_SW_MAGIC);
 	fdt_set_version(fdt, FDT_LAST_SUPPORTED_VERSION);
 	fdt_set_last_comp_version(fdt, FDT_FIRST_SUPPORTED_VERSION);
 	fdt_set_totalsize(fdt,  bufsize);
 
-	fdt_set_off_mem_rsvmap(fdt, ALIGN(sizeof(struct fdt_header),
-					  sizeof(struct fdt_reserve_entry)));
+	fdt_set_off_mem_rsvmap(fdt, FDT_ALIGN(sizeof(struct fdt_header),
+					      sizeof(struct fdt_reserve_entry)));
 	fdt_set_off_dt_struct(fdt, fdt_off_mem_rsvmap(fdt));
 	fdt_set_off_dt_strings(fdt, bufsize);
 
@@ -112,7 +112,7 @@ int fdt_add_reservemap_entry(void *fdt, uint64_t addr, uint64_t size)
 	struct fdt_reserve_entry *re;
 	int offset;
 
-	SW_CHECK_HEADER(fdt);
+	FDT_SW_CHECK_HEADER(fdt);
 
 	if (fdt_size_dt_struct(fdt))
 		return -FDT_ERR_BADSTATE;
@@ -140,9 +140,9 @@ int fdt_begin_node(void *fdt, const char *name)
 	struct fdt_node_header *nh;
 	int namelen = strlen(name) + 1;
 
-	SW_CHECK_HEADER(fdt);
+	FDT_SW_CHECK_HEADER(fdt);
 
-	nh = grab_space(fdt, sizeof(*nh) + ALIGN(namelen, FDT_TAGSIZE));
+	nh = _fdt_grab_space(fdt, sizeof(*nh) + FDT_TAGALIGN(namelen));
 	if (! nh)
 		return -FDT_ERR_NOSPACE;
 
@@ -155,9 +155,9 @@ int fdt_end_node(void *fdt)
 {
 	uint32_t *en;
 
-	SW_CHECK_HEADER(fdt);
+	FDT_SW_CHECK_HEADER(fdt);
 
-	en = grab_space(fdt, FDT_TAGSIZE);
+	en = _fdt_grab_space(fdt, FDT_TAGSIZE);
 	if (! en)
 		return -FDT_ERR_NOSPACE;
 
@@ -165,7 +165,7 @@ int fdt_end_node(void *fdt)
 	return 0;
 }
 
-static int find_add_string(void *fdt, const char *s)
+static int _fdt_find_add_string(void *fdt, const char *s)
 {
 	char *strtab = (char *)fdt + fdt_totalsize(fdt);
 	const char *p;
@@ -193,13 +193,13 @@ int fdt_property(void *fdt, const char *name, const void *val, int len)
 	struct fdt_property *prop;
 	int nameoff;
 
-	SW_CHECK_HEADER(fdt);
+	FDT_SW_CHECK_HEADER(fdt);
 
-	nameoff = find_add_string(fdt, name);
+	nameoff = _fdt_find_add_string(fdt, name);
 	if (nameoff == 0)
 		return -FDT_ERR_NOSPACE;
 
-	prop = grab_space(fdt, sizeof(*prop) + ALIGN(len, FDT_TAGSIZE));
+	prop = _fdt_grab_space(fdt, sizeof(*prop) + FDT_TAGALIGN(len));
 	if (! prop)
 		return -FDT_ERR_NOSPACE;
 
@@ -218,10 +218,10 @@ int fdt_finish(void *fdt)
 	uint32_t tag;
 	int offset, nextoffset;
 
-	SW_CHECK_HEADER(fdt);
+	FDT_SW_CHECK_HEADER(fdt);
 
 	/* Add terminator */
-	end = grab_space(fdt, sizeof(*end));
+	end = _fdt_grab_space(fdt, sizeof(*end));
 	if (! end)
 		return -FDT_ERR_NOSPACE;
 	*end = cpu_to_fdt32(FDT_END);
diff --git a/libfdt/fdt_wip.c b/libfdt/fdt_wip.c
index b336113..e30c81d 100644
--- a/libfdt/fdt_wip.c
+++ b/libfdt/fdt_wip.c
@@ -76,7 +76,7 @@ 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;
 
@@ -93,7 +93,7 @@ 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;
 }
@@ -143,6 +143,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;
 }
diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
index 549e345..46eb93e 100644
--- a/libfdt/libfdt_internal.h
+++ b/libfdt/libfdt_internal.h
@@ -52,13 +52,10 @@
  */
 #include <fdt.h>
 
-#define ALIGN(x, a)	(((x) + (a) - 1) & ~((a) - 1))
-#define PALIGN(p, a)	((void *)ALIGN((unsigned long)(p), (a)))
+#define FDT_ALIGN(x, a)		(((x) + (a) - 1) & ~((a) - 1))
+#define FDT_TAGALIGN(x)		(FDT_ALIGN((x), FDT_TAGSIZE))
 
-#define memeq(p, q, n)	(memcmp((p), (q), (n)) == 0)
-#define streq(p, q)	(strcmp((p), (q)) == 0)
-
-#define CHECK_HEADER(fdt) \
+#define FDT_CHECK_HEADER(fdt) \
 	{ \
 		int err; \
 		if ((err = fdt_check_header(fdt)) != 0) \
@@ -93,6 +90,6 @@ static inline struct fdt_reserve_entry *_fdt_mem_rsv_w(void *fdt, int n)
 	return (void *)(uintptr_t)_fdt_mem_rsv(fdt, n);
 }
 
-#define SW_MAGIC		(~FDT_MAGIC)
+#define FDT_SW_MAGIC		(~FDT_MAGIC)
 
 #endif /* _LIBFDT_INTERNAL_H */
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 4/7] libfdt: Improve documentation in libfdt.h
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
                   ` (2 preceding siblings ...)
  2008-08-20  2:30 ` [U-Boot] [PATCH 3/7] libfdt: Increase namespace-pollution paranoia gvb.uboot at gmail.com
@ 2008-08-20  2:30 ` gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 5/7] libfdt: Forgot one function when cleaning the namespace gvb.uboot at gmail.com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

From: Wolfram Sang <w.sang@pengutronix.de>

Fix a few typos and mistakes.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
---
 include/libfdt.h |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index 7e043ef..0747981 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -213,7 +213,7 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
 /**********************************************************************/
 
 /**
- * fdt_string - retreive a string from the strings block of a device tree
+ * fdt_string - retrieve a string from the strings block of a device tree
  * @fdt: pointer to the device tree blob
  * @stroffset: offset of the string within the strings block (native endian)
  *
@@ -227,7 +227,7 @@ int fdt_move(const void *fdt, void *buf, int bufsize);
 const char *fdt_string(const void *fdt, int stroffset);
 
 /**
- * fdt_num_mem_rsv - retreive the number of memory reserve map entries
+ * fdt_num_mem_rsv - retrieve the number of memory reserve map entries
  * @fdt: pointer to the device tree blob
  *
  * Returns the number of entries in the device tree blob's memory
@@ -240,7 +240,7 @@ const char *fdt_string(const void *fdt, int stroffset);
 int fdt_num_mem_rsv(const void *fdt);
 
 /**
- * fdt_get_mem_rsv - retreive one memory reserve map entry
+ * fdt_get_mem_rsv - retrieve one memory reserve map entry
  * @fdt: pointer to the device tree blob
  * @address, @size: pointers to 64-bit variables
  *
@@ -320,7 +320,7 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, const char *name);
 int fdt_path_offset(const void *fdt, const char *path);
 
 /**
- * fdt_get_name - retreive the name of a given node
+ * fdt_get_name - retrieve the name of a given node
  * @fdt: pointer to the device tree blob
  * @nodeoffset: structure block offset of the starting node
  * @lenp: pointer to an integer variable (will be overwritten) or NULL
@@ -352,7 +352,7 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
  * fdt_get_property() retrieves a pointer to the fdt_property
  * structure within the device tree blob corresponding to the property
  * named 'name' of the node at offset nodeoffset.  If lenp is
- * non-NULL, the length of the property value also returned, in the
+ * non-NULL, the length of the property value is also returned, in the
  * integer pointed to by lenp.
  *
  * returns:
@@ -389,7 +389,7 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
  * fdt_getprop() retrieves a pointer to the value of the property
  * named 'name' of the node at offset nodeoffset (this will be a
  * pointer to within the device blob itself, not a copy of the value).
- * If lenp is non-NULL, the length of the property value also
+ * If lenp is non-NULL, the length of the property value is also
  * returned, in the integer pointed to by lenp.
  *
  * returns:
@@ -415,7 +415,7 @@ static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
 }
 
 /**
- * fdt_get_phandle - retreive the phandle of a given node
+ * fdt_get_phandle - retrieve the phandle of a given node
  * @fdt: pointer to the device tree blob
  * @nodeoffset: structure block offset of the node
  *
@@ -423,7 +423,7 @@ static inline void *fdt_getprop_w(void *fdt, int nodeoffset,
  * structure block offset nodeoffset.
  *
  * returns:
- *	the phandle of the node at nodeoffset, on succes (!= 0, != -1)
+ *	the phandle of the node at nodeoffset, on success (!= 0, != -1)
  *	0, if the node has no phandle, or another error occurs
  */
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset);
@@ -522,7 +522,7 @@ int fdt_node_depth(const void *fdt, int nodeoffset);
  * structure from the start to nodeoffset, *twice*.
  *
  * returns:
- *	stucture block offset of the parent of the node at nodeoffset
+ *	structure block offset of the parent of the node at nodeoffset
  *		(>=0), on success
  *	-FDT_ERR_BADOFFSET, nodeoffset does not refer to a BEGIN_NODE tag
  *	-FDT_ERR_BADMAGIC,
@@ -579,7 +579,7 @@ int fdt_node_offset_by_prop_value(const void *fdt, int startoffset,
  * @fdt: pointer to the device tree blob
  * @phandle: phandle value
  *
- * fdt_node_offset_by_prop_value() returns the offset of the node
+ * fdt_node_offset_by_phandle() returns the offset of the node
  * which has the given phandle value.  If there is more than one node
  * in the tree with the given phandle (an invalid tree), results are
  * undefined.
@@ -806,13 +806,13 @@ int fdt_pack(void *fdt);
 /**
  * fdt_add_mem_rsv - add one memory reserve map entry
  * @fdt: pointer to the device tree blob
- * @addres, @size: 64-bit values (native endian)
+ * @address, @size: 64-bit values (native endian)
  *
  * Adds a reserve map entry to the given blob reserving a region at
  * address address of length size.
  *
  * This function will insert data into the reserve map and will
- * therfore change the indexes of some entries in the table.
+ * therefore change the indexes of some entries in the table.
  *
  * returns:
  *	0, on success
@@ -836,7 +836,7 @@ int fdt_add_mem_rsv(void *fdt, uint64_t address, uint64_t size);
  * the blob.
  *
  * This function will delete data from the reservation table and will
- * therfore change the indexes of some entries in the table.
+ * therefore change the indexes of some entries in the table.
  *
  * returns:
  *	0, on success
@@ -886,7 +886,7 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name);
  * @len: length of the property value
  *
  * fdt_setprop() sets the value of the named property in the given
- * node to the given value and length, creeating the property if it
+ * node to the given value and length, creating the property if it
  * does not already exist.
  *
  * This function may insert or delete data from the blob, and will
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 5/7] libfdt: Forgot one function when cleaning the namespace
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
                   ` (3 preceding siblings ...)
  2008-08-20  2:30 ` [U-Boot] [PATCH 4/7] libfdt: Improve documentation in libfdt.h gvb.uboot at gmail.com
@ 2008-08-20  2:30 ` gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 6/7] libfdt: Implement fdt_get_property_namelen() and fdt_getprop_namelen() gvb.uboot at gmail.com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

From: David Gibson <david@gibson.dropbear.id.au>

In commit b6d80a20fc293f3b995c3ce1a6744a5574192125, we renamed all
libfdt functions to be prefixed with fdt_ or _fdt_ to minimise the
chance of collisions with things from whatever package libfdt is
embedded in, pulled into the libfdt build via that environment's
libfdt_env.h.

Except... I missed one.  This patch applies the same treatment to
_stringlist_contains().  While we're at it, also make it static since
it's only used in the same file.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 libfdt/fdt_ro.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 326d19c..6292a00 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -412,7 +412,8 @@ int fdt_node_offset_by_phandle(const void *fdt, uint32_t phandle)
 					     &phandle, sizeof(phandle));
 }
 
-int _stringlist_contains(const char *strlist, int listlen, const char *str)
+static int _fdt_stringlist_contains(const char *strlist, int listlen,
+				    const char *str)
 {
 	int len = strlen(str);
 	const char *p;
@@ -438,7 +439,7 @@ int fdt_node_check_compatible(const void *fdt, int nodeoffset,
 	prop = fdt_getprop(fdt, nodeoffset, "compatible", &len);
 	if (!prop)
 		return len;
-	if (_stringlist_contains(prop, len, compatible))
+	if (_fdt_stringlist_contains(prop, len, compatible))
 		return 0;
 	else
 		return 1;
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 6/7] libfdt: Implement fdt_get_property_namelen() and fdt_getprop_namelen()
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
                   ` (4 preceding siblings ...)
  2008-08-20  2:30 ` [U-Boot] [PATCH 5/7] libfdt: Forgot one function when cleaning the namespace gvb.uboot at gmail.com
@ 2008-08-20  2:30 ` gvb.uboot at gmail.com
  2008-08-20  2:30 ` [U-Boot] [PATCH 7/7] libfdt: Add support for using aliases in fdt_path_offset() gvb.uboot at gmail.com
  2008-08-21  1:45 ` [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt Jerry Van Baren
  7 siblings, 0 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

From: David Gibson <david@gibson.dropbear.id.au>

As well as fdt_subnode_offset(), libfdt includes an
fdt_subnode_offset_namelen() function that takes the subnode name to
look up not as a NUL-terminated string, but as a string with an
explicit length.  This can be useful when the caller has the name as
part of a longer string, such as a full path.

However, we don't have corresponding 'namelen' versions for
fdt_get_property() and fdt_getprop().  There are less obvious use
cases for these variants on property names, but there are
circumstances where they can be useful e.g. looking up property names
which need to be parsed from a longer string buffer such as user input
or a configuration file, or looking up an alias in a path with
IEEE1275 style aliases.

So, since it's very easy to implement such variants, this patch does
so.  The original NUL-terminated variants are, of course, implemented
in terms of the namelen versions.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 include/libfdt.h |   30 ++++++++++++++++++++++++++++++
 libfdt/fdt_ro.c  |   37 ++++++++++++++++++++++++++++++-------
 2 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/include/libfdt.h b/include/libfdt.h
index 0747981..94c35e3 100644
--- a/include/libfdt.h
+++ b/include/libfdt.h
@@ -343,6 +343,22 @@ int fdt_path_offset(const void *fdt, const char *path);
 const char *fdt_get_name(const void *fdt, int nodeoffset, int *lenp);
 
 /**
+ * fdt_get_property_namelen - find a property based on substring
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to find
+ * @name: name of the property to find
+ * @namelen: number of characters of name to consider
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * Identical to fdt_get_property_namelen(), but only examine the first
+ * namelen characters of name for matching the property name.
+ */
+const struct fdt_property *fdt_get_property_namelen(const void *fdt,
+						    int nodeoffset,
+						    const char *name,
+						    int namelen, int *lenp);
+
+/**
  * fdt_get_property - find a given property in a given node
  * @fdt: pointer to the device tree blob
  * @nodeoffset: offset of the node whose property to find
@@ -380,6 +396,20 @@ static inline struct fdt_property *fdt_get_property_w(void *fdt, int nodeoffset,
 }
 
 /**
+ * fdt_getprop_namelen - get property value based on substring
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to find
+ * @name: name of the property to find
+ * @namelen: number of characters of name to consider
+ * @lenp: pointer to an integer variable (will be overwritten) or NULL
+ *
+ * Identical to fdt_getprop(), but only examine the first namelen
+ * characters of name for matching the property name.
+ */
+const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
+				const char *name, int namelen, int *lenp);
+
+/**
  * fdt_getprop - retrieve the value of a given property
  * @fdt: pointer to the device tree blob
  * @nodeoffset: offset of the node whose property to find
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index 6292a00..d566eba 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -84,6 +84,14 @@ const char *fdt_string(const void *fdt, int stroffset)
 	return (const char *)fdt + fdt_off_dt_strings(fdt) + stroffset;
 }
 
+static int _fdt_string_eq(const void *fdt, int stroffset,
+			  const char *s, int len)
+{
+	const char *p = fdt_string(fdt, stroffset);
+
+	return (strlen(p) == len) && (memcmp(p, s, len) == 0);
+}
+
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
 {
 	FDT_CHECK_HEADER(fdt);
@@ -179,9 +187,10 @@ const char *fdt_get_name(const void *fdt, int nodeoffset, int *len)
 	return NULL;
 }
 
-const struct fdt_property *fdt_get_property(const void *fdt,
-					    int nodeoffset,
-					    const char *name, int *lenp)
+const struct fdt_property *fdt_get_property_namelen(const void *fdt,
+						    int nodeoffset,
+						    const char *name,
+						    int namelen, int *lenp)
 {
 	uint32_t tag;
 	const struct fdt_property *prop;
@@ -214,7 +223,7 @@ const struct fdt_property *fdt_get_property(const void *fdt,
 			if (! prop)
 				goto fail;
 			namestroff = fdt32_to_cpu(prop->nameoff);
-			if (strcmp(fdt_string(fdt, namestroff), name) == 0) {
+			if (_fdt_string_eq(fdt, namestroff, name, namelen)) {
 				/* Found it! */
 				int len = fdt32_to_cpu(prop->len);
 				prop = fdt_offset_ptr(fdt, offset,
@@ -242,18 +251,32 @@ const struct fdt_property *fdt_get_property(const void *fdt,
 	return NULL;
 }
 
-const void *fdt_getprop(const void *fdt, int nodeoffset,
-		  const char *name, int *lenp)
+const struct fdt_property *fdt_get_property(const void *fdt,
+					    int nodeoffset,
+					    const char *name, int *lenp)
+{
+	return fdt_get_property_namelen(fdt, nodeoffset, name,
+					strlen(name), lenp);
+}
+
+const void *fdt_getprop_namelen(const void *fdt, int nodeoffset,
+				const char *name, int namelen, int *lenp)
 {
 	const struct fdt_property *prop;
 
-	prop = fdt_get_property(fdt, nodeoffset, name, lenp);
+	prop = fdt_get_property_namelen(fdt, nodeoffset, name, namelen, lenp);
 	if (! prop)
 		return NULL;
 
 	return prop->data;
 }
 
+const void *fdt_getprop(const void *fdt, int nodeoffset,
+			const char *name, int *lenp)
+{
+	return fdt_getprop_namelen(fdt, nodeoffset, name, strlen(name), lenp);
+}
+
 uint32_t fdt_get_phandle(const void *fdt, int nodeoffset)
 {
 	const uint32_t *php;
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 7/7] libfdt: Add support for using aliases in fdt_path_offset()
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
                   ` (5 preceding siblings ...)
  2008-08-20  2:30 ` [U-Boot] [PATCH 6/7] libfdt: Implement fdt_get_property_namelen() and fdt_getprop_namelen() gvb.uboot at gmail.com
@ 2008-08-20  2:30 ` gvb.uboot at gmail.com
  2008-08-21  1:45 ` [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt Jerry Van Baren
  7 siblings, 0 replies; 11+ messages in thread
From: gvb.uboot at gmail.com @ 2008-08-20  2:30 UTC (permalink / raw)
  To: u-boot

From: Kumar Gala <galak@kernel.crashing.org>

If the path doesn't start with '/' check to see if it matches some alias
under "/aliases" and substitute the matching alias value in the path
and retry the lookup.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
---
 libfdt/fdt_ro.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c
index d566eba..b09a6e9 100644
--- a/libfdt/fdt_ro.c
+++ b/libfdt/fdt_ro.c
@@ -143,8 +143,25 @@ int fdt_path_offset(const void *fdt, const char *path)
 
 	FDT_CHECK_HEADER(fdt);
 
-	if (*path != '/')
-		return -FDT_ERR_BADPATH;
+	/* see if we have an alias */
+	if (*path != '/') {
+		const char *q;
+		int aliasoffset = fdt_path_offset(fdt, "/aliases");
+
+		if (aliasoffset < 0)
+			return -FDT_ERR_BADPATH;
+
+		q = strchr(path, '/');
+		if (!q)
+			q = end;
+
+		p = fdt_getprop_namelen(fdt, aliasoffset, path, q - p, NULL);
+		if (!p)
+			return -FDT_ERR_BADPATH;
+		offset = fdt_path_offset(fdt, p);
+
+		p = q;
+	}
 
 	while (*p) {
 		const char *q;
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt
  2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
                   ` (6 preceding siblings ...)
  2008-08-20  2:30 ` [U-Boot] [PATCH 7/7] libfdt: Add support for using aliases in fdt_path_offset() gvb.uboot at gmail.com
@ 2008-08-21  1:45 ` Jerry Van Baren
  2008-08-21  1:51   ` David Gibson
  7 siblings, 1 reply; 11+ messages in thread
From: Jerry Van Baren @ 2008-08-21  1:45 UTC (permalink / raw)
  To: u-boot

gvb.uboot at gmail.com wrote:
> The following changesets resynchronize u-boot with the master libfdt.
> 
> Best regards,
> gvb

First results using aliases with David's libfdt improvements...

These are the aliases:

=> fdt p /aliases
aliases {
         ethernet0 = "/qe at e0100000/ucc at 2000";
         ethernet1 = "/qe at e0100000/ucc at 3000";
         serial0 = "/soc8360 at e0000000/serial at 4500";
         serial1 = "/soc8360 at e0000000/serial at 4600";
         pci0 = "/pci at e0008500";
};

Dereference an alias by not using the '/' prefix per OF conventions:

=> fdt print ethernet0
ucc at 2000 {
         device_type = "network";
         compatible = "ucc_geth";
         cell-index = <0x1>;
         reg = <0x2000 0x200>;
         interrupts = <0x20>;
         interrupt-parent = <0x2>;
         local-mac-address = [00 00 00 00 00 00];
         rx-clock-name = "none";
         tx-clock-name = "clk9";
         phy-handle = <0x3>;
         phy-connection-type = "rgmii-id";
         pio-handle = <0x4>;
};

Whooo-heeee!

Dereference the ethernet0 alias and print a property:

=> fdt print ethernet0/phy-connection-type
libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND

Doh doh doh!  :-)  Pretty close, though.  I'll have to dig into this a 
bit more to see why the alias expansion doesn't seem to work with 
properties, check how it behaves with nested nodes (maybe).

I've rebased u-boot-fdt against u-boot and pushed David's (and other's) 
libfdt improvements to u-boot-fdt.  This is *NOT* ready to be merged 
into the mainline, but I've made it available in case others want to 
play with it.

Warning: I will be rebasing u-boot-fdt as Wolfgang merges more changes 
into the mainline.  I have not seen problems with rebasing, but YMMV.

Best regards,
gvb

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt
  2008-08-21  1:45 ` [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt Jerry Van Baren
@ 2008-08-21  1:51   ` David Gibson
  2008-08-21  2:08     ` Jerry Van Baren
  0 siblings, 1 reply; 11+ messages in thread
From: David Gibson @ 2008-08-21  1:51 UTC (permalink / raw)
  To: u-boot

On Wed, Aug 20, 2008 at 09:45:04PM -0400, Jerry Van Baren wrote:
> gvb.uboot at gmail.com wrote:
>> The following changesets resynchronize u-boot with the master libfdt.
>>
>> Best regards,
>> gvb
>
> First results using aliases with David's libfdt improvements...
>
> These are the aliases:
>
> => fdt p /aliases
> aliases {
>         ethernet0 = "/qe at e0100000/ucc at 2000";
>         ethernet1 = "/qe at e0100000/ucc at 3000";
>         serial0 = "/soc8360 at e0000000/serial at 4500";
>         serial1 = "/soc8360 at e0000000/serial at 4600";
>         pci0 = "/pci at e0008500";
> };
>
> Dereference an alias by not using the '/' prefix per OF conventions:
>
> => fdt print ethernet0
> ucc at 2000 {
>         device_type = "network";
>         compatible = "ucc_geth";
>         cell-index = <0x1>;
>         reg = <0x2000 0x200>;
>         interrupts = <0x20>;
>         interrupt-parent = <0x2>;
>         local-mac-address = [00 00 00 00 00 00];
>         rx-clock-name = "none";
>         tx-clock-name = "clk9";
>         phy-handle = <0x3>;
>         phy-connection-type = "rgmii-id";
>         pio-handle = <0x4>;
> };
>
> Whooo-heeee!
>
> Dereference the ethernet0 alias and print a property:
>
> => fdt print ethernet0/phy-connection-type
> libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND

Uh... didn't I talk you out of this broken path-to-property stuff way
back when?

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt
  2008-08-21  1:51   ` David Gibson
@ 2008-08-21  2:08     ` Jerry Van Baren
  0 siblings, 0 replies; 11+ messages in thread
From: Jerry Van Baren @ 2008-08-21  2:08 UTC (permalink / raw)
  To: u-boot

David Gibson wrote:
> On Wed, Aug 20, 2008 at 09:45:04PM -0400, Jerry Van Baren wrote:
>> gvb.uboot at gmail.com wrote:
>>> The following changesets resynchronize u-boot with the master libfdt.
>>>
>>> Best regards,
>>> gvb
>> First results using aliases with David's libfdt improvements...
>>
>> These are the aliases:
>>
>> => fdt p /aliases
>> aliases {
>>         ethernet0 = "/qe at e0100000/ucc at 2000";
>>         ethernet1 = "/qe at e0100000/ucc at 3000";
>>         serial0 = "/soc8360 at e0000000/serial at 4500";
>>         serial1 = "/soc8360 at e0000000/serial at 4600";
>>         pci0 = "/pci at e0008500";
>> };
>>
>> Dereference an alias by not using the '/' prefix per OF conventions:
>>
>> => fdt print ethernet0
>> ucc at 2000 {
>>         device_type = "network";
>>         compatible = "ucc_geth";
>>         cell-index = <0x1>;
>>         reg = <0x2000 0x200>;
>>         interrupts = <0x20>;
>>         interrupt-parent = <0x2>;
>>         local-mac-address = [00 00 00 00 00 00];
>>         rx-clock-name = "none";
>>         tx-clock-name = "clk9";
>>         phy-handle = <0x3>;
>>         phy-connection-type = "rgmii-id";
>>         pio-handle = <0x4>;
>> };
>>
>> Whooo-heeee!
>>
>> Dereference the ethernet0 alias and print a property:
>>
>> => fdt print ethernet0/phy-connection-type
>> libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND
> 
> Uh... didn't I talk you out of this broken path-to-property stuff way
> back when?

Dang, you are quick.  I just realized that myself.  The alias 
dereference *IS* working as expected.

As you point out, the proper syntax is path <space> property:
=> fdt print ethernet0 phy-connection-type
device_type = "network"

which works just fine.

Thanks!
gvb

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-08-21  2:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-20  2:30 [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt gvb.uboot at gmail.com
2008-08-20  2:30 ` [U-Boot] [PATCH 1/7] dtc: Enable and fix -Wpointer-arith warnings gvb.uboot at gmail.com
2008-08-20  2:30 ` [U-Boot] [PATCH 2/7] dtc: Enable and fix -Wcast-qual warnings gvb.uboot at gmail.com
2008-08-20  2:30 ` [U-Boot] [PATCH 3/7] libfdt: Increase namespace-pollution paranoia gvb.uboot at gmail.com
2008-08-20  2:30 ` [U-Boot] [PATCH 4/7] libfdt: Improve documentation in libfdt.h gvb.uboot at gmail.com
2008-08-20  2:30 ` [U-Boot] [PATCH 5/7] libfdt: Forgot one function when cleaning the namespace gvb.uboot at gmail.com
2008-08-20  2:30 ` [U-Boot] [PATCH 6/7] libfdt: Implement fdt_get_property_namelen() and fdt_getprop_namelen() gvb.uboot at gmail.com
2008-08-20  2:30 ` [U-Boot] [PATCH 7/7] libfdt: Add support for using aliases in fdt_path_offset() gvb.uboot at gmail.com
2008-08-21  1:45 ` [U-Boot] [PATCH 0/7] libfdt: Update to resync with dtc/libfdt Jerry Van Baren
2008-08-21  1:51   ` David Gibson
2008-08-21  2:08     ` Jerry Van Baren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox