eaded_irq - allocate an interrupt line
1008 * @irq: Interrupt line to allocate
1009 * @handler: Function to be called when the IRQ occurs.
1010 * Primary handler for threaded interrupts
1011 * If NULL and thread_fn != NULL the default
1012 * primary handler is installed
1013 * @thread_fn: Function called from the irq handler thread
1014 * If NULL, no irq thread is created
1015 * @irqflags: Interrupt type flags
1016 * @devname: An ascii name for the claiming device
1017 * @dev_id: A cookie passed back to the handler function
1018 *
1019 * This call allocates interrupt resources and enables the
1020 * interrupt line and IRQ handling. From the point this
1021 * call is made your handler function may be invoked. Since
1022 * your handler function must clear any interrupt the board
1023 * raises, you must take care both to initialise your hardware
1024 * and to set up the interrupt handler in the right order.
1025 *
1026 * If you want to set up a threaded irq handler for your device
1027 * then you need to supply @handler and @thread_fn. @handler ist
1028 * still called in hard interrupt context and has to check
1029 * whether the interrupt originates from the device. If yes it
1030 * needs to disable the interrupt on the device and return
1031 * IRQ_WAKE_THREAD which will wake up the handler thread and run
1032 * @thread_fn. This split handler design is necessary to support
1033 * shared interrupts.
1034 *
1035 * Dev_id must be globally unique. Normally the address of the
1036 * device data structure is used as the cookie. Since the handler
1037 * receives this value it makes sense to use it.
1038 *
1039 * If your interrupt is shared you must pass a non NULL dev_id
1040 * as this is required when freeing the interrupt.
1041 *
1042 * Flags:
1043 *
1044 * IRQF_SHARED Interrupt is shared
1045 * IRQF_SAMPLE_RANDOM The interrupt can be used for entropy
1046 * IRQF_TRIGGER_* Specify active edge(s) or level
1047 *
1048 */
5.首先分析request_threaded_irq()函数中的各个形参
1>:irq:表示申请的中断号。
2>:handler:表示中断服务例程
3.> thread_fn:中断线程化,此处传递的是NULL。NULL表示没有中断线程化。
此参数是最新版本中才出现的。为什么要提出中断线程化
在 Linux 中,中断具有最高的优先级。不论在任何时刻,只要产生中断事件,内核将立即执行相应的中断
处理程序,等到所有挂起的中断和软中断处理完毕后才能执行正常的任务,因此有可能造成实时任务得不
到及时的处理。中断线程化之后,中断将作为内核线程运行而且被赋予不同的实时优先级,实时任务可以
有比中断线程更高的优先级。这样,具有最高优先级的实时任务就能得到优先处理,即使在严重负载下仍
有实时性保证。but,并不是所有的中断都可以被线程化,比如时钟中断,主要用来维护系统时间以及定时器
等,其中定时器是操作系统的脉搏,一旦被线程化,就有可能被挂起,这样后果将不堪设想,所以不应当
被线程化。
4>.irqflags:表示中断标志位。
5>.devname:表示请求中断的设备的名称。
6>.dev_id: 对应于request_irq()函数中所传递的第五个参数,可取任意值,但必须唯一能够代表发出中断请求的设备,通常取描述该设备的结构体。 共享中断时所用。
现在继续迭代深入 request_threaded_irq()内部是如何实现的。
1049int request_threaded_irq(unsigned int irq, irq_handler_t handler,
1050 irq_handler_t thread_fn, unsigned long irqflags,
1051 const char *devname, void *dev_id)
1052{
1053 struct irqaction *action;
1054 struct irq_desc *desc;
1055 int retval;
1056
1057 /*
1058 * Sanity-check: shared interrupts must pass in a real dev-ID,
1059 * otherwise we'll have trouble later trying to figure out
1060 * which interrupt is which (messes up the interrupt freeing
1061 * logic etc).
1062 */
1063 if ((irqflags & IRQF_SHAR