request_threaded_irq()在驱动程序中使用,为什么不使用request_irq()?两者有什么区别?

发布于 2024-12-08 18:43:57 字数 922 浏览 1 评论 0原文

我发布了这是讨论 request_threaded_irq 的线程,但我没有得到任何回复。所以我新鲜发布它。

我正在开发电容式触摸屏的触摸屏驱动程序。它使用 request_threaded_irq() 调用而不是 request_irq()。我无法理解两者之间的基本区别。它说: -

名称

request_threaded_irq - 分配中断线

概要

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);

参数

  1. irq - 分配处理程序的中断线
  2. - 发生 IRQ 时调用的函数。线程中断的主处理程序 如果为 NULL 且 thread_fn != NULL,则安装默认主处理程序
  3. thread_fn - 从 irq 处理程序线程调用的函数 如果为 NULL,则不会创建 irq 线程
  4. irqflags - 中断类型标志
  5. 的 ASCII 名称
  6. devname - 声明设备的dev_id - cookie 传递回处理函数,

Handler 和 Thread_fn 参数是令人困惑的。驱动程序中也没有定义工作函数。

这是我引用的驱动程序。

可以有人帮助我理解这一点吗?

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.

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 :-

Name

request_threaded_irq — allocate an interrupt line

Synopsis

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

  1. irq - Interrupt line to allocate
  2. handler - Function to be called when the IRQ occurs. Primary handler for threaded interrupts If NULL and thread_fn != NULL the default primary handler is installed
  3. thread_fn - Function called from the irq handler thread If NULL, no irq thread is created
  4. irqflags - Interrupt type flags
  5. devname - An ascii name for the claiming device
  6. dev_id - A cookie passed back to the handler function

the Handler and Thread_fn arguments are the ones which are confusing. Also there is no work function defined in the driver.

Here is the driver which I am refering to.

Can somebody help me in understanding this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沦落红尘 2024-12-15 18:43:57

添加了 request_threaded_irq() 函数,以允许开发人员将中断处理代码分为两部分。第一部分将在中断被阻止的情况下执行,第二部分可以由内核线程在没有中断被阻止的情况下执行。有关原因的详细信息,您可以阅读以下内容:

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

在您的情况下,您链接到的驱动程序执行以下操作:

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

通过为第二个参数“处理程序”传递 NULL,将参数传递给 thread_fn,或者当中断发生时将调用函数 cy8ctmg110_irq_thread()检测到。

对于您来说,选择哪个请求 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);

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.

For you, choosing which request irq function will depend on what your driver needs to do in interrupt context.

很酷又爱笑 2024-12-15 18:43:57

另一个重要的方面:“如果你想为你的设备设置一个线程中断处理程序,那么你需要提供处理程序和thread_fn。处理程序仍然在硬中断上下文中调用,并且必须检查中断是否源自设备。如果是< strong>它需要禁用设备上的中断并返回 IRQ_WAKE_THREAD,这将唤醒处理程序线程并运行 thread_fn。”

来源:https://www.kernel.org/doc/htmldocs/genericirq.html

Another important aspect: "If you want to set up a threaded irq handler for your device then you need to supply handler and thread_fn. handler is still called in hard interrupt context and has to check whether the interrupt originates from the device. If yes it needs to disable the interrupt on the device and return IRQ_WAKE_THREAD which will wake up the handler thread and run thread_fn."

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文