Today, when we are on some key driver... After compilation, A warmming is displayed as follows:
Warning: Passing Argument 2 of 'request _ IRQ 'from incompatible pointer type
My request_irq function calls are as follows:
If (request_irq (key_info-> irq_no, key_eint_handler, ir1__disabled, "mini2440_key", & I ))
{
Return-1;
}
The prototype of the key_eint_handler function is as follows:
Static void key_eint_handler (int irq, void * dev_id, struct pt_regs * regs)
The alarm prompts that the second parameter pointer type does not match. I thought it was okay to find out why not match, that is, a warning...
And so on... A burst of searching through the network...
The result is...
The problem lies in
Prototype of the key_eint_handler function,
It should be caused:
Static void key_eint_handler (int irq, void * dev_id, struct pt_regs * regs) // incorrect syntax
Changed:
Static irqreturn_t key_eint_handler (int irq, void * dev_id) // write the statement correctly
Why?
According to the three parameters written in instructor song Baohua's book...
Start with the kernel source code...
In
Linux/include/Linux/interrupt. H, line 60 has such a definition.
Typedef irqreturn_t (* irq_handler_t) (INT, void *);
What does this definition mean?
It refers to the definition of a function pointer type irq_handler_t, the return type of this function is irqreturn_t, the list of parameters is int, void *
Let's take a look at the function declaration section of request_irq.
Kernel/IRQ/manage. C:
Int request_irq (
Unsigned int IRQ,
Irq_handler_t handler,
Unsigned long irqflags,
Const char * devname,
Void * dev_id)
The second parameter of request_irq is the handler function, whose type is irq_handler_t,
That is to say, the return type of my handler function is irq_handler_t,
Combined with the above-mentioned
Typedef irqreturn_t (* irq_handler_t) (INT, void *);
So...
The handler function should be written as follows:
Static irqreturn_t key_eint_handler (int irq, void * dev_id) // write the statement correctly
2 parameters... The returned type is irqreturn_t!
Changes in the request_irq () function prototype
The request_irq () function prototype in the Linux-2.6.22 is slightly changed with the previous version:
/********************************/
Linux-2.6.22.6
Include/Linux/irqreturn. h: typedef int irqreturn_t;
Include/Linux/interrupt. h: typedef irqreturn_t (* irq_handler_t) (INT, void *);
Kernel/IRQ/manage. C: int request_irq (
Unsigned int IRQ,
Irq_handler_t handler,
Unsigned long irqflags,
Const char * devname,
Void * dev_id)
/********************************/
Linux-2.6.13
Include/Linux/interrupt. h: typedef int irqreturn_t;
Kernel/IRQ/manage. C: int request_irq (
Unsigned int IRQ,
Irqreturn_t (* Handler) (INT, void *, struct pt_regs *),
Unsigned long irqflags,
Const char * devname,
Void * dev_id)
/********************************/