aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/gpio.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-02-02 10:20:01 -0500
committerGrant Likely <grant.likely@secretlab.ca>2012-02-06 01:08:30 -0500
commitff64abefb6680dfc2aca7ecaa5e695949e7335c9 (patch)
tree8e580bc26cb65edf3135b25e29ddf8f77d776569 /drivers/of/gpio.c
parent9467d298e92455e6fd411d7ef1f367ced940587c (diff)
of_gpio: add support of of_gpio_named_count to be able to count named gpio
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Cc: devicetree-discuss@lists.ozlabs.org Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/of/gpio.c')
-rw-r--r--drivers/of/gpio.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c
index 7e62d15d60f6..e034b38590a8 100644
--- a/drivers/of/gpio.c
+++ b/drivers/of/gpio.c
@@ -78,8 +78,9 @@ err0:
78EXPORT_SYMBOL(of_get_named_gpio_flags); 78EXPORT_SYMBOL(of_get_named_gpio_flags);
79 79
80/** 80/**
81 * of_gpio_count - Count GPIOs for a device 81 * of_gpio_named_count - Count GPIOs for a device
82 * @np: device node to count GPIOs for 82 * @np: device node to count GPIOs for
83 * @propname: property name containing gpio specifier(s)
83 * 84 *
84 * The function returns the count of GPIOs specified for a node. 85 * The function returns the count of GPIOs specified for a node.
85 * 86 *
@@ -93,14 +94,14 @@ EXPORT_SYMBOL(of_get_named_gpio_flags);
93 * defines four GPIOs (so this function will return 4), two of which 94 * defines four GPIOs (so this function will return 4), two of which
94 * are not specified. 95 * are not specified.
95 */ 96 */
96unsigned int of_gpio_count(struct device_node *np) 97unsigned int of_gpio_named_count(struct device_node *np, const char* propname)
97{ 98{
98 unsigned int cnt = 0; 99 unsigned int cnt = 0;
99 100
100 do { 101 do {
101 int ret; 102 int ret;
102 103
103 ret = of_parse_phandle_with_args(np, "gpios", "#gpio-cells", 104 ret = of_parse_phandle_with_args(np, propname, "#gpio-cells",
104 cnt, NULL); 105 cnt, NULL);
105 /* A hole in the gpios = <> counts anyway. */ 106 /* A hole in the gpios = <> counts anyway. */
106 if (ret < 0 && ret != -EEXIST) 107 if (ret < 0 && ret != -EEXIST)
@@ -109,7 +110,7 @@ unsigned int of_gpio_count(struct device_node *np)
109 110
110 return cnt; 111 return cnt;
111} 112}
112EXPORT_SYMBOL(of_gpio_count); 113EXPORT_SYMBOL(of_gpio_named_count);
113 114
114/** 115/**
115 * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags 116 * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags