Linux 中断学习之小试牛刀篇(8)

135request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,  
136            const char *name, void *dev)  
137{  
138        return request_threaded_irq(irq, handler, NULL, flags, name, dev);  
139}  
140 
 135request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
 136            const char *name, void *dev)
 137{
 138        return request_threaded_irq(irq, handler, NULL, flags, name, dev);
 139}
 140

可以看到request_irq()函数里面有封装了request_threaded_irq(irq, handler, NULL, flags, name, dev)函数。

先看一下官方的解释

1006/** 
1007 *      request_threaded_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 */ 
1006/**
1007 *      request_threaded_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 */
 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwszfw.html