rb532: check irq number when handling GPIO interrupts
PATCH 2/2 rb532: check irq number when handling GPIO interrupts
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).
---
arch/mips/rb532/irq.c +3 -2
@@ -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) {
Hello.
Quoted 12 lines · Florian Fainelli
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 <[email protected]>---
arch/mips/rb532/irq.c +0
-0
arch/mips/rb532/irq.c static void rb532_disable_irq(unsigned int irq_nr) · line 155
Quoted 6 lines
arch/mips/rb532/irq.c +2
-1@@ -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 ))
So, 13 or 14? The code seem to allow 14. Probably it should be <, not <=
here...
arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, unsigned type) · line 178
Quoted 9 lines
arch/mips/rb532/irq.c +1
-1rb532_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 ))
... and >= here.
arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, unsigned type) · line 181
Quoted 3 lines
arch/mips/rb532/irq.c +0
-0return (type ==IRQ_TYPE_LEVEL_HIGH ) ?0 : -EINVAL ;switch (type) {
WBR, Sergei
Le Thursday 21 May 2009 20:52:13 Sergei Shtylyov, vous avez écrit :
Quoted 18 lines
Hello.
Quoted 15 lines · Florian Fainelli
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 <[email protected]>---
arch/mips/rb532/irq.c +0
-0@@ -151,7 +151,8 @@ static void rb532_disable_irq(unsigned int irq_nr) mask |= intr_bit;WRITE_MASK (addr, mask);
Quoted 7 lines
arch/mips/rb532/irq.c static void rb532_disable_irq(unsigned int irq_nr)
Quoted 4 lines
arch/mips/rb532/irq.c +2
-1-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 ))So, 13 or 14? The code seem to allow 14. Probably it should be <, not
<= here...
That's actually 14, numbering starting from 0, I should learn how to count. Ralf, do you want me to resubmit that one with the proper message / descriptions ?
Quoted 18 lines
arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, · line 178
Quoted 10 lines
arch/mips/rb532/irq.c +0
-0rb532_gpio_set_istat (0 , irq_nr -GPIO_MAPPED_IRQ_BASE );arch/mips/rb532/irq.c +1
-1/* @@ -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 ))... and >= here.arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, unsigned type) · line 181
Quoted 3 lines
arch/mips/rb532/irq.c +0
-0return (type ==IRQ_TYPE_LEVEL_HIGH ) ?0 : -EINVAL ;switch (type) {WBR, Sergei
Signature · 4 lines
Best regards, Florian Fainelli Email : [email protected] http://openwrt.org -------------------------------
Ralf Baechle
AppliedQuoted 20 lines · Florian Fainelli
That's actually 14, numbering starting from 0, I should learn how to count. Ralf, do you want me to resubmit that one with the proper message / descriptions ?
Quoted 16 lines
arch/mips/rb532/irq.c static int rb532_set_type(unsigned int irq_nr, · line 178
Quoted 10 lines
arch/mips/rb532/irq.c +1
-1rb532_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 ))... and >= here.Quoted 3 lines
arch/mips/rb532/irq.c +0
-0return (type ==IRQ_TYPE_LEVEL_HIGH ) ?0 : -EINVAL ;switch (type) {
Queued for 2.6.31 with the comment fix and the change from > to >=.
Thanks,
Ralf