* [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX
@ 2013-06-20 15:26 Axel Lin
2013-06-20 15:35 ` Tom Rini
2013-06-20 15:47 ` Stefan Roese
0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2013-06-20 15:26 UTC (permalink / raw)
To: u-boot
AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/gpio/omap_gpio.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
index a30d7f0..9aa6d41 100644
--- a/drivers/gpio/omap_gpio.c
+++ b/drivers/gpio/omap_gpio.c
@@ -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)
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX
2013-06-20 15:26 [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX Axel Lin
@ 2013-06-20 15:35 ` Tom Rini
2013-06-20 15:47 ` Stefan Roese
1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2013-06-20 15:35 UTC (permalink / raw)
To: u-boot
On Thu, Jun 20, 2013 at 11:26:56PM +0800, Axel Lin wrote:
> AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Reviewed-by: Tom Rini <trini@ti.com>
--
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX
2013-06-20 15:26 [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX Axel Lin
2013-06-20 15:35 ` Tom Rini
@ 2013-06-20 15:47 ` Stefan Roese
2013-06-20 19:42 ` Marek Vasut
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Roese @ 2013-06-20 15:47 UTC (permalink / raw)
To: u-boot
On 20.06.2013 17:26, Axel Lin wrote:
> AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/gpio/omap_gpio.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
> index a30d7f0..9aa6d41 100644
> --- a/drivers/gpio/omap_gpio.c
> +++ b/drivers/gpio/omap_gpio.c
> @@ -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
^ permalink raw reply [flat|nested] 4+ messages in thread* [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX
2013-06-20 15:47 ` Stefan Roese
@ 2013-06-20 19:42 ` Marek Vasut
0 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2013-06-20 19:42 UTC (permalink / raw)
To: u-boot
Dear Stefan Roese,
> On 20.06.2013 17:26, Axel Lin wrote:
> > AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.
> >
> > Signed-off-by: Axel Lin <axel.lin@ingics.com>
> > ---
> >
> > drivers/gpio/omap_gpio.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
> > index a30d7f0..9aa6d41 100644
> > --- a/drivers/gpio/omap_gpio.c
> > +++ b/drivers/gpio/omap_gpio.c
> > @@ -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
You were faster ;-) and I agree with this method.
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-20 19:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-20 15:26 [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX Axel Lin
2013-06-20 15:35 ` Tom Rini
2013-06-20 15:47 ` Stefan Roese
2013-06-20 19:42 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox