Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] GPIO API: SA1100 wrapper cleanup

Based on the discussion last december (http://lkml.org/lkml/2006/12/20/241),
this patch
- adds gpio_direction_input/output functions to
generic.c instead of making them inline,
- fixes comment and includes and uses inline functions
instead of macros in gpio.h

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
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>

authored by

Philipp Zabel and committed by
Linus Torvalds
5b7e42b2 adff264f

+44 -20
+30
arch/arm/mach-sa1100/generic.c
··· 138 138 return v; 139 139 } 140 140 141 + int gpio_direction_input(unsigned gpio) 142 + { 143 + unsigned long flags; 144 + 145 + if (gpio > GPIO_MAX) 146 + return -EINVAL; 147 + 148 + local_irq_save(flags); 149 + GPDR &= ~GPIO_GPIO(gpio); 150 + local_irq_restore(flags); 151 + return 0; 152 + } 153 + 154 + EXPORT_SYMBOL(gpio_direction_input); 155 + 156 + int gpio_direction_output(unsigned gpio) 157 + { 158 + unsigned long flags; 159 + 160 + if (gpio > GPIO_MAX) 161 + return -EINVAL; 162 + 163 + local_irq_save(flags); 164 + GPDR |= GPIO_GPIO(gpio); 165 + local_irq_restore(flags); 166 + return 0; 167 + } 168 + 169 + EXPORT_SYMBOL(gpio_direction_output); 170 + 141 171 /* 142 172 * Default power-off for SA1100 143 173 */
+14 -20
include/asm-arm/arch-sa1100/gpio.h
··· 1 1 /* 2 - * linux/include/asm-arm/arch-pxa/gpio.h 2 + * linux/include/asm-arm/arch-sa1100/gpio.h 3 3 * 4 4 * SA1100 GPIO wrappers for arch-neutral GPIO calls 5 5 * ··· 24 24 #ifndef __ASM_ARCH_SA1100_GPIO_H 25 25 #define __ASM_ARCH_SA1100_GPIO_H 26 26 27 - #include <asm/arch/SA-1100.h> 28 - #include <asm/arch/irqs.h> 29 - #include <asm/arch/hardware.h> 30 - 31 - #include <asm/errno.h> 27 + #include <asm/hardware.h> 28 + #include <asm/irq.h> 32 29 33 30 static inline int gpio_request(unsigned gpio, const char *label) 34 31 { ··· 37 40 return; 38 41 } 39 42 40 - static inline int gpio_direction_input(unsigned gpio) 43 + extern int gpio_direction_input(unsigned gpio); 44 + extern int gpio_direction_output(unsigned gpio); 45 + 46 + 47 + static inline int gpio_get_value(unsigned gpio) 41 48 { 42 - if (gpio > GPIO_MAX) 43 - return -EINVAL; 44 - GPDR = (GPDR_In << gpio) 0 49 + return GPLR & GPIO_GPIO(gpio); 45 50 } 46 51 47 - static inline int gpio_direction_output(unsigned gpio) 52 + static inline void gpio_set_value(unsigned gpio, int value) 48 53 { 49 - if (gpio > GPIO_MAX) 50 - return -EINVAL; 51 - GPDR = (GPDR_Out << gpio) 0 54 + if (value) 55 + GPSR = GPIO_GPIO(gpio); 56 + else 57 + GPCR = GPIO_GPIO(gpio); 52 58 } 53 - 54 - #define gpio_get_value(gpio) \ 55 - (GPLR & GPIO_GPIO(gpio)) 56 - 57 - #define gpio_set_value(gpio,value) \ 58 - ((value) ? (GPSR = GPIO_GPIO(gpio)) : (GPCR(gpio) = GPIO_GPIO(gpio))) 59 59 60 60 #include <asm-generic/gpio.h> /* cansleep wrappers */ 61 61