[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <aecf5e530807180321v529c95e1k91fbcffe246a0a75@mail.gmail.com>
Date: Fri, 18 Jul 2008 15:51:02 +0530
From: "sasa sasa" <sasak.1983@...il.com>
To: linux-kernel@...r.kernel.org
Cc: "Thomas Gleixner" <tglx@...utronix.de>
Subject: [PATCH] IRQ : bug fix in setup_irq
>From ebb5cb875363822e7c2dc17dae36f14dd4a0e71e Mon Sep 17 00:00:00 2001
From: Sandeep Kaushik <sandeep-mmc.kaushik@...com>
Date: Fri, 18 Jul 2008 14:58:19 +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
rchitecture dependent pins like gpio pins are requested as interrupt pin and
they are already occupied by other devices in some other modes, then setup_irq
must return error.
Signed-off-by: Sandeep Kaushik <sandeep-mmc.kaushik@...com>
---
kernel/irq/manage.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 1f31422..ca92f97 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -339,6 +339,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
desc->status |= IRQ_NO_BALANCING;
if (!shared) {
+ int trigger_type = 0;
irq_chip_set_defaults(desc->chip);
#if defined(CONFIG_IRQ_PER_CPU)
@@ -346,11 +347,22 @@ 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))) {
+ /* Action handler gets freed but
+ * desc->action also needs to be
+ * set to NULL
+ */
+ *p = NULL;
+ spin_unlock_irqrestore(&desc->lock,
+ flags);
+ return -EBUSY;
+ }
+ }
else
/*
* IRQF_TRIGGER_* but the PIC does not support
@@ -571,8 +583,10 @@ int request_irq(unsigned int irq, irq_handler_t handler,
#endif
retval = setup_irq(irq, action);
- if (retval)
+ if (retval) {
+ printk(KERN_WARNING"Failed to allocate interrupt %d\n", retval);
kfree(action);
+ }
return retval;
}
--
1.5.6.GIT
Download attachment "0001-IRQ-bug-fix-in-setup_irq.patch" of type "application/octet-stream" (2127 bytes)
Powered by blists - more mailing lists