From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Thu, 20 Jun 2013 17:47:42 +0200 Subject: [U-Boot] [PATCH] gpio: omap_gpio: Fix valid gpio range for AM33XX In-Reply-To: <1371742016.8005.5.camel@phoenix> References: <1371742016.8005.5.camel@phoenix> Message-ID: <51C3241E.2070709@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > --- > 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