[U-Boot] [PATCH] lib/fdtdec: Fix fdt_addr_t and fdt_size_t typedef

York Sun yorksun at freescale.com
Mon Jul 20 17:23:20 CEST 2015


fdt_addr_t is a physical address. It can be either 64-bit or 32-bit,
depending on the architecture. It should be phys_addr_t instead of
u64 or u32. Similarly, fdt_size_t is changed to phys_size_t.

Signed-off-by: York Sun <yorksun at freescale.com>
CC: Simon Glass <sjg at chromium.org>
---
The print format for fdt_size_t may not be the best. size_t and phys_size_t
are not always aligned, so using %zx doesn't always work.

 include/fdtdec.h |    7 +++----
 lib/fdtdec.c     |    4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 2323603..c61734c 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -14,6 +14,7 @@
  * changes to support FDT are minimized.
  */
 
+#include <linux/types.h>
 #include <libfdt.h>
 #include <pci.h>
 
@@ -21,15 +22,13 @@
  * A typedef for a physical address. Note that fdt data is always big
  * endian even on a litle endian machine.
  */
+typedef phys_addr_t fdt_addr_t;
+typedef phys_size_t fdt_size_t;
 #ifdef CONFIG_PHYS_64BIT
-typedef u64 fdt_addr_t;
-typedef u64 fdt_size_t;
 #define FDT_ADDR_T_NONE (-1ULL)
 #define fdt_addr_to_cpu(reg) be64_to_cpu(reg)
 #define fdt_size_to_cpu(reg) be64_to_cpu(reg)
 #else
-typedef u32 fdt_addr_t;
-typedef u32 fdt_size_t;
 #define FDT_ADDR_T_NONE (-1U)
 #define fdt_addr_to_cpu(reg) be32_to_cpu(reg)
 #define fdt_size_to_cpu(reg) be32_to_cpu(reg)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 9877849..718ab49 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -102,8 +102,8 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
 			size = (fdt_size_t *)((char *)cell +
 					sizeof(fdt_addr_t));
 			*sizep = fdt_size_to_cpu(*size);
-			debug("addr=%08lx, size=%08x\n",
-			      (ulong)addr, *sizep);
+			debug("addr=%pa, size=%lx\n",
+			      &addr, *sizep);
 		} else {
 			debug("%08lx\n", (ulong)addr);
 		}
-- 
1.7.9.5



More information about the U-Boot mailing list