From 88023c1d746c23ab68116e97054d331416ec5d9d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Wed, 12 Dec 2012 16:28:10 +0800 Subject: [PATCH] rk: refactor gpio.h and add new gpio_is_valid --- arch/arm/mach-rk2928/include/mach/gpio.h | 14 -------------- arch/arm/mach-rk30/include/mach/gpio.h | 14 -------------- arch/arm/plat-rk/include/plat/gpio.h | 23 ++++++++++++++++++++--- include/asm-generic/gpio.h | 2 ++ 4 files changed, 22 insertions(+), 31 deletions(-) diff --git a/arch/arm/mach-rk2928/include/mach/gpio.h b/arch/arm/mach-rk2928/include/mach/gpio.h index caf0c55929bd..4cf8254be0ad 100755 --- a/arch/arm/mach-rk2928/include/mach/gpio.h +++ b/arch/arm/mach-rk2928/include/mach/gpio.h @@ -362,18 +362,4 @@ #include -#ifndef __ASSEMBLY__ -extern void __init rk30_gpio_init(void); -static inline int gpio_to_irq(unsigned gpio) -{ - return gpio - PIN_BASE + NR_GIC_IRQS; -} - -static inline int irq_to_gpio(unsigned irq) -{ - return irq - NR_GIC_IRQS + PIN_BASE; -} - -#endif /* __ASSEMBLY__ */ - #endif diff --git a/arch/arm/mach-rk30/include/mach/gpio.h b/arch/arm/mach-rk30/include/mach/gpio.h index 43c915d1102b..d5ce06f12517 100755 --- a/arch/arm/mach-rk30/include/mach/gpio.h +++ b/arch/arm/mach-rk30/include/mach/gpio.h @@ -415,18 +415,4 @@ #include -#ifndef __ASSEMBLY__ -extern void __init rk30_gpio_init(void); - -static inline int gpio_to_irq(unsigned gpio) -{ - return gpio - PIN_BASE + NR_GIC_IRQS; -} - -static inline int irq_to_gpio(unsigned irq) -{ - return irq - NR_GIC_IRQS + PIN_BASE; -} -#endif /* __ASSEMBLY__ */ - #endif diff --git a/arch/arm/plat-rk/include/plat/gpio.h b/arch/arm/plat-rk/include/plat/gpio.h index f83ff524d2f1..20656edb2ac7 100644 --- a/arch/arm/plat-rk/include/plat/gpio.h +++ b/arch/arm/plat-rk/include/plat/gpio.h @@ -1,6 +1,8 @@ #ifndef __PLAT_GPIO_H #define __PLAT_GPIO_H +#include + /* * tp_int = * tp_rst = @@ -86,7 +88,24 @@ typedef enum GPIOIntType { GPIOEdgelRising }eGPIOIntType_t; -#ifndef __ASSEMBLY__ +static inline bool gpio_is_valid(int number) +{ + return number >= PIN_BASE && number < ARCH_NR_GPIOS; +} + +#define gpio_is_valid gpio_is_valid + +extern void __init rk30_gpio_init(void); + +static inline int gpio_to_irq(unsigned gpio) +{ + return gpio - PIN_BASE + NR_GIC_IRQS; +} + +static inline int irq_to_gpio(unsigned irq) +{ + return irq - NR_GIC_IRQS + PIN_BASE; +} #include #include /* cansleep wrappers */ @@ -95,6 +114,4 @@ typedef enum GPIOIntType { #define gpio_set_value __gpio_set_value #define gpio_cansleep __gpio_cansleep -#endif /* __ASSEMBLY__ */ - #endif diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h index 5ba10a40e523..44238fba36a3 100644 --- a/include/asm-generic/gpio.h +++ b/include/asm-generic/gpio.h @@ -35,10 +35,12 @@ * platform data and other tables. */ +#ifndef gpio_is_valid static inline bool gpio_is_valid(int number) { return number >= 0 && number < ARCH_NR_GPIOS; } +#endif struct device; struct seq_file; -- 2.34.1