aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2011-05-10 19:23:07 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-05-26 23:02:43 -0400
commit3474cb3cc0140f9cf6ca56983f8180b4b4c5c36a (patch)
tree73abf5a283fb330ef15c7cb8e9d0cc264f03ab5f /include/asm-generic
parent82ab0f75ee2f5defe300eadc91635aa455e01afd (diff)
gpio: Convert gpio_is_valid to return bool
Make the code a bit more readable. Instead of casting an int to an unsigned then comparing to MAX_NR_GPIOS, add a >= 0 test and let the compiler optimizer do the conversion to unsigned. The generated code should be the same. Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/gpio.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index ff5c66080c8..a98b52cb970 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -35,9 +35,9 @@
35 * platform data and other tables. 35 * platform data and other tables.
36 */ 36 */
37 37
38static inline int gpio_is_valid(int number) 38static inline bool gpio_is_valid(int number)
39{ 39{
40 return ((unsigned)number) < ARCH_NR_GPIOS; 40 return number >= 0 && number < ARCH_NR_GPIOS;
41} 41}
42 42
43struct device; 43struct device;
@@ -212,7 +212,7 @@ extern void gpio_unexport(unsigned gpio);
212 212
213#else /* !CONFIG_GPIOLIB */ 213#else /* !CONFIG_GPIOLIB */
214 214
215static inline int gpio_is_valid(int number) 215static inline bool gpio_is_valid(int number)
216{ 216{
217 /* only non-negative numbers are valid */ 217 /* only non-negative numbers are valid */
218 return number >= 0; 218 return number >= 0;