diff options
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 @@ | |||
16 | #define ARCH_NR_GPIOS 256 | 16 | #define ARCH_NR_GPIOS 256 |
17 | #endif | 17 | #endif |
18 | 18 | ||
19 | static inline int gpio_is_valid(int number) | ||
20 | { | ||
21 | /* only some non-negative numbers are valid */ | ||
22 | return ((unsigned)number) < ARCH_NR_GPIOS; | ||
23 | } | ||
24 | |||
19 | struct seq_file; | 25 | struct seq_file; |
20 | struct module; | 26 | struct module; |
21 | 27 | ||
@@ -99,6 +105,12 @@ extern int __gpio_cansleep(unsigned gpio); | |||
99 | 105 | ||
100 | #else | 106 | #else |
101 | 107 | ||
108 | static inline int gpio_is_valid(int number) | ||
109 | { | ||
110 | /* only non-negative numbers are valid */ | ||
111 | return number >= 0; | ||
112 | } | ||
113 | |||
102 | /* platforms that don't directly support access to GPIOs through I2C, SPI, | 114 | /* platforms that don't directly support access to GPIOs through I2C, SPI, |
103 | * or other blocking infrastructure can use these wrappers. | 115 | * or other blocking infrastructure can use these wrappers. |
104 | */ | 116 | */ |