On Fri, 29 Dec 2006, David Brownell wrote: > Here's a version that compiles ...
This patch is completely broken. > Arch-neutral GPIO calls for PXA. This is not PXA but SA1100 to start with. > Signed-off-by: David Brownell <[EMAIL PROTECTED]> > > Index: pxa/include/asm-arm/arch-sa1100/gpio.h > =================================================================== > --- /dev/null 1970-01-01 00:00:00.000000000 +0000 > +++ pxa/include/asm-arm/arch-sa1100/gpio.h 2006-12-29 > 18:21:00.000000000 -0800 > @@ -0,0 +1,100 @@ [...] > +static inline int gpio_direction_input(unsigned gpio) > +{ > + if (gpio > GPIO_MAX) > + return -EINVAL; > + GPDR = (GPDR_In << gpio); This is crap. It will expand to GPDR = 0 effectively making _all_ gpios as input. What you want here is: GPDR &= ~(1 << gpio); and you most probably need to protect the implied read-modify-write cycle with a spinlock unless the generic gpio API expects this protection is the responsibility of the caller. > +static inline int gpio_direction_output(unsigned gpio) > +{ > + if (gpio > GPIO_MAX) > + return -EINVAL; > + GPDR = (GPDR_Out << gpio); Same issue, although this would make all gpios as input except for the specified one. What you want is: GPDR |= (1 << gpio); And again spinlock protection is probably needed. > +static inline int __gpio_get_value(unsigned gpio) > +{ > + return GPLR & GPIO_GPIO(gpio); > +} > + > +#define gpio_get_value(gpio) \ > + (__builtin_constant_p(gpio) \ > + ? __gpio_get_value(gpio) \ > + : sa1100_gpio_get_value(gpio)) > + Please drop the out of line version. It will always be more costly than the inline version even for non constant gpio values. And I think the usage of GPIO_GPIO(gpio) is more obfuscating than directly using (1 << gpio). > +static inline void __gpio_set_value(unsigned gpio, int value) > +{ > + if (value) > + GPSR = GPIO_GPIO(gpio); > + else > + GPCR = GPIO_GPIO(gpio); > +} > + > +#define gpio_set_value(gpio,value) \ > + (__builtin_constant_p(gpio) \ > + ? __gpio_set_value(gpio, value) \ > + : sa1100_gpio_set_value(gpio, value)) Same as above. Nicolas - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/