"Passing Argument 2 0f" request_irq "from incompatible pointer type" causes the application to be interrupted and the module cannot be loaded.

Source: Internet
Author: User

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)

/********************************/


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.