gpio: add gpio_is_valid() to omap_gpio API

Add gpio_is_valid() to omap_gpio API

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
This commit is contained in:
Nikita Kiryanov 2012-11-27 22:40:57 +00:00 committed by Tom Rini
parent abcbe2eb00
commit dcee1ab320
2 changed files with 10 additions and 7 deletions

View file

@ -49,4 +49,11 @@ extern const struct gpio_bank *const omap_gpio_bank;
#define METHOD_GPIO_24XX 4 #define METHOD_GPIO_24XX 4
/**
* Check if gpio is valid.
*
* @param gpio GPIO number
* @return 1 if ok, 0 on error
*/
int gpio_is_valid(int gpio);
#endif /* _GPIO_H_ */ #endif /* _GPIO_H_ */

View file

@ -53,18 +53,14 @@ static inline int get_gpio_index(int gpio)
return gpio & 0x1f; return gpio & 0x1f;
} }
static inline int gpio_valid(int gpio) int gpio_is_valid(int gpio)
{ {
if (gpio < 0) return (gpio >= 0) && (gpio < 192);
return -1;
if (gpio < 192)
return 0;
return -1;
} }
static int check_gpio(int gpio) static int check_gpio(int gpio)
{ {
if (gpio_valid(gpio) < 0) { if (!gpio_is_valid(gpio)) {
printf("ERROR : check_gpio: invalid GPIO %d\n", gpio); printf("ERROR : check_gpio: invalid GPIO %d\n", gpio);
return -1; return -1;
} }