gpio: omap_gpio: Fix valid gpio range for AM33XX
PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX
AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
--- drivers/gpio/omap_gpio.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpio/omap_gpio.c +4 -0
@@ -55,7 +55,11 @@ static inline int get_gpio_index(int gpio)int gpio_is_valid (int gpio) { +#if defined(CONFIG_AM33XX ) +return (gpio >=0 ) && (gpio <128 ); +#else return (gpio >=0 ) && (gpio <192 ); +#endif }static int check_gpio (int gpio)
Signature · 1 line
1.8.1.2
PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX
Quoted 3 lines · Axel Lin
AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
Signed-off-by Axel Lin <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130620/d7d57441/attachment.pgp>
PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX
In reply to Axel LinQuoted 12 lines · Axel Lin
AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
Signed-off-by Axel Lin <[email protected]>--- drivers/gpio/omap_gpio.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/omap_gpio.c +0
-0
drivers/gpio/omap_gpio.c static inline int get_gpio_index(int gpio) · line 63
Quoted 9 lines
drivers/gpio/omap_gpio.c +4
-0@@ -55,7 +55,11 @@ static inline int get_gpio_index(int gpio)int gpio_is_valid (int gpio) { +#if defined(CONFIG_AM33XX ) +return (gpio >=0 ) && (gpio <128 ); +#else return (gpio >=0 ) && (gpio <192 ); +#endif }
Those ifdef's in the code really ugly and frowned upon. Better would be to move this into a define in the top of the C file:
#if defined(CONFIG_AM33XX)
#define CONFIG_OMAP_MAX_GPIO 128
#else
#define CONFIG_OMAP_MAX_GPIO 192
#endif
And then use this define in the code:
return (gpio >= 0) && (gpio < CONFIG_OMAP_MAX_GPIO);
Thanks,
Stefan
PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX
Dear Stefan Roese,
Quoted 37 lines · Axel Lin
Quoted 25 lines
AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
Signed-off-by Axel Lin <[email protected]>---
drivers/gpio/omap_gpio.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpio/omap_gpio.c +4
-0@@ -55,7 +55,11 @@ static inline int get_gpio_index(int gpio)int gpio_is_valid (int gpio) { +#if defined(CONFIG_AM33XX ) +return (gpio >=0 ) && (gpio <128 ); +#else return (gpio >=0 ) && (gpio <192 ); +#endif Quoted 1 line
}
Those ifdef's in the code really ugly and frowned upon. Better would be to move this into a define in the top of the C file:
#if
defined(CONFIG_AM33XX)
#defineCONFIG_OMAP_MAX_GPIO128
#else
#defineCONFIG_OMAP_MAX_GPIO192
#endif
Quoted 6 lines
And then use this define in the code:
return (gpio >= 0) && (gpio < CONFIG_OMAP_MAX_GPIO);Thanks,
Stefan
You were faster ;-) and I agree with this method.
Best regards,
Marek Vasut