diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2008-06-25 14:27:53 +1000 |
---|---|---|
committer | Jon Loeliger <jdl@jdl.com> | 2008-07-14 12:07:22 -0500 |
commit | c8c374b8565081da08e3d1d73df8ddb0d6a66ae3 (patch) | |
tree | 9cedc7a1cebed065c1af55f74733fa8b76ee8602 /dtc.h | |
parent | 53359016caf6db9ab2347517a323d6ba8eb6671e (diff) | |
download | dtc-c8c374b8565081da08e3d1d73df8ddb0d6a66ae3.zip dtc-c8c374b8565081da08e3d1d73df8ddb0d6a66ae3.tar.gz dtc-c8c374b8565081da08e3d1d73df8ddb0d6a66ae3.tar.bz2 |
dtc: Use the same endian-conversion functions as libfdt
Currently both libfdt and dtc define a set of endian conversion macros
for accessing the device tree blob which is always big-endian. libfdt
uses names like cpu_to_fdt32() and dtc uses names like cpu_to_be32 (as
the Linux kernel). This patch switches dtc over to using the libfdt
macros (including libfdt_env.h to supply them). This has a couple of
small advantages:
- Removes some code duplication
- Will make conversion a bit easier if we ever need to produce
little-endian device tree blobs.
- dtc no longer needs to pull in netinet/in.h simply for the
ntohs() and ntohl() functions
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'dtc.h')
-rw-r--r-- | dtc.h | 17 |
1 files changed, 1 insertions, 16 deletions
@@ -30,10 +30,8 @@ #include <ctype.h> #include <errno.h> #include <unistd.h> -#include <netinet/in.h> -#include <endian.h> -#include <byteswap.h> +#include <libfdt_env.h> #include <fdt.h> #define DEFAULT_FDT_VERSION 17 @@ -77,19 +75,6 @@ static inline void *xrealloc(void *p, size_t len) typedef uint32_t cell_t; -#define cpu_to_be16(x) htons(x) -#define be16_to_cpu(x) ntohs(x) - -#define cpu_to_be32(x) htonl(x) -#define be32_to_cpu(x) ntohl(x) - -#if __BYTE_ORDER == __BIG_ENDIAN -#define cpu_to_be64(x) (x) -#define be64_to_cpu(x) (x) -#else -#define cpu_to_be64(x) bswap_64(x) -#define be64_to_cpu(x) bswap_64(x) -#endif #define streq(a, b) (strcmp((a), (b)) == 0) #define strneq(a, b, n) (strncmp((a), (b), (n)) == 0) |