>From 6772dfdf27e153d0698f7fbecff767417ae76eab Mon Sep 17 00:00:00 2001 From: Gerald Van Baren Date: Wed, 21 Mar 2007 19:40:38 -0400 Subject: [PATCH] Use a common header set linux/u-boot Using the "right" header files along with the __KERNEL__ discriminator allows libfdt to be compiled under linux (userland) or u-boot. It also simplifies the byteswap #defines. Signed-off-by: Gerald Van Baren --- fdt.h | 4 ++++ libfdt_env.h | 21 +++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fdt.h b/fdt.h index 4687a31..64507a9 100644 --- a/fdt.h +++ b/fdt.h @@ -3,7 +3,11 @@ #ifndef __ASSEMBLY__ +#ifndef __KERNEL__ #include +#else +#include +#endif struct fdt_header { uint32_t magic; /* magic word FDT_MAGIC */ diff --git a/libfdt_env.h b/libfdt_env.h index 59f2536..dc6562e 100644 --- a/libfdt_env.h +++ b/libfdt_env.h @@ -2,21 +2,18 @@ #define _LIBFDT_ENV_H #include +#ifndef __KERNEL__ #include #include -#include -#include - -#if __BYTE_ORDER == __BIG_ENDIAN -#define fdt32_to_cpu(x) (x) -#define cpu_to_fdt32(x) (x) -#define fdt64_to_cpu(x) (x) -#define cpu_to_fdt64(x) (x) #else -#define fdt32_to_cpu(x) (bswap_32((x))) -#define cpu_to_fdt32(x) (bswap_32((x))) -#define fdt64_to_cpu(x) (bswap_64((x))) -#define cpu_to_fdt64(x) (bswap_64((x))) +#include +#include #endif +#include + +#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_be32(x)) #endif /* _LIBFDT_ENV_H */ -- 1.4.4.4