aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/gpio.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/gpio.c
parent2e89e685a8fd0e8334de967739d11e2e28c1a4dd (diff)
downloadkernel_samsung_smdk4412-337148812f97368a8ec4a69f1691e4c5ce3af494.zip
kernel_samsung_smdk4412-337148812f97368a8ec4a69f1691e4c5ce3af494.tar.gz
kernel_samsung_smdk4412-337148812f97368a8ec4a69f1691e4c5ce3af494.tar.bz2
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/gpio.c')
-rw-r--r--drivers/of/gpio.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index 6eea601..24c3606 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -36,7 +36,7 @@ int of_get_gpio_flags(struct device_node *np, int index,
struct of_gpio_chip *of_gc = NULL;
int size;
const void *gpio_spec;
- const u32 *gpio_cells;
+ const __be32 *gpio_cells;
ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index,
&gc, &gpio_spec);
@@ -55,7 +55,7 @@ int of_get_gpio_flags(struct device_node *np, int index,
gpio_cells = of_get_property(gc, "#gpio-cells", &size);
if (!gpio_cells || size != sizeof(*gpio_cells) ||
- *gpio_cells != of_gc->gpio_cells) {
+ be32_to_cpup(gpio_cells) != of_gc->gpio_cells) {
pr_debug("%s: wrong #gpio-cells for %s\n",
np->full_name, gc->full_name);
ret = -EINVAL;
@@ -127,7 +127,8 @@ EXPORT_SYMBOL(of_gpio_count);
int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
const void *gpio_spec, enum of_gpio_flags *flags)
{
- const u32 *gpio = gpio_spec;
+ const __be32 *gpio = gpio_spec;
+ const u32 n = be32_to_cpup(gpio);
/*
* We're discouraging gpio_cells < 2, since that way you'll have to
@@ -140,13 +141,13 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
return -EINVAL;
}
- if (*gpio > of_gc->gc.ngpio)
+ if (n > of_gc->gc.ngpio)
return -EINVAL;
if (flags)
- *flags = gpio[1];
+ *flags = be32_to_cpu(gpio[1]);
- return *gpio;
+ return n;
}
EXPORT_SYMBOL(of_gpio_simple_xlate);