bcm47xx: Fix GPIO API return codes
Subsystems (2)
PATCH 1/1 bcm47xx: Fix GPIO API return codes
The GPIO API is supposed to return 0 or a negative error code,
but the SSB GPIO functions return the bitmask of the GPIO register.
Fix this by ignoring the bitmask and always returning 0. The SSB GPIO functions can't fail.
---
arch/mips/include/asm/mach-bcm47xx/gpio.h +12 -8
@@ -31,24 +31,28 @@ static inline void gpio_set_value(unsignstatic inline int gpio_direction_input (unsigned gpio) { -return ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,0 ); +ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,0 ); +return 0 ; }static inline int gpio_direction_output (unsigned gpio,int value) { -return ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,1 << gpio); +ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,1 << gpio); +return 0 ; } -static int gpio_intmask (unsigned gpio,int value) +static inline int gpio_intmask (unsigned gpio,int value) { -return ssb_gpio_intmask (&ssb_bcm47xx,1 << gpio, - value ?1 << gpio :0 ); +ssb_gpio_intmask (&ssb_bcm47xx,1 << gpio, + value ?1 << gpio :0 ); +return 0 ; } -static int gpio_polarity (unsigned gpio,int value) +static inline int gpio_polarity (unsigned gpio,int value) { -return ssb_gpio_polarity (&ssb_bcm47xx,1 << gpio, - value ?1 << gpio :0 ); +ssb_gpio_polarity (&ssb_bcm47xx,1 << gpio, + value ?1 << gpio :0 ); +return 0 ; }
Signature · 1 line
Greetings, Michael.
Hi Michael,
Le Saturday 14 February 2009 21:27:19 Michael Buesch, vous avez écrit :
Quoted 4 lines
The GPIO API is supposed to return 0 or a negative error code, but the SSB GPIO functions return the bitmask of the GPIO register. Fix this by ignoring the bitmask and always returning 0. The SSB GPIO functions can't fail.
At some point we might want to convert the existing board code to use gpiolib. I will try to come up with a patch for this later this afternoon.
Otherwise, your patch looks good.
Signature · 4 lines
Best regards, Florian Fainelli Email : [email protected] http://openwrt.org -------------------------------
Quoted 10 lines · On Sunday 15 February 2009 14:27:36 Florian Fainelli wrote:
Hi Michael,
Le Saturday 14 February 2009 21:27:19 Michael Buesch, vous avez écrit :
Quoted 4 lines
The GPIO API is supposed to return 0 or a negative error code, but the SSB GPIO functions return the bitmask of the GPIO register. Fix this by ignoring the bitmask and always returning 0. The SSB GPIO functions can't fail.
At some point we might want to convert the existing board code to use gpiolib. I will try to come up with a patch for this later this afternoon.
Well, why? What's the advantage?
I think it would degrade performance even more, due to yet another few function calls in the hotpath. And yes, performance does matter.
The only reason the optional inlined GPIO API exists is to avoid the gpiolib callbacks on platforms where the GPIO numbers are written in stone anyway.
And that's the case for bcm47xx
Signature · 1 line
Greetings, Michael.
Quoted 37 lines · On Sat, 14 Feb 2009 21:27:19 +0100 Michael Buesch <[email protected]> wrote:
The GPIO API is supposed to return 0 or a negative error code,
but the SSB GPIO functions return the bitmask of the GPIO register.
Fix this by ignoring the bitmask and always returning 0. The SSB GPIO functions can't fail.Signed-off-by Michael Buesch <[email protected]>---
Index:
linux-2.6/arch/mips/include/asm/mach-bcm47xx/gpio.h
===================================================================arch/mips/include/asm/mach-bcm47xx/gpio.h +8
-5@@ -31,24 +31,28 @@ static inline void gpio_set_value(unsignstatic inline int gpio_direction_input (unsigned gpio) { -return ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,0 ); +ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,0 ); +return 0 ; }static inline int gpio_direction_output (unsigned gpio,int value) { -return ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,1 << gpio); +ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,1 << gpio); +return 0 ; } -static int gpio_intmask (unsigned gpio,int value) +static inline int gpio_intmask (unsigned gpio,int value) { -return ssb_gpio_intmask (&ssb_bcm47xx,1 << gpio, - value ?1 << gpio :0 ); +ssb_gpio_intmask (&ssb_bcm47xx,1 << gpio, + value ?1 << gpio :0 ); +return 0 ; }
arch/mips/include/asm/mach-bcm47xx/gpio.h static inline void gpio_set_value(unsign · line 56
Quoted 10 lines
arch/mips/include/asm/mach-bcm47xx/gpio.h +4
-3-static int gpio_polarity (unsigned gpio,int value) +static inline int gpio_polarity (unsigned gpio,int value) { -return ssb_gpio_polarity (&ssb_bcm47xx,1 << gpio, - value ?1 << gpio :0 ); +ssb_gpio_polarity (&ssb_bcm47xx,1 << gpio, + value ?1 << gpio :0 ); +return 0 ; }
What are the consequences of the bug which you fixed? User-visible runtime failures? Something else?
Please always include this information in the changelogs - without it I cannot make which-kernel-needs-this decisions.
Quoted 54 lines · On Wednesday 18 February 2009 01:29:18 Andrew Morton wrote:
Quoted 37 lines · On Sat, 14 Feb 2009 21:27:19 +0100 Michael Buesch <[email protected]> wrote:
The GPIO API is supposed to return 0 or a negative error code,
but the SSB GPIO functions return the bitmask of the GPIO register.
Fix this by ignoring the bitmask and always returning 0. The SSB GPIO functions can't fail.Signed-off-by Michael Buesch <[email protected]>---
Index:
linux-2.6/arch/mips/include/asm/mach-bcm47xx/gpio.h
===================================================================arch/mips/include/asm/mach-bcm47xx/gpio.h +8
-5@@ -31,24 +31,28 @@ static inline void gpio_set_value(unsignstatic inline int gpio_direction_input (unsigned gpio) { -return ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,0 ); +ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,0 ); +return 0 ; }static inline int gpio_direction_output (unsigned gpio,int value) { -return ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,1 << gpio); +ssb_gpio_outen (&ssb_bcm47xx,1 << gpio,1 << gpio); +return 0 ; } -static int gpio_intmask (unsigned gpio,int value) +static inline int gpio_intmask (unsigned gpio,int value) { -return ssb_gpio_intmask (&ssb_bcm47xx,1 << gpio, - value ?1 << gpio :0 ); +ssb_gpio_intmask (&ssb_bcm47xx,1 << gpio, + value ?1 << gpio :0 ); +return 0 ; }arch/mips/include/asm/mach-bcm47xx/gpio.h static inline void gpio_set_value(unsign · line 56
Quoted 10 lines
arch/mips/include/asm/mach-bcm47xx/gpio.h +4
-3-static int gpio_polarity (unsigned gpio,int value) +static inline int gpio_polarity (unsigned gpio,int value) { -return ssb_gpio_polarity (&ssb_bcm47xx,1 << gpio, - value ?1 << gpio :0 ); +ssb_gpio_polarity (&ssb_bcm47xx,1 << gpio, + value ?1 << gpio :0 ); +return 0 ; }What are the consequences of the bug which you fixed? User-visible runtime failures? Something else?
Quoted 2 lines
Please always include this information in the changelogs - without it I cannot make which-kernel-needs-this decisions.
Well, it fixes all users of the API that don't ignore the return value. "Fixes" means "turns them from completely not working at all into - working properly". This is the case for gpio-spi, for example. gpio-spi doesn't work on bcm47xx without this fix. gpio-spi is in 2.6.29.
I didn't search for other API-users that might be broken.
So I'd like to see this going to Linus as soon as possible.
Signature · 1 line
Greetings, Michael.