the interrupt request caused by warning:passing argument 2 ' REQUEST_IRQ ' from incompatible pointer type has failed and this article has been transferred from: http://blog.sina.com . cn/s/blog_7321be1101012gek.html
Today in the driver of some key ... Write the compilation appears with a warmming as follows:
warning:passing argument 2 of ' REQUEST_IRQ ' from incompatible pointer type
My Request_irq function call is as follows:
if (Request_irq (Key_info->irq_no, Key_eint_handler, irqf_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 hint of the alarm means that the second parameter pointer type does not match. Originally feel that does not match is a warning does not matter, but later still want to find out why ...
So ..... A search through the network ...
The result came out ...
The problem is
The prototype of the Key_eint_handler function,
Should be by:
static void Key_eint_handler (int irq, void *dev_id,struct pt_regs *regs)//Wrong notation
To
static irqreturn_t key_eint_handler (int irq, void *dev_id)//correct notation
Why, then?
According to Song Baohua Teacher's book is written 3 parameters of the way ...
So from the core source code to start ...
In
Linux/include/linux/interrupt.h, there's a definition around line 60.
typedef irqreturn_t (*irq_handler_t) (int, void *);
What does this definition mean?
It means: Define a function pointer type irq_handler_t, the return type of this function is irqreturn_t, the argument list is int, void*
Let's look at the function Declarations 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, the type is irq_handler_t,
That is to say: I define the handler function return type of irq_handler_t,
In combination with the top one,
typedef irqreturn_t (*irq_handler_t) (int, void *);
So...
The handler function should be written as:
static irqreturn_t key_eint_handler (int irq, void *dev_id)//correct notation
2 parameters ... The return type is irqreturn_t is correct.
The above is personal understanding ...
Reference article link: http://topic.csdn.net/u/20090309/14/70503922-791a-42c3-abd0-529ec808d7d3.html
According to the information on the Internet, the following extracts:
changes in REQUEST_IRQ () function prototypes
The REQUEST_IRQ () function prototype in Linux-2.6.22 has a slight change from 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)
Source: http://www.cublog.cn/u3/102839/showart_2056392.html