Request_threaded_irq () is used in the driver, why not request_irq ()? What is the difference between the two?

I posted this thread that was discussing about request_threaded_irq, but I did not get any response. Therefore, I am publishing it recently.

I am working on a touch screen driver for a capacitive touch screen. He used request_threaded_irq () instead of request_irq (). I could not understand the main difference between the two. It says: -

Name

request_threaded_irq - highlight interrupt line

Summary

int request_threaded_irq (unsigned int irq, irq_handler_t handler, irq_handler_t thread_fn, unsigned long irqflags, const char * devname, void * dev_id);

Arguments

  • irq - interrupt string to place
  • handler - a function called when an IRQ occurs. Primary handler for thread interrupts If NULL and thread_fn! = NULL, the default primary handler is set
  • thread_fn - A function called from the irq handler thread. If NULL, irq thread is not created
  • irqflags - interrupt type flags
  • devname - ascii name for the requesting device
  • dev_id - cookie returns to handler function

the Handler and Thread_fn arguments are the ones that are confusing. Also, the driver does not have a function.

Here is the driver I'm referring to.

Can someone help me in understanding this?

+4
source share
2 answers

The request_threaded_irq () function has been added to allow developers to split the interrupt handling code in two. One part that will be executed with blocked interrupts, and the second part that the kernel thread can execute without blocking interrupts. More on why, you can read this:

http://lwn.net/Articles/302043/

In your case, the driver you contacted does the following:

err = request_threaded_irq(client->irq, NULL, cy8ctmg110_irq_thread, IRQF_TRIGGER_RISING, "touch_reset_key", ts); 

Passing NULL for the second arg, the "handler", the thread_fn argument, or the cy8ctmg110_irq_thread () function is called when an interrupt is detected.

For you, choosing which irq query function will depend on what your driver should do in the context of the interrupt.

+6
source

Another important aspect: "If you want to configure an irq handler with an irq thread for your device, you need to provide a handler handler and thread_fn. The handler is still called in the context of a hard interrupt and must check if an interrupt occurs from the device. If so , it you must disable the interrupt on the device and return IRQ_WAKE_THREAD, which will awaken the handler thread and run thread_fn . "

Source: https://www.kernel.org/doc/htmldocs/genericirq.html

0
source

All Articles