>From cf76c764e891a90ab0aaf322327e47e3a3302492 Mon Sep 17 00:00:00 2001
From: Sandeep Kaushik <[email protected]>
Date: Tue, 22 Jul 2008 13:20:51 +0530
Subject: [PATCH] IRQ : bug fix in setup_irq
This patch is for bug fix in setup_irq function.
Error handling is added in setup_irq function. This is required in case if some
architecture dependent pin's set_type function returned error.
Signed-off-by: Sandeep Kaushik <[email protected]>
---
kernel/irq/manage.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 1f31422..a90ed1c 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -339,6 +339,8 @@ int setup_irq(unsigned int irq, struct irqaction *new)
desc->status |= IRQ_NO_BALANCING;
if (!shared) {
+ int trigger_type;
+
irq_chip_set_defaults(desc->chip);
#if defined(CONFIG_IRQ_PER_CPU)
@@ -346,11 +348,25 @@ int setup_irq(unsigned int irq, struct irqaction *new)
desc->status |= IRQ_PER_CPU;
#endif
+ trigger_type = new->flags & IRQF_TRIGGER_MASK;
+
/* Setup the type (level, edge polarity) if configured: */
- if (new->flags & IRQF_TRIGGER_MASK) {
- if (desc->chip && desc->chip->set_type)
- desc->chip->set_type(irq,
- new->flags & IRQF_TRIGGER_MASK);
+ if (trigger_type) {
+ if (desc->chip && desc->chip->set_type) {
+ if ((desc->chip->set_type(irq, trigger_type))) {
+ printk(KERN_ERR "IRQF_TRIGGER set_type"
+ "function for IRQ"
+ "%d (%s) failed\n",
+ irq, desc->chip->name);
+ /*
+ * Action handler gets freed but
+ * last action handler on desc->action
+ * list also needs to bet to NULL.
+ */
+ *p = NULL;
+ goto mismatch;
+ }
+ }
else
/*
* IRQF_TRIGGER_* but the PIC does not support
--
1.5.6.GIT
Hello Sandeep,
there is a patch in -mm that does the same (and more, so it asserts that
irqaction *new isn't added to the desc->action list if set_type fails.)
See http://thread.gmane.org/gmane.linux.kernel/698011/focus=702236 or
handle-failure-of-irqchip-set_type-in-setup_irq.patch
handle-failure-of-irqchip-set_type-in-setup_irq-update.patch
in mmotm.
Best regards
Uwe
--
Uwe Kleine-K?nig, Software Engineer
Digi International GmbH Branch Breisach, K?ferstrasse 8, 79206 Breisach, Germany
Tax: 315/5781/0242 / VAT: DE153662976 / Reg. Amtsgericht Dortmund HRB 13962