在驱动程序中使用request_threaded_irq()为什么不使用request_irq()?两者之间有什么区别? [英] request_threaded_irq() is used in the driver why not request_irq()? What are the differences between two?
问题描述
我发布了这是讨论关于request_threaded_irq的主题,但没有得到任何答复.因此,我正在重新发布它.
I posted this is the thread which discussed about request_threaded_irq but I did not get any reply. So I am posting it freshly.
我正在开发用于电容式触摸屏的触摸屏驱动程序.它使用request_threaded_irq()调用而不是request_irq().我无法理解两者之间的基本区别.它说:-
I am working on a touchscreen driver for capacitive touchscree. It used request_threaded_irq() call instead of request_irq(). I could not understand the basic difference betweeen two. It says :-
名称
request_threaded_irq —分配中断行
request_threaded_irq — allocate an interrupt line
简介
int request_threaded_irq(无符号int irq,irq_handler_t处理程序,irq_handler_t thread_fn,无符号长irqflags,const char * devname,void * dev_id);
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);
参数
- irq-分配中断线
- handler-发生IRQ时要调用的函数.线程中断的主处理程序如果NULL和thread_fn!= NULL,则安装默认的主处理程序
- thread_fn-从irq处理程序线程调用的函数如果为NULL,则不创建任何irq线程
- irqflags-中断类型标志
- devname-声明设备的ASCII名称
- dev_id-将Cookie传递回处理程序函数
Handler和Thread_fn参数令人困惑.此外,驱动程序中未定义任何工作功能.
the Handler and Thread_fn arguments are the ones which are confusing. Also there is no work function defined in the driver.
有人可以帮助我理解这一点吗?
Can somebody help me in understanding this?
推荐答案
添加了request_threaded_irq()函数,以允许开发人员将中断处理代码分为两部分.一部分将在中断被阻止的情况下执行,另一部分可以由内核线程在不中断被阻止的情况下完成.有关原因的详细信息,您可以阅读以下内容:
The request_threaded_irq() function was added to allow developers to split interrupt handling code into two parts. One part that will execute with interrupts blocked, and a second part that can be done by a kernel thread without interrupts blocked. For details of why, you can read this:
http://lwn.net/Articles/302043/
以您为例,您链接到的驱动程序将执行以下操作:
In your case, the driver you linked to does this:
err = request_threaded_irq(client->irq, NULL, cy8ctmg110_irq_thread,
IRQF_TRIGGER_RISING, "touch_reset_key", ts);
在检测到中断时,将通过为第二个arg,处理程序,thread_fn的参数或函数cy8ctmg110_irq_thread()传递NULL来调用
By passing NULL for the second arg, "handler", the argument to thread_fn, or the function cy8ctmg110_irq_thread() will be called when the interrupt is detected.
对于您来说,选择哪个请求irq函数将取决于您的驱动程序在中断上下文中需要执行的操作.
For you, choosing which request irq function will depend on what your driver needs to do in interrupt context.
这篇关于在驱动程序中使用request_threaded_irq()为什么不使用request_irq()?两者之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!