[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20091012151127.312c986a.akpm@linux-foundation.org>
Date: Mon, 12 Oct 2009 15:11:27 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Roel Kluin <roel.kluin@...il.com>
Cc: alek.du@...el.com, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpio: Fix test on unsigned in lnw_irq_type()
On Mon, 12 Oct 2009 16:12:40 +0200
Roel Kluin <roel.kluin@...il.com> wrote:
> The wrong test was used, gpio is unsigned.
>
> Signed-off-by: Roel Kluin <roel.kluin@...il.com>
> ---
> diff --git a/drivers/gpio/langwell_gpio.c b/drivers/gpio/langwell_gpio.c
> index 5711ce5..0d0cbc0 100644
> --- a/drivers/gpio/langwell_gpio.c
> +++ b/drivers/gpio/langwell_gpio.c
> @@ -123,8 +123,11 @@ static int lnw_irq_type(unsigned irq, unsigned type)
> void __iomem *grer = (void __iomem *)(&lnw->reg_base->GRER[reg]);
> void __iomem *gfer = (void __iomem *)(&lnw->reg_base->GFER[reg]);
>
> - if (gpio < 0 || gpio > lnw->chip.ngpio)
> + if (irq < lnw->irq_base || gpio > lnw->chip.ngpio ||
> + reg >= ARRAY_SIZE(lnw->reg_base->GRER)
> + reg >= ARRAY_SIZE(lnw->reg_base->GFER))
> return -EINVAL;
> +
> spin_lock_irqsave(&lnw->lock, flags);
> if (type & IRQ_TYPE_EDGE_RISING)
> value = readl(grer) | BIT(gpio % 32);
Makes the code unfortunately complex. It'd be better to make `gpio' a
signed quantity, or even..
--- a/drivers/gpio/langwell_gpio.c~gpio-fix-test-on-unsigned-in-lnw_irq_type
+++ a/drivers/gpio/langwell_gpio.c
@@ -123,7 +123,7 @@ static int lnw_irq_type(unsigned irq, un
void __iomem *grer = (void __iomem *)(&lnw->reg_base->GRER[reg]);
void __iomem *gfer = (void __iomem *)(&lnw->reg_base->GFER[reg]);
- if (gpio < 0 || gpio > lnw->chip.ngpio)
+ if ((s32)gpio < 0 || gpio > lnw->chip.ngpio)
return -EINVAL;
spin_lock_irqsave(&lnw->lock, flags);
if (type & IRQ_TYPE_EDGE_RISING)
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists