diff options
author | Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> | 2008-04-28 11:14:46 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 17:58:34 +0200 |
commit | e6de1808f8ebfeb7e49f3c5a30cb8f2032beb287 (patch) | |
tree | 2230ea8f384449c7785d636ab016af3b2aa20123 /include/asm-generic/gpio.h | |
parent | gpiolib: i2c/spi drivers: handle rmmod better (diff) | |
download | linux-e6de1808f8ebfeb7e49f3c5a30cb8f2032beb287.tar.xz linux-e6de1808f8ebfeb7e49f3c5a30cb8f2032beb287.zip |
gpio: define gpio_is_valid()
Introduce a gpio_is_valid() predicate; use it in gpiolib.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
[ use inline function; follow the gpio_* naming convention;
work without gpiolib; all programming interfaces need docs ]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-generic/gpio.h')
-rw-r--r-- | include/asm-generic/gpio.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 7e77b6ff45bb..464c5b334dc2 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -16,6 +16,12 @@ #define ARCH_NR_GPIOS 256 #endif +static inline int gpio_is_valid(int number) +{ + /* only some non-negative numbers are valid */ + return ((unsigned)number) < ARCH_NR_GPIOS; +} + struct seq_file; struct module; @@ -99,6 +105,12 @@ extern int __gpio_cansleep(unsigned gpio); #else +static inline int gpio_is_valid(int number) +{ + /* only non-negative numbers are valid */ + return number >= 0; +} + /* platforms that don't directly support access to GPIOs through I2C, SPI, * or other blocking infrastructure can use these wrappers. */ |