cpm2_pic: Allow correct flow_types for port C interrupts
PATCH v2 1/1 cpm2_pic: Allow correct flow_types for port C interrupts
Port C interrupts can be either falling edge, or either edge. Other external interrupts are either falling edge or active low.
---
Changed in v2:
- Disallow rising edge only on Port C
arch/powerpc/sysdev/cpm2_pic.c | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-)
arch/powerpc/sysdev/cpm2_pic.c +23 -7
@@ -141,13 +141,29 @@ static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)struct irq_desc *desc =get_irq_desc (virq);unsigned int vold, vnew, edibit; -if (flow_type ==IRQ_TYPE_NONE ) - flow_type =IRQ_TYPE_LEVEL_LOW ; - -if (flow_type &IRQ_TYPE_EDGE_RISING ) { -printk (KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n" , - flow_type); -return -EINVAL ; +/* Port C interrupts are either IRQ_TYPE_EDGE_FALLING or +* IRQ_TYPE_EDGE_BOTH (default). All others are IRQ_TYPE_EDGE_FALLING +* or IRQ_TYPE_LEVEL_LOW (default) +*/ +if (src >=CPM2_IRQ_PORTC15 && src <=CPM2_IRQ_PORTC0 ) { +if (flow_type ==IRQ_TYPE_NONE ) + flow_type =IRQ_TYPE_EDGE_BOTH ; + +if ((flow_type !=IRQ_TYPE_EDGE_BOTH ) && + (flow_type !=IRQ_TYPE_EDGE_FALLING )) { +printk (KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n" , + flow_type); +return -EINVAL ; + } + }else { +if (flow_type ==IRQ_TYPE_NONE ) + flow_type =IRQ_TYPE_LEVEL_LOW ; + +if (flow_type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_LEVEL_HIGH )) { +printk (KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n" , + flow_type); +return -EINVAL ; + } } desc->status &= ~(IRQ_TYPE_SENSE_MASK |IRQ_LEVEL );
Signature · 1 line
1.5.6.5
Quoted 10 lines · Mark Ware
Port C interrupts can be either falling edge, or either edge. Other external interrupts are either falling edge or active low. =20
Signed-off-by Mark Ware <[email protected]>---
Changed in v2:
- Disallow rising edge only on Port C=20
=20arch/powerpc/sysdev/cpm2_pic.c| 30 +++++++++++++++++++++++-------1 files changed, 23 insertions(+), 7 deletions(-)
Anton, mind taking a look at this for me.
- k
=
Quoted 2 lines
=20
= renamed from arch/powerpc/sysdev/cpm2_pic.c +0
-0
b/arch/powerpc/sysdev/cpm2_pic.c
arch/powerpc/sysdev/cpm2_pic.c static int cpm2_set_irq_type(unsigned int virq, =
Quoted 4 lines
index 78f1f7c..eba5f24 100644
arch/powerpc/sysdev/cpm2_pic.c +0
-0@@ -141,13 +141,29 @@ static int cpm2_set_irq_type(unsigned int virq, =
unsigned int flow_type)
arch/powerpc/sysdev/cpm2_pic.c
Quoted 8 lines
arch/powerpc/sysdev/cpm2_pic.c +0
-0struct irq_desc *desc =3D get_irq_desc(virq);unsigned int vold, vnew, edibit;=20
arch/powerpc/sysdev/cpm2_pic.c +0
-5- if (flow_type =3D=3D IRQ_TYPE_NONE) - flow_type =3D IRQ_TYPE_LEVEL_LOW; - - if (flow_type & IRQ_TYPE_EDGE_RISING) { - printk(KERN_ERR "CPM2 PIC: sense type 0x%x not =
supported\n",
arch/powerpc/sysdev/cpm2_pic.c static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)
Quoted 4 lines
arch/powerpc/sysdev/cpm2_pic.c +2
-2- flow_type); -return -EINVAL ; +/* Port C interrupts are either IRQ_TYPE_EDGE_FALLING or +* IRQ_TYPE_EDGE_BOTH (default). All others are =
IRQ_TYPE_EDGE_FALLING
arch/powerpc/sysdev/cpm2_pic.c
Quoted 9 lines
arch/powerpc/sysdev/cpm2_pic.c +9
-0+* or IRQ_TYPE_LEVEL_LOW (default) +*/ + if (src >=3D CPM2_IRQ_PORTC15 && src <=3D CPM2_IRQ_PORTC0) { + if (flow_type =3D=3D IRQ_TYPE_NONE) + flow_type =3D IRQ_TYPE_EDGE_BOTH; + + if ((flow_type !=3D IRQ_TYPE_EDGE_BOTH) &&=20 + (flow_type !=3D IRQ_TYPE_EDGE_FALLING)) { + printk(KERN_ERR "CPM2 PIC: sense type 0x%x not =
supported\n",
arch/powerpc/sysdev/cpm2_pic.c static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)
Quoted 8 lines
arch/powerpc/sysdev/cpm2_pic.c +8
-0+ flow_type); +return -EINVAL ; + } + }else { + if (flow_type =3D=3D IRQ_TYPE_NONE) + flow_type =3D IRQ_TYPE_LEVEL_LOW; + + if (flow_type & (IRQ_TYPE_EDGE_RISING | =
IRQ_TYPE_LEVEL_HIGH)) {
arch/powerpc/sysdev/cpm2_pic.c
Quoted 1 line
arch/powerpc/sysdev/cpm2_pic.c +1
-0+ printk(KERN_ERR "CPM2 PIC: sense type 0x%x not =
supported\n",
Quoted 8 lines
arch/powerpc/sysdev/cpm2_pic.c +3
-0+ flow_type); +return -EINVAL ; + }} =20 desc->status &=3D ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);--=20
1.5.6.5
Quoted 4 lines · Mark Ware
Port C interrupts can be either falling edge, or either edge. Other external interrupts are either falling edge or active low.
Signed-off-by Mark Ware <[email protected]>
Looks correct (checked with 8272 and 8555 specs).
Cosmetic nitpicks below. I tend to think they don't desire another resend, but I couldn't resist making them anyway. ;-)
[...]
arch/powerpc/sysdev/cpm2_pic.c static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type) · line 153
Quoted 6 lines
arch/powerpc/sysdev/cpm2_pic.c +6
-0+if (src >=CPM2_IRQ_PORTC15 && src <=CPM2_IRQ_PORTC0 ) { +if (flow_type ==IRQ_TYPE_NONE ) + flow_type =IRQ_TYPE_EDGE_BOTH ; + +if ((flow_type !=IRQ_TYPE_EDGE_BOTH ) && + (flow_type !=IRQ_TYPE_EDGE_FALLING )) {
I'd place one more tab here. And parenthesis aren't actually needed.
arch/powerpc/sysdev/cpm2_pic.c static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type) · line 164
Quoted 11 lines
arch/powerpc/sysdev/cpm2_pic.c +11
-0+printk (KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n" , + flow_type); +return -EINVAL ; + } + }else { +if (flow_type ==IRQ_TYPE_NONE ) + flow_type =IRQ_TYPE_LEVEL_LOW ; + +if (flow_type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_LEVEL_HIGH )) { +printk (KERN_ERR "CPM2 PIC: sense type 0x%x not supported\n" , + flow_type);
pr_err is shorter. Also, this message is duplicated. Would be better to do something like:
if (somethingwrong) goto err_sense; ... return 0;
err_sense:
pr_err("CPM2 PIC: sense type 0x%x not supported\n", flow_type);
return -EINVAL;
}Or we may don't print any errors at all. For internal interrupts we don't print them anyway, i.e. the current code has just
return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL;
Thanks,
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
Quoted 4 lines · Anton Vorontsov
arch/powerpc/sysdev/cpm2_pic.c static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type) · line 153
Quoted 2 lines
arch/powerpc/sysdev/cpm2_pic.c +2
-0+if ((flow_type !=IRQ_TYPE_EDGE_BOTH ) && + (flow_type !=IRQ_TYPE_EDGE_FALLING )) {I'd place one more tab here.
Or better, align one "flow_type" with the other.
-Scott
Quoted 10 lines · Scott Wood
Quoted 4 lines · Anton Vorontsov
Quoted 2 lines
+ if ((
flow_type!=IRQ_TYPE_EDGE_BOTH) && +
(flow_type!=IRQ_TYPE_EDGE_FALLING)) {I'd place one more tab here.
Or better, align one "
flow_type" with the other.-Scott
Thanks Anton and Scott.
Scott's suggestion is also my preferred style, but a (brief) search through the source didn't reveal much support.
I'll send a new version shortly including you suggestions.
- Mark