diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2013-02-12 12:48:37 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2013-02-13 05:11:53 -0500 |
commit | e80beb27d2f81a1c3c8887e0e0a82d77bb392d28 (patch) | |
tree | 1f81c7ffb20b23d5f7a157e996fbb176779af88a /drivers/gpio/gpiolib-of.c | |
parent | bd69f73f2c81eed9a398708b8c4bb3409ba1b0f9 (diff) |
gpio: Make of_count_named_gpios() use new of_count_phandle_with_args()
This patch replaces the horribly coded of_count_named_gpios() with a
call to of_count_phandle_with_args() which is far more efficient. This
also changes the return value of of_gpio_count() & of_gpio_named_count()
from 'unsigned int' to 'int' so that it can return an error code. All
the users of that function are fixed up to correctly handle a negative
return value.
v2: Split GPIO portion into a separate patch
Tested-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'drivers/gpio/gpiolib-of.c')
-rw-r--r-- | drivers/gpio/gpiolib-of.c | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index d542a141811a..dd8a2129222f 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
@@ -89,41 +89,6 @@ int of_get_named_gpio_flags(struct device_node *np, const char *propname, | |||
89 | EXPORT_SYMBOL(of_get_named_gpio_flags); | 89 | EXPORT_SYMBOL(of_get_named_gpio_flags); |
90 | 90 | ||
91 | /** | 91 | /** |
92 | * of_gpio_named_count - Count GPIOs for a device | ||
93 | * @np: device node to count GPIOs for | ||
94 | * @propname: property name containing gpio specifier(s) | ||
95 | * | ||
96 | * The function returns the count of GPIOs specified for a node. | ||
97 | * | ||
98 | * Note that the empty GPIO specifiers counts too. For example, | ||
99 | * | ||
100 | * gpios = <0 | ||
101 | * &pio1 1 2 | ||
102 | * 0 | ||
103 | * &pio2 3 4>; | ||
104 | * | ||
105 | * defines four GPIOs (so this function will return 4), two of which | ||
106 | * are not specified. | ||
107 | */ | ||
108 | unsigned int of_gpio_named_count(struct device_node *np, const char* propname) | ||
109 | { | ||
110 | unsigned int cnt = 0; | ||
111 | |||
112 | do { | ||
113 | int ret; | ||
114 | |||
115 | ret = of_parse_phandle_with_args(np, propname, "#gpio-cells", | ||
116 | cnt, NULL); | ||
117 | /* A hole in the gpios = <> counts anyway. */ | ||
118 | if (ret < 0 && ret != -EEXIST) | ||
119 | break; | ||
120 | } while (++cnt); | ||
121 | |||
122 | return cnt; | ||
123 | } | ||
124 | EXPORT_SYMBOL(of_gpio_named_count); | ||
125 | |||
126 | /** | ||
127 | * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags | 92 | * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags |
128 | * @gc: pointer to the gpio_chip structure | 93 | * @gc: pointer to the gpio_chip structure |
129 | * @np: device node of the GPIO chip | 94 | * @np: device node of the GPIO chip |