Skip to contentSkip to conversation

lib/fdtdec: Fix fdt_addr_t and fdt_size_t typedef

PATCH Superseded York Sun 2 participants 3 messages Jul 23, 2015 – Aug 3, 2015

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

York Sun

author
#0 lore raw

PATCH v2 1/1 lib/fdtdec: Fix fdt_addr_t and fdt_size_t typedef

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.

---
Change log
v2: Rebase code to latest master, add change to fsl_dspi.c.

 drivers/spi/fsl_dspi.c |    4 ++--
 include/fdtdec.h       |    7 +++----
 lib/fdtdec.c           |    4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/spi/fsl_dspi.c +2 -2
index 7928531..326f040 100644
@@ -664,8 +664,8 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus)
 	plat->speed_hz = fdtdec_get_int(blob,
 			node, "spi-max-frequency", FSL_DSPI_DEFAULT_SCK_FREQ);
 
-	debug("DSPI: regs=0x%llx, max-frequency=%d, endianess=%s, num-cs=%d\n",
-	      (u64)plat->regs_addr, plat->speed_hz,
+	debug("DSPI: regs=0x%pa, max-frequency=%d, endianess=%s, num-cs=%d\n",
+	      &plat->regs_addr, plat->speed_hz,
 	      plat->flags & DSPI_FLAG_REGMAP_ENDIAN_BIG ? "be" : "le",
 	      plat->num_chipselect);
 
include/fdtdec.h +3 -4
index 2323603..c61734c 100644
@@ -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)
lib/fdtdec.c +2 -2
index 9c6b361..3ff8b66 100644
@@ -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=%llx\n",
-			      (ulong)addr, (u64)*sizep);
+			debug("addr=%pa, size=%llx\n",
+			      &addr, (u64)*sizep);
 		} else {
 			debug("%08lx\n", (ulong)addr);
 		}
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 lib/fdtdec: Fix fdt_addr_t and fdt_size_t typedef

Hi York,

Quoted 9 lines · York Sun

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.

---
Change log
v2: Rebase code to latest master, add change to fsl_dspi.c.

Can you please put that change into a different patch? For both:

Quoted 67 lines
 drivers/spi/fsl_dspi.c |    4 ++--
 include/fdtdec.h       |    7 +++----
 lib/fdtdec.c           |    4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/spi/fsl_dspi.c +2 -2
index 7928531..326f040 100644
@@ -664,8 +664,8 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus)
        plat->speed_hz = fdtdec_get_int(blob,
                        node, "spi-max-frequency", FSL_DSPI_DEFAULT_SCK_FREQ);
 
-       debug("DSPI: regs=0x%llx, max-frequency=%d, endianess=%s, num-cs=%d\n",
-             (u64)plat->regs_addr, plat->speed_hz,
+       debug("DSPI: regs=0x%pa, max-frequency=%d, endianess=%s, num-cs=%d\n",
+             &plat->regs_addr, plat->speed_hz,
              plat->flags & DSPI_FLAG_REGMAP_ENDIAN_BIG ? "be" : "le",
              plat->num_chipselect);
 
include/fdtdec.h +3 -4
index 2323603..c61734c 100644
@@ -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)
lib/fdtdec.c +2 -3
index 9c6b361..3ff8b66 100644
@@ -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=%llx\n",
-                             (ulong)addr, (u64)*sizep);
+                       debug("addr=%pa, size=%llx\n",
+                             &addr, (u64)*sizep);
                } else {
                        debug("%08lx\n", (ulong)addr);
                }
--
Quoted 2 lines

1.7.9.5

Regards,
Simon

author
#2 lore raw

PATCH v2 1/1 lib/fdtdec: Fix fdt_addr_t and fdt_size_t typedef

Sure. I have to rebase it anyway after this commit 5b34436.

York

Quoted 90 lines · Simon Glass

Hi York,

Quoted 9 lines · York Sun

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.

---
Change log
v2: Rebase code to latest master, add change to fsl_dspi.c.

Can you please put that change into a different patch? For both:

Quoted 67 lines
 drivers/spi/fsl_dspi.c |    4 ++--
 include/fdtdec.h       |    7 +++----
 lib/fdtdec.c           |    4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)
drivers/spi/fsl_dspi.c +2 -2
index 7928531..326f040 100644
@@ -664,8 +664,8 @@ static int fsl_dspi_ofdata_to_platdata(struct udevice *bus)
        plat->speed_hz = fdtdec_get_int(blob,
                        node, "spi-max-frequency", FSL_DSPI_DEFAULT_SCK_FREQ);
 
-       debug("DSPI: regs=0x%llx, max-frequency=%d, endianess=%s, num-cs=%d\n",
-             (u64)plat->regs_addr, plat->speed_hz,
+       debug("DSPI: regs=0x%pa, max-frequency=%d, endianess=%s, num-cs=%d\n",
+             &plat->regs_addr, plat->speed_hz,
              plat->flags & DSPI_FLAG_REGMAP_ENDIAN_BIG ? "be" : "le",
              plat->num_chipselect);
 
include/fdtdec.h +3 -4
index 2323603..c61734c 100644
@@ -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)
lib/fdtdec.c +2 -3
index 9c6b361..3ff8b66 100644
@@ -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=%llx\n",
-                             (ulong)addr, (u64)*sizep);
+                       debug("addr=%pa, size=%llx\n",
+                             &addr, (u64)*sizep);
                } else {
                        debug("%08lx\n", (ulong)addr);
                }
--
Quoted 2 lines

1.7.9.5

Regards,
Simon