lib/fdtdec: Fix compiling warning for debug
RFC 1/1 lib/fdtdec: Fix compiling warning for debug
fdt_addr_t and fdt_size_t can be either 64-bit or 32-bit, depending on the architecture. Change the type to phys_addr_t and phys_size_t.
--- include/fdtdec.h | 7 +++---- lib/fdtdec.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-)
include/fdtdec.h +3 -4
@@ -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
@@ -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=%zx\n" , + &addr, *sizep); }else {debug ("%08lx\n" , (ulong )addr); }
Signature · 1 line
1.7.9.5
Hello York,
Quoted 2 lines · York Sun
fdt_addr_tandfdt_size_tcan be either 64-bit or 32-bit, depending on the architecture. Change the type tophys_addr_tandphys_size_t.
If the only reason for changing the type is to avoid warnings in debug() then I don't think this is the right approach (see my message re PRIu64).
If, on the other hand, there is reason to believe the fdt_addr_t and fdt_size_t are wrongly defined and should be typedef'd or ~define's as phys_*_t, then the rationale for this should be exposed.
Amicalement,
Signature · 1 line
Albert.
Hi,
Quoted 11 lines · Albert ARIBAUD
Hello York,
Quoted 2 lines · York Sun
fdt_addr_tandfdt_size_tcan be either 64-bit or 32-bit, depending on the architecture. Change the type tophys_addr_tandphys_size_t.If the only reason for changing the type is to avoid warnings in
debug()then I don't think this is the right approach (see my message re PRIu64).
Quoted 7 lines
If, on the other hand, there is reason to believe the
fdt_addr_tandfdt_size_tare wrongly defined and should be typedef'd or ~define's as phys_*_t, then the rationale for this should be exposed.Amicalement,
--
Albert.
For LBA we do this in ide.h:
#ifdef CONFIG_SYS_64BIT_LBA
typedef uint64_t lbaint_t;
#define LBAF "%llx"
#define LBAFU "%llu"
#else
typedef ulong lbaint_t;
#define LBAF "%lx"
#define LBAFU "%lu"
#endif
How about something similar for this case? It would be nice to avoid promoting everything to 64-bit given that very few platforms are actually 64-bit.
Regards,
Simon
Quoted 34 lines · Simon Glass
Hi,
Quoted 11 lines · Albert ARIBAUD
Hello York,
Quoted 2 lines · York Sun
fdt_addr_tandfdt_size_tcan be either 64-bit or 32-bit, depending on the architecture. Change the type tophys_addr_tandphys_size_t.If the only reason for changing the type is to avoid warnings in
debug()then I don't think this is the right approach (see my message re PRIu64).Quoted 7 lines
If, on the other hand, there is reason to believe the
fdt_addr_tandfdt_size_tare wrongly defined and should be typedef'd or ~define's as phys_*_t, then the rationale for this should be exposed.Amicalement,
--
Albert.For LBA we do this in
ide.h:#ifdef
CONFIG_SYS_64BIT_LBA
typedefuint64_tlbaint_t;
#define LBAF "%llx"
#define LBAFU "%llu"
#else
typedef ulonglbaint_t;
#define LBAF "%lx"
#define LBAFU "%lu"
#endif
Quoted 4 lines
How about something similar for this case? It would be nice to avoid promoting everything to 64-bit given that very few platforms are actually 64-bit.
Simon,
Do you think fdt_addr_t should be phys_addr_t? According to the comments you put in file, "A typedef for a physical address". If yes, I can change the commit message.
On the other hand, if we want to keep the current typedef, we can use Albert's PRIu64 technique, we then don't have to define the format string.
York
Hi York,
Quoted 42 lines · York Sun
Quoted 34 lines · Simon Glass
Hi,
Quoted 11 lines · Albert ARIBAUD
Hello York,
Quoted 2 lines · York Sun
fdt_addr_tandfdt_size_tcan be either 64-bit or 32-bit, depending on the architecture. Change the type tophys_addr_tandphys_size_t.If the only reason for changing the type is to avoid warnings in
debug()then I don't think this is the right approach (see my message re PRIu64).Quoted 7 lines
If, on the other hand, there is reason to believe the
fdt_addr_tandfdt_size_tare wrongly defined and should be typedef'd or ~define's as phys_*_t, then the rationale for this should be exposed.Amicalement,
--
Albert.For LBA we do this in
ide.h:#ifdef
CONFIG_SYS_64BIT_LBA
typedefuint64_tlbaint_t;
#define LBAF "%llx"
#define LBAFU "%llu"
#else
typedef ulonglbaint_t;
#define LBAF "%lx"
#define LBAFU "%lu"
#endifQuoted 4 lines
How about something similar for this case? It would be nice to avoid promoting everything to 64-bit given that very few platforms are actually 64-bit.
Quoted 5 lines
Simon,
Do you think
fdt_addr_tshould bephys_addr_t? According to the comments you put in file, "A typedef for a physical address". If yes, I can change the commit message.
Sounds good to me.
Quoted 3 lines
On the other hand, if we want to keep the current typedef, we can use Albert's PRIu64 technique, we then don't have to define the format string.
The only reason for a difference typedef is the big endian nature of FDT data. So I think your patch is fine on that front.
Regards,
Simon