summaryrefslogtreecommitdiffstats
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorJeremy Kerr <jeremy.kerr@canonical.com>2010-01-30 01:45:26 -0700
committerGrant Likely <grant.likely@secretlab.ca>2010-02-09 08:34:10 -0700
commit337148812f97368a8ec4a69f1691e4c5ce3af494 (patch)
tree3fa2e5477c657cb2ebc40db9182d0989a5d60e13 /drivers/of/base.c
parent2e89e685a8fd0e8334de967739d11e2e28c1a4dd (diff)
downloadblackbird-op-linux-337148812f97368a8ec4a69f1691e4c5ce3af494.tar.gz
blackbird-op-linux-337148812f97368a8ec4a69f1691e4c5ce3af494.zip
of: assume big-endian properties, adding conversions where necessary
Properties in the device tree are specified as big-endian. At present, the only platforms to support device trees are also big-endian, so we've been acessing the properties as raw values. We'd like to add device tree support to little-endian platforms too, so add endian conversion to the sites where we access property values in the common of code. Compiled on powerpc (ppc44x_defconfig & ppc64_defconfig) and arm (fdt support only for now). Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of/base.c')
-rw-r--r--drivers/of/base.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 524645ab42a4..873479a21c80 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -38,7 +38,7 @@ int of_n_addr_cells(struct device_node *np)
np = np->parent;
ip = of_get_property(np, "#address-cells", NULL);
if (ip)
- return *ip;
+ return be32_to_cpup(ip);
} while (np->parent);
/* No #address-cells property for the root node */
return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
@@ -54,7 +54,7 @@ int of_n_size_cells(struct device_node *np)
np = np->parent;
ip = of_get_property(np, "#size-cells", NULL);
if (ip)
- return *ip;
+ return be32_to_cpup(ip);
} while (np->parent);
/* No #size-cells property for the root node */
return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
@@ -696,8 +696,8 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
const void **out_args)
{
int ret = -EINVAL;
- const u32 *list;
- const u32 *list_end;
+ const __be32 *list;
+ const __be32 *list_end;
int size;
int cur_index = 0;
struct device_node *node = NULL;
@@ -711,7 +711,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
list_end = list + size / sizeof(*list);
while (list < list_end) {
- const u32 *cells;
+ const __be32 *cells;
const phandle *phandle;
phandle = list++;
@@ -735,7 +735,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
goto err1;
}
- list += *cells;
+ list += be32_to_cpup(cells);
if (list > list_end) {
pr_debug("%s: insufficient arguments length\n",
np->full_name);
OpenPOWER on IntegriCloud