[U-Boot] [PATCH 1/2] fdt: Bring in changes from v1.4.4

Simon Glass sjg at chromium.org
Tue Mar 28 16:23:31 UTC 2017


This a few minor changes down from upstream since the last sync.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 lib/libfdt/fdt_overlay.c  | 23 ++++++++++++-----------
 lib/libfdt/fdt_rw.c       |  3 ++-
 lib/libfdt/fdt_strerror.c |  3 +++
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
index 56cb70ed44..ceb968786e 100644
--- a/lib/libfdt/fdt_overlay.c
+++ b/lib/libfdt/fdt_overlay.c
@@ -21,14 +21,14 @@
  */
 static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
 {
-	const uint32_t *val;
+	const fdt32_t *val;
 	int len;
 
 	val = fdt_getprop(fdto, fragment, "target", &len);
 	if (!val)
 		return 0;
 
-	if ((len != sizeof(*val)) || (*val == (uint32_t)-1))
+	if ((len != sizeof(*val)) || (fdt32_to_cpu(*val) == (uint32_t)-1))
 		return (uint32_t)-1;
 
 	return fdt32_to_cpu(*val);
@@ -99,7 +99,7 @@ static int overlay_get_target(const void *fdt, const void *fdto,
 static int overlay_phandle_add_offset(void *fdt, int node,
 				      const char *name, uint32_t delta)
 {
-	const uint32_t *val;
+	const fdt32_t *val;
 	uint32_t adj_val;
 	int len;
 
@@ -210,7 +210,7 @@ static int overlay_update_local_node_references(void *fdto,
 	int ret;
 
 	fdt_for_each_property_offset(fixup_prop, fdto, fixup_node) {
-		const uint32_t *fixup_val;
+		const fdt32_t *fixup_val;
 		const char *tree_val;
 		const char *name;
 		int fixup_len;
@@ -234,7 +234,8 @@ static int overlay_update_local_node_references(void *fdto,
 		}
 
 		for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) {
-			uint32_t adj_val, poffset;
+			fdt32_t adj_val;
+			uint32_t poffset;
 
 			poffset = fdt32_to_cpu(fixup_val[i]);
 
@@ -246,9 +247,7 @@ static int overlay_update_local_node_references(void *fdto,
 			 */
 			memcpy(&adj_val, tree_val + poffset, sizeof(adj_val));
 
-			adj_val = fdt32_to_cpu(adj_val);
-			adj_val += delta;
-			adj_val = cpu_to_fdt32(adj_val);
+			adj_val = cpu_to_fdt32(fdt32_to_cpu(adj_val) + delta);
 
 			ret = fdt_setprop_inplace_namelen_partial(fdto,
 								  tree_node,
@@ -272,7 +271,7 @@ static int overlay_update_local_node_references(void *fdto,
 
 		tree_child = fdt_subnode_offset(fdto, tree_node,
 						fixup_child_name);
-		if (ret == -FDT_ERR_NOTFOUND)
+		if (tree_child == -FDT_ERR_NOTFOUND)
 			return -FDT_ERR_BADOVERLAY;
 		if (tree_child < 0)
 			return tree_child;
@@ -356,6 +355,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 {
 	const char *symbol_path;
 	uint32_t phandle;
+	fdt32_t phandle_prop;
 	int symbol_off, fixup_off;
 	int prop_len;
 
@@ -381,10 +381,11 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
 	if (fixup_off < 0)
 		return fixup_off;
 
-	phandle = cpu_to_fdt32(phandle);
+	phandle_prop = cpu_to_fdt32(phandle);
 	return fdt_setprop_inplace_namelen_partial(fdto, fixup_off,
 						   name, name_len, poffset,
-						   &phandle, sizeof(phandle));
+						   &phandle_prop,
+						   sizeof(phandle_prop));
 };
 
 /**
diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
index 87d4030fb1..80a3212141 100644
--- a/lib/libfdt/fdt_rw.c
+++ b/lib/libfdt/fdt_rw.c
@@ -242,7 +242,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 	if (err)
 		return err;
 
-	memcpy(prop->data, val, len);
+	if (len)
+		memcpy(prop->data, val, len);
 	return 0;
 }
 
diff --git a/lib/libfdt/fdt_strerror.c b/lib/libfdt/fdt_strerror.c
index 7f8e02b1ee..f89004c609 100644
--- a/lib/libfdt/fdt_strerror.c
+++ b/lib/libfdt/fdt_strerror.c
@@ -36,6 +36,9 @@ static struct fdt_errtabent fdt_errtable[] = {
 	FDT_ERRTABENT(FDT_ERR_BADVERSION),
 	FDT_ERRTABENT(FDT_ERR_BADSTRUCTURE),
 	FDT_ERRTABENT(FDT_ERR_BADLAYOUT),
+	FDT_ERRTABENT(FDT_ERR_INTERNAL),
+	FDT_ERRTABENT(FDT_ERR_BADNCELLS),
+	FDT_ERRTABENT(FDT_ERR_BADVALUE),
 	FDT_ERRTABENT(FDT_ERR_BADOVERLAY),
 	FDT_ERRTABENT(FDT_ERR_NOPHANDLES),
 };
-- 
2.12.2.564.g063fe858b8-goog



More information about the U-Boot mailing list