linux-mips
[Top] [All Lists]

[PATCH 2/2] rb532: check irq number when handling GPIO interrupts

To: Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
Subject: [PATCH 2/2] rb532: check irq number when handling GPIO interrupts
From: Florian Fainelli <florian@openwrt.org>
Date: Thu, 21 May 2009 19:49:47 +0200
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:date:subject :mime-version:x-uid:x-length:to:content-type :content-transfer-encoding:content-disposition:message-id; bh=M2oMXw6rbZZwBdrOycte7UM09wAwEBvhvpCe/fk9vGE=; b=VE1I83x0jjCtHMDTQwZCwVpNbOY0LRz4VUVVXC4E2PqdYs84ziPgkTUgW4O8mNMGAG hOocNmGigBcUs+lsh29X7M/DtNzAcE8WyW6QXTNoAhhM2f5c9cJTyWPvQZOXqcoCxUlv n1iS05yFOJEzlrHegXiZow1sLTrqw136Nk/0k=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:date:subject:mime-version:x-uid:x-length:to :content-type:content-transfer-encoding:content-disposition :message-id; b=krAQXzwP1O1tfnsCzkSD7BJpFewuuzs/MzSZ7OnhTEtf+TJUgkMmg9AfQl3CvlseLE C4Vc3MvTazwiPVT+xCQrc9chCANRskysiY8xe8dP+VXERPNONOt7ObO23ECp2PGtxW6h Q5azJNHsCEyAeV21UByBmKvY+A63pP0qU5bcY=
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
This patch makes sure that we are not going to clear
or change the interrupt status of a GPIO interrupt
superior to 13 as this is the maximum number of GPIO
interrupt source (p.232 of the RC32434 reference manual).

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
diff --git a/arch/mips/rb532/irq.c b/arch/mips/rb532/irq.c
index 53eeb5e..afdcafc 100644
--- a/arch/mips/rb532/irq.c
+++ b/arch/mips/rb532/irq.c
@@ -151,7 +151,8 @@ static void rb532_disable_irq(unsigned int irq_nr)
                mask |= intr_bit;
                WRITE_MASK(addr, mask);
 
-               if (group == GPIO_MAPPED_IRQ_GROUP)
+               /* There is a maximum of 13 GPIO interrupts */
+               if (group == GPIO_MAPPED_IRQ_GROUP && irq_nr <= 
(GROUP4_IRQ_BASE + 13))
                        rb532_gpio_set_istat(0, irq_nr - GPIO_MAPPED_IRQ_BASE);
 
                /*
@@ -174,7 +175,7 @@ static int rb532_set_type(unsigned int irq_nr, unsigned 
type)
        int gpio = irq_nr - GPIO_MAPPED_IRQ_BASE;
        int group = irq_to_group(irq_nr);
 
-       if (group != GPIO_MAPPED_IRQ_GROUP)
+       if (group != GPIO_MAPPED_IRQ_GROUP || irq_nr > (GROUP4_IRQ_BASE + 13))
                return (type == IRQ_TYPE_LEVEL_HIGH) ? 0 : -EINVAL;
 
        switch (type) {

<Prev in Thread] Current Thread [Next in Thread>