[U-Boot] [PATCH v2 05/11] fdt: Use the correct return types for fdtdec_decode_region()

Simon Glass sjg at chromium.org
Fri Oct 24 02:58:51 CEST 2014


Use the correct FDT data types for this function. Also add more debugging.

Acked-by: Anatolij Gustschin <agust at denx.de>
Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2: None

 include/fdtdec.h | 10 +++++-----
 lib/fdtdec.c     | 19 ++++++++++++-------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 5fb86b0..3915fe0 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -595,12 +595,12 @@ const u8 *fdtdec_locate_byte_array(const void *blob, int node,
  * @param blob		FDT blob
  * @param node		node to examine
  * @param prop_name	name of property to find
- * @param ptrp		returns pointer to region, or NULL if no address
- * @param size		returns size of region
- * @return 0 if ok, -1 on error (propery not found)
+ * @param basep		Returns base address of region
+ * @param size		Returns size of region
+ * @return 0 if ok, -1 on error (property not found)
  */
-int fdtdec_decode_region(const void *blob, int node,
-		const char *prop_name, void **ptrp, size_t *size);
+int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
+			 fdt_addr_t *basep, fdt_size_t *sizep);
 
 /* A flash map entry, containing an offset and length */
 struct fmap_entry {
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index d5a6a3e..4b5e9cd 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -671,20 +671,25 @@ char *fdtdec_get_config_string(const void *blob, const char *prop_name)
 	return (char *)nodep;
 }
 
-int fdtdec_decode_region(const void *blob, int node,
-		const char *prop_name, void **ptrp, size_t *size)
+int fdtdec_decode_region(const void *blob, int node, const char *prop_name,
+			 fdt_addr_t *basep, fdt_size_t *sizep)
 {
 	const fdt_addr_t *cell;
 	int len;
 
-	debug("%s: %s\n", __func__, prop_name);
+	debug("%s: %s: %s\n", __func__, fdt_get_name(blob, node, NULL),
+	      prop_name);
 	cell = fdt_getprop(blob, node, prop_name, &len);
-	if (!cell || (len != sizeof(fdt_addr_t) * 2))
+	if (!cell || (len < sizeof(fdt_addr_t) * 2)) {
+		debug("cell=%p, len=%d\n", cell, len);
 		return -1;
+	}
+
+	*basep = fdt_addr_to_cpu(*cell);
+	*sizep = fdt_size_to_cpu(cell[1]);
+	debug("%s: base=%08lx, size=%lx\n", __func__, (ulong)*basep,
+	      (ulong)*sizep);
 
-	*ptrp = map_sysmem(fdt_addr_to_cpu(*cell), *size);
-	*size = fdt_size_to_cpu(cell[1]);
-	debug("%s: size=%zx\n", __func__, *size);
 	return 0;
 }
 
-- 
2.1.0.rc2.206.gedb03e5



More information about the U-Boot mailing list