diff options
author | Jeremy Kerr <jeremy.kerr@canonical.com> | 2010-01-30 03:41:49 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-02-09 10:34:10 -0500 |
commit | 2e89e685a8fd0e8334de967739d11e2e28c1a4dd (patch) | |
tree | 6fdf51430532616584f0ffa65376b5a2a4c49a40 /include/linux/of.h | |
parent | 36b9d3070d653af5807cef74ff129721d9047107 (diff) |
of: use __be32 for cell value accessors
Currently, we're using u32 for cell values, and hence assuming
host-endian device trees.
As we'd like to support little-endian platforms, use a __be32 for cell
values, and convert in the cell accessors.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'include/linux/of.h')
-rw-r--r-- | include/linux/of.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index fd47c81d7a25..fa5571b6e219 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/kref.h> | 20 | #include <linux/kref.h> |
21 | #include <linux/mod_devicetable.h> | 21 | #include <linux/mod_devicetable.h> |
22 | 22 | ||
23 | #include <asm/byteorder.h> | ||
24 | |||
23 | typedef u32 phandle; | 25 | typedef u32 phandle; |
24 | typedef u32 ihandle; | 26 | typedef u32 ihandle; |
25 | 27 | ||
@@ -95,16 +97,16 @@ extern void of_node_put(struct device_node *node); | |||
95 | */ | 97 | */ |
96 | 98 | ||
97 | /* Helper to read a big number; size is in cells (not bytes) */ | 99 | /* Helper to read a big number; size is in cells (not bytes) */ |
98 | static inline u64 of_read_number(const u32 *cell, int size) | 100 | static inline u64 of_read_number(const __be32 *cell, int size) |
99 | { | 101 | { |
100 | u64 r = 0; | 102 | u64 r = 0; |
101 | while (size--) | 103 | while (size--) |
102 | r = (r << 32) | *(cell++); | 104 | r = (r << 32) | be32_to_cpu(*(cell++)); |
103 | return r; | 105 | return r; |
104 | } | 106 | } |
105 | 107 | ||
106 | /* Like of_read_number, but we want an unsigned long result */ | 108 | /* Like of_read_number, but we want an unsigned long result */ |
107 | static inline unsigned long of_read_ulong(const u32 *cell, int size) | 109 | static inline unsigned long of_read_ulong(const __be32 *cell, int size) |
108 | { | 110 | { |
109 | /* toss away upper bits if unsigned long is smaller than u64 */ | 111 | /* toss away upper bits if unsigned long is smaller than u64 */ |
110 | return of_read_number(cell, size); | 112 | return of_read_number(cell, size); |