
On Mon, Oct 20, 2008 at 12:01:59AM +0200, Wolfgang Denk wrote:
Hello,
on some systems (for example Fedora Core 4) U-Boot builds with the following wanrings only:
... In file included from /home/wd/git/u-boot/include/libfdt_env.h:33, from fdt.c:51: /usr/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
[snip]
However, for the FDT code this doesn't help, as we then will get unresolved references for fdt32_to_cpu(), cpu_to_fdt32(), fdt64_to_cpu() and cpu_to_fdt64().
The 32 bit accesses couldbe worked around by using htonl() resp. ntohl(), but I don't know a good way for the 64 bit cases.
Is there a clean and portable way to do this?
Best regards,
Wolfgang Denk
Hi Wolfgang,
Does this work better?
Best regards, gvb
From 0d33fb368acac6f88c0940ff2d1c77856900abcd Mon Sep 17 00:00:00 2001
From: Gerald Van Baren vanbaren@cideas.com Date: Sun, 19 Oct 2008 22:50:07 -0400 Subject: [PATCH] libfdt: Use endian.h instead of asm/byteorder.h
Using asm/byteorder.h directly is strongly discouraged since it is a private kernel header.
Signed-off-by: Gerald Van Baren vanbaren@cideas.com --- include/libfdt_env.h | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/include/libfdt_env.h b/include/libfdt_env.h index 671c3a8..728a248 100644 --- a/include/libfdt_env.h +++ b/include/libfdt_env.h @@ -33,10 +33,17 @@ #include <asm/byteorder.h> extern struct fdt_header *working_fdt; /* Pointer to the working fdt */
-#define fdt32_to_cpu(x) __be32_to_cpu(x) -#define cpu_to_fdt32(x) __cpu_to_be32(x) -#define fdt64_to_cpu(x) __be64_to_cpu(x) -#define cpu_to_fdt64(x) __cpu_to_be64(x) +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define fdt32_to_cpu(x) __swab32(x) +#define cpu_to_fdt32(x) __swab32(x) +#define fdt64_to_cpu(x) __swab64(x) +#define cpu_to_fdt64(x) __swab64(x) +#else +#define fdt32_to_cpu(x) (x) +#define cpu_to_fdt32(x) (x) +#define fdt64_to_cpu(x) (x) +#define cpu_to_fdt64(x) (x) +#endif
/* * Types for `void *' pointers.