Skip to content

Commit

Permalink
genirq: record IRQ_LEVEL in irq_desc[]
Browse files Browse the repository at this point in the history
Impact: fix __irq_set_trigger() for IRQ_LEVEL

When recording the irq trigger type, let's also make sure
that IRQ_LEVEL gets set correctly.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
David Brownell authored and Ingo Molnar committed Dec 2, 2008
1 parent 061e41f commit f2b662d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions kernel/irq/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ int set_irq_type(unsigned int irq, unsigned int type)
return -ENODEV;
}

type &= IRQ_TYPE_SENSE_MASK;
if (type == IRQ_TYPE_NONE)
return 0;

Expand Down
15 changes: 9 additions & 6 deletions kernel/irq/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,18 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned int irq,
return 0;
}

ret = chip->set_type(irq, flags & IRQF_TRIGGER_MASK);
/* caller masked out all except trigger mode flags */
ret = chip->set_type(irq, flags);

if (ret)
pr_err("setting trigger mode %d for irq %u failed (%pF)\n",
(int)(flags & IRQF_TRIGGER_MASK),
irq, chip->set_type);
(int)flags, irq, chip->set_type);
else {
if (flags & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH))
flags |= IRQ_LEVEL;
/* note that IRQF_TRIGGER_MASK == IRQ_TYPE_SENSE_MASK */
desc->status &= ~IRQ_TYPE_SENSE_MASK;
desc->status |= flags & IRQ_TYPE_SENSE_MASK;
desc->status &= ~(IRQ_LEVEL | IRQ_TYPE_SENSE_MASK);
desc->status |= flags;
}

return ret;
Expand Down Expand Up @@ -459,7 +461,8 @@ __setup_irq(unsigned int irq, struct irq_desc * desc, struct irqaction *new)

/* Setup the type (level, edge polarity) if configured: */
if (new->flags & IRQF_TRIGGER_MASK) {
ret = __irq_set_trigger(desc, irq, new->flags);
ret = __irq_set_trigger(desc, irq,
new->flags & IRQF_TRIGGER_MASK);

if (ret) {
spin_unlock_irqrestore(&desc->lock, flags);
Expand Down

0 comments on commit f2b662d

Please sign in to comment.