diff options
Diffstat (limited to 'include/linux/of_gpio.h')
| -rw-r--r-- | include/linux/of_gpio.h | 40 | 
1 files changed, 23 insertions, 17 deletions
diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index c454f579674..a83dc6f5008 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -50,9 +50,6 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)  extern int of_get_named_gpio_flags(struct device_node *np,  		const char *list_name, int index, enum of_gpio_flags *flags); -extern unsigned int of_gpio_named_count(struct device_node *np, -					const char* propname); -  extern int of_mm_gpiochip_add(struct device_node *np,  			      struct of_mm_gpio_chip *mm_gc); @@ -71,12 +68,6 @@ static inline int of_get_named_gpio_flags(struct device_node *np,  	return -ENOSYS;  } -static inline unsigned int of_gpio_named_count(struct device_node *np, -					const char* propname) -{ -	return 0; -} -  static inline int of_gpio_simple_xlate(struct gpio_chip *gc,  				       const struct of_phandle_args *gpiospec,  				       u32 *flags) @@ -90,22 +81,37 @@ static inline void of_gpiochip_remove(struct gpio_chip *gc) { }  #endif /* CONFIG_OF_GPIO */  /** - * of_gpio_count - Count GPIOs for a device + * of_gpio_named_count() - Count GPIOs for a device   * @np:		device node to count GPIOs for + * @propname:	property name containing gpio specifier(s)   *   * The function returns the count of GPIOs specified for a node. + * Note that the empty GPIO specifiers count too. Returns either + *   Number of gpios defined in property, + *   -EINVAL for an incorrectly formed gpios property, or + *   -ENOENT for a missing gpios property   * - * Note that the empty GPIO specifiers counts too. For example, - * + * Example:   * gpios = <0 - *          &pio1 1 2 + *          &gpio1 1 2   *          0 - *          &pio2 3 4>; + *          &gpio2 3 4>; + * + * The above example defines four GPIOs, two of which are not specified. + * This function will return '4' + */ +static inline int of_gpio_named_count(struct device_node *np, const char* propname) +{ +	return of_count_phandle_with_args(np, propname, "#gpio-cells"); +} + +/** + * of_gpio_count() - Count GPIOs for a device + * @np:		device node to count GPIOs for   * - * defines four GPIOs (so this function will return 4), two of which - * are not specified. + * Same as of_gpio_named_count, but hard coded to use the 'gpios' property   */ -static inline unsigned int of_gpio_count(struct device_node *np) +static inline int of_gpio_count(struct device_node *np)  {  	return of_gpio_named_count(np, "gpios");  }  |