diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-08 00:15:36 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-08 00:15:36 +0400 |
commit | fbce1c234feedb5270468aa4b1770c1cab58a960 (patch) | |
tree | 7391d7bcce50eab43c750c4055b056ab1892d6b2 /drivers/of/gpio.c | |
parent | 7affca3537d74365128e477b40c529d6f2fe86c8 (diff) | |
parent | d0ad5e89256c351ddd40167152c24a88efcb0f6d (diff) | |
download | linux-fbce1c234feedb5270468aa4b1770c1cab58a960.tar.xz |
Merge tag 'gpio-for-linus' of git://git.secretlab.ca/git/linux-2.6
Changes queued in gpio/next for the start of the 3.3 merge window
* tag 'gpio-for-linus-20120104' of git://git.secretlab.ca/git/linux-2.6:
gpio: Add decode of WM8994 GPIO configuration
gpio: Convert GPIO drivers to module_platform_driver
gpio: Fix typo in comment in Samsung driver
gpio: Explicitly index samsung_gpio_cfgs
gpio: Add Linus Walleij as gpio co-maintainer
of: Add device tree selftests
of: create of_phandle_args to simplify return of phandle parsing data
gpio/powerpc: Eliminate duplication of of_get_named_gpio_flags()
gpio/microblaze: Eliminate duplication of of_get_named_gpio_flags()
gpiolib: output basic details and consolidate gpio device drivers
pch_gpio: Change company name OKI SEMICONDUCTOR to LAPIS Semiconductor
pch_gpio: Support new device LAPIS Semiconductor ML7831 IOH
spi/pl022: make the chip deselect handling thread safe
spi/pl022: add support for pm_runtime autosuspend
spi/pl022: disable the PL022 block when unused
spi/pl022: move device disable to workqueue thread
spi/pl022: skip default configuration before suspending
spi/pl022: fix build warnings
spi/pl022: only enable RX interrupts when TX is complete
Diffstat (limited to 'drivers/of/gpio.c')
-rw-r--r-- | drivers/of/gpio.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c index ef0105fa52b1..7e62d15d60f6 100644 --- a/drivers/of/gpio.c +++ b/drivers/of/gpio.c @@ -35,32 +35,27 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname, int index, enum of_gpio_flags *flags) { int ret; - struct device_node *gpio_np; struct gpio_chip *gc; - int size; - const void *gpio_spec; - const __be32 *gpio_cells; + struct of_phandle_args gpiospec; - ret = of_parse_phandles_with_args(np, propname, "#gpio-cells", index, - &gpio_np, &gpio_spec); + ret = of_parse_phandle_with_args(np, propname, "#gpio-cells", index, + &gpiospec); if (ret) { pr_debug("%s: can't parse gpios property\n", __func__); goto err0; } - gc = of_node_to_gpiochip(gpio_np); + gc = of_node_to_gpiochip(gpiospec.np); if (!gc) { pr_debug("%s: gpio controller %s isn't registered\n", - np->full_name, gpio_np->full_name); + np->full_name, gpiospec.np->full_name); ret = -ENODEV; goto err1; } - gpio_cells = of_get_property(gpio_np, "#gpio-cells", &size); - if (!gpio_cells || size != sizeof(*gpio_cells) || - be32_to_cpup(gpio_cells) != gc->of_gpio_n_cells) { + if (gpiospec.args_count != gc->of_gpio_n_cells) { pr_debug("%s: wrong #gpio-cells for %s\n", - np->full_name, gpio_np->full_name); + np->full_name, gpiospec.np->full_name); ret = -EINVAL; goto err1; } @@ -69,13 +64,13 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname, if (flags) *flags = 0; - ret = gc->of_xlate(gc, np, gpio_spec, flags); + ret = gc->of_xlate(gc, &gpiospec, flags); if (ret < 0) goto err1; ret += gc->base; err1: - of_node_put(gpio_np); + of_node_put(gpiospec.np); err0: pr_debug("%s exited with status %d\n", __func__, ret); return ret; @@ -105,8 +100,8 @@ unsigned int of_gpio_count(struct device_node *np) do { int ret; - ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", - cnt, NULL, NULL); + ret = of_parse_phandle_with_args(np, "gpios", "#gpio-cells", + cnt, NULL); /* A hole in the gpios = <> counts anyway. */ if (ret < 0 && ret != -EEXIST) break; @@ -127,12 +122,9 @@ EXPORT_SYMBOL(of_gpio_count); * gpio chips. This function performs only one sanity check: whether gpio * is less than ngpios (that is specified in the gpio_chip). */ -int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, - const void *gpio_spec, u32 *flags) +int of_gpio_simple_xlate(struct gpio_chip *gc, + const struct of_phandle_args *gpiospec, u32 *flags) { - 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 * write your own xlate function (that will have to retrive the GPIO @@ -144,13 +136,16 @@ int of_gpio_simple_xlate(struct gpio_chip *gc, struct device_node *np, return -EINVAL; } - if (n > gc->ngpio) + if (WARN_ON(gpiospec->args_count < gc->of_gpio_n_cells)) + return -EINVAL; + + if (gpiospec->args[0] > gc->ngpio) return -EINVAL; if (flags) - *flags = be32_to_cpu(gpio[1]); + *flags = gpiospec->args[1]; - return n; + return gpiospec->args[0]; } EXPORT_SYMBOL(of_gpio_simple_xlate); @@ -198,8 +193,6 @@ int of_mm_gpiochip_add(struct device_node *np, if (ret) goto err2; - pr_debug("%s: registered as generic GPIO chip, base is %d\n", - np->full_name, gc->base); return 0; err2: iounmap(mm_gc->regs); |