]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
of: use __be32 for cell value accessors
authorJeremy Kerr <jeremy.kerr@canonical.com>
Sat, 30 Jan 2010 08:41:49 +0000 (01:41 -0700)
committerGrant Likely <grant.likely@secretlab.ca>
Tue, 9 Feb 2010 15:34:10 +0000 (08:34 -0700)
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>
drivers/of/fdt.c
include/linux/of.h
include/linux/of_fdt.h

index 56fbd6e3122add28bdcabc6184f395c3c8de95bc..968a86af5301619ba4c80a87a27e3cda43176f0b 100644 (file)
@@ -431,9 +431,9 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname,
        return 1;
 }
 
-u64 __init dt_mem_next_cell(int s, u32 **cellp)
+u64 __init dt_mem_next_cell(int s, __be32 **cellp)
 {
-       u32 *p = *cellp;
+       __be32 *p = *cellp;
 
        *cellp = p + s;
        return of_read_number(p, s);
index fd47c81d7a2544afc99a913116ecf86777b97475..fa5571b6e219e7a86c87253e8bb4c0f4beb59bfc 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/kref.h>
 #include <linux/mod_devicetable.h>
 
+#include <asm/byteorder.h>
+
 typedef u32 phandle;
 typedef u32 ihandle;
 
@@ -95,16 +97,16 @@ extern void of_node_put(struct device_node *node);
  */
 
 /* Helper to read a big number; size is in cells (not bytes) */
-static inline u64 of_read_number(const u32 *cell, int size)
+static inline u64 of_read_number(const __be32 *cell, int size)
 {
        u64 r = 0;
        while (size--)
-               r = (r << 32) | *(cell++);
+               r = (r << 32) | be32_to_cpu(*(cell++));
        return r;
 }
 
 /* Like of_read_number, but we want an unsigned long result */
-static inline unsigned long of_read_ulong(const u32 *cell, int size)
+static inline unsigned long of_read_ulong(const __be32 *cell, int size)
 {
        /* toss away upper bits if unsigned long is smaller than u64 */
        return of_read_number(cell, size);
index f32f0fc5314a32b8cd6ce4f31251df0f809aaaff..6a35d91a53a6d8645c17c774bfd776f9bac16633 100644 (file)
@@ -78,7 +78,7 @@ extern void early_init_dt_check_for_initrd(unsigned long node);
 extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
                                     int depth, void *data);
 extern void early_init_dt_add_memory_arch(u64 base, u64 size);
-extern u64 dt_mem_next_cell(int s, u32 **cellp);
+extern u64 dt_mem_next_cell(int s, __be32 **cellp);
 
 /*
  * If BLK_DEV_INITRD, the fdt early init code will call this function,