[PATCH] libfdt: Use endian.h instead of asm/byteorder.h

Gerald Van Baren vanbaren at cideas.com
Mon Oct 20 04:50:07 CEST 2008


Using asm/byteorder.h directly is strongly discouraged since it is a
private kernel header.

Signed-off-by: Gerald Van Baren <vanbaren at 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.
-- 
1.5.6.5



More information about the U-Boot mailing list