From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergei Shtylyov Date: Mon, 27 Dec 2010 14:35:54 +0300 Subject: [U-Boot] [PATCH] nios2: add gpio_is_valid In-Reply-To: <1293417961-8247-1-git-send-email-thomas@wytron.com.tw> References: <1293417961-8247-1-git-send-email-thomas@wytron.com.tw> Message-ID: <4D187A1A.7080108@mvista.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello. On 27-12-2010 5:46, Thomas Chou wrote: > Signed-off-by: Thomas Chou [...] > diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h > index 36a7132..4b21c8f 100644 > --- a/arch/nios2/include/asm/gpio.h > +++ b/arch/nios2/include/asm/gpio.h > @@ -52,6 +52,11 @@ static inline void gpio_set_value(unsigned gpio, int value) > { > writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio<< 2)); > } > + > +static inline int gpio_is_valid(int number) > +{ > + return ((unsigned)number) < CONFIG_SYS_GPIO_WIDTH; No need to have parens around '(unsigned)number'. > diff --git a/board/altera/nios2-generic/gpio.c b/board/altera/nios2-generic/gpio.c > index 8c639ce..4a30564 100644 > --- a/board/altera/nios2-generic/gpio.c > +++ b/board/altera/nios2-generic/gpio.c [...] > @@ -62,4 +63,9 @@ void gpio_set_value(unsigned gpio, int value) > pio_data_reg&= ~mask; > writel(pio_data_reg, ALTERA_PIO_DATA); > } > + > +int gpio_is_valid(int number) > +{ > + return ((unsigned)number) < ALTERA_PIO_WIDTH; Same here... WBR, Sergei