Re: Threaded interrupts for synaptic touchscreen in HTC dream
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2009-07-23 04:43:29
Also in:
linux-i2c, lkml
Subsystem:
irq subsystem, the rest · Maintainers:
Thomas Gleixner, Linus Torvalds
On Wed, Jul 22, 2009 at 11:04:33PM +0200, Thomas Gleixner wrote:
Any more ?
Can we also have something like below by any chance? -- Dmitry genirq: provide dummy hard irq handler for threaded interrupts From: Dmitry Torokhov <dmitry.torokhov@gmail.com> Quite often drivers using threaded interrupts don't do anything in the hard IRQ portion of their interrupt handler; everything is offloaded to the threaded half. Instead of having every driver implement a stub have one ready in the IRQ core. Signed-off-by: Dmitry Torokhov <redacted> --- kernel/irq/manage.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 50da676..cdc52f6 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c@@ -695,6 +695,15 @@ out_thread: return ret; } +/* + * Default hardirq handler for threaded irqs that is used when + * driver did not provide its own implementation. + */ +static irqreturn_t dummy_hardirq_handler(int irq, void *dev_id) +{ + return IRQ_WAKE_THREAD; +} + /** * setup_irq - setup an interrupt * @irq: Interrupt line to setup
@@ -837,8 +846,11 @@ EXPORT_SYMBOL(free_irq); * request_threaded_irq - allocate an interrupt line * @irq: Interrupt line to allocate * @handler: Function to be called when the IRQ occurs. - * Primary handler for threaded interrupts - * @thread_fn: Function called from the irq handler thread + * Primary handler for threaded interrupts. + * May be NULL, in which case a dummy interrupt + * handler is used that simply returns + * IRQ_WAKE_THREAD + * @thread_fn: Function called from the irq handler thread. * If NULL, no irq thread is created * @irqflags: Interrupt type flags * @devname: An ascii name for the claiming device
@@ -917,14 +929,16 @@ int request_threaded_irq(unsigned int irq, irq_handler_t handler, if (desc->status & IRQ_NOREQUEST) return -EINVAL; - if (!handler) + + if (!handler && !thread_fn) { return -EINVAL; + } action = kzalloc(sizeof(struct irqaction), GFP_KERNEL); if (!action) return -ENOMEM; - action->handler = handler; + action->handler = handler ?: dummy_hardirq_handler; action->thread_fn = thread_fn; action->flags = irqflags; action->name = devname;