Request_irq ()

Source: Internet
Author: User

Note: The flags value of the interrupt parameter may vary with Linux kernel versions. For details, see Linux/interrupt. h, Linux/IRQ. H and ASM/IRQ. h.

The request_irq () function is used in both the 2.4 and 2.6 Kernels to register interrupt service functions. In the 2.4 kernel, the header file to be included is # include <Linux/sched. h>, and the header file to be included in the 2.6 kernel is
# Include <Linux/interrupt. h>. The function prototype is as follows:

2.4 kernel int request_irq (unsigned int IRQ, void (* Handler) (INT, void *, struct pt_regs *), unsigned long frags, const char * device, void * dev_id ); 2.6 kernel request_irq (unsigned int IRQ, irq_handler_t handler, unsigned long flags, const char * Name, void * Dev );

Parameter description:

In the event of an interrupt corresponding to the 1st IRQ parameter, call the interrupt service function specified by the handler parameter (that is, set the Custom Handler () interrupt service functions are registered in the kernel ).

The 3rd parameter flags specifies the Interrupt Processing attribute, such as fast interrupt or interrupt sharing.

In the new kernel (Versions later than 2.6.19), define the macro for this parameter in Linux/interrupt. H, for example:

Reference

/** These flags used only by the kernel as part of the* irq handling routines.** IRQF_DISABLED - keep irqs disabled when calling the action handler* IRQF_SAMPLE_RANDOM - irq is used to feed the random generator* IRQF_SHARED - allow sharing the irq among several devices* IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur* IRQF_TIMER - Flag to mark this interrupt as timer interrupt* IRQF_PERCPU - Interrupt is per cpu* IRQF_NOBALANCING - Flag to exclude this interrupt from irq balancing* IRQF_IRQPOLL - Interrupt is used for polling (only the interrupt that is*                registered first in an shared interrupt is considered for*                performance reasons)*/#define IRQF_DISABLED           0x00000020#define IRQF_SAMPLE_RANDOM      0x00000040#define IRQF_SHARED             0x00000080#define IRQF_PROBE_SHARED       0x00000100#define IRQF_TIMER              0x00000200#define IRQF_PERCPU             0x00000400#define IRQF_NOBALANCING        0x00000800#define IRQF_IRQPOLL            0x00001000

The 4th parameter name is usually the name of the device driver. The value change is used in/proc/Interrupt System (virtual) files, or in case of kernel interruption errors, and the custom "XXX" is used ".

The 5th dev_id parameter can be used as the interrupt difference parameter during shared interruption, or used to specify the data address to be referenced by the interrupt service function.

Return Value:
If the function runs normally, 0 is returned. Otherwise, the negative value of the corresponding error is returned.

typedef int irqreturn_t;#define IRQ_NONE        (0)#define IRQ_HANDLED     (1)#define IRQ_RETVAL(x)   ((x) != 0)

Source: http://hi.baidu.com/pchwuhan/blog/item/0251051a820a5562dab4bd4b.html

Http://hi.baidu.com/zengzhaonong/blog/item/3b9f5e34a2b0954b241f1424.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.