I'm setting up a kernel interrupt handler with:
irq_result = request_irq(53, gpeds_hdlr, 0, "gpeds_hdlr", NULL);
Then, I'm defining my interrupt handler with:
irq_handler_t gpeds_hdlr(int irq, void *dev_id)
Compiler complains with:
/home/pi/module/mod_gpio.c: In function ‘init_function’:
/home/pi/module/mod_gpio.c:86:31: error: passing argument 2 of ‘request_irq’ from incompatible pointer type [-Werror=incompatible-pointer-types]
irq_result = request_irq(53, gpeds_hdlr, 0, "gpeds_hdlr", NULL);
^~~~~~~~~~
In file included from /home/pi/module/mod_gpio.c:1:
./include/linux/interrupt.h:157:45: note: expected ‘irq_handler_t’ {aka ‘enum irqreturn (*)(int, void *)’} but argument is of type ‘irqreturn_t (* (*)(int, void *))(int, void *)’ {aka ‘enum irqreturn (* (*)(int, void *))(int, void *)’}
request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
~~~~~~~~~~~~~~^~~~~~~
If I define my interrupt handler this way, as suggested by some online resources:
irqreturn_t gpeds_hdlr(int irq, void *dev_id, struct pt_regs *regs) {
Then I get a very similar compile error:
/home/pi/module/mod_gpio.c: In function ‘init_function’:
/home/pi/module/mod_gpio.c:85:31: error: passing argument 2 of ‘request_irq’ from incompatible pointer type [-Werror=incompatible-pointer-types]
irq_result = request_irq(53, gpeds_hdlr, 0, "gpeds_hdlr", NULL);
^~~~~~~~~~
In file included from /home/pi/module/mod_gpio.c:1:
./include/linux/interrupt.h:157:45: note: expected ‘irq_handler_t’ {aka ‘enum irqreturn (*)(int, void *)’} but argument is of type ‘irqreturn_t (*)(int, void *, struct pt_regs *)’ {aka ‘enum irqreturn (*)(int, void *, struct pt_regs *)’}
request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags,
~~~~~~~~~~~~~~^~~~~~~
How do I get past this?
Of note: linux/interrupt.h contains:
typedef irqreturn_t (*irq_handler_t)(int, void *);
and linux/irqreturn.h, included from linux/interrupt.h, contains:
typedef enum irqreturn irqreturn_t;
Thanks!
You should define your handler as following and pass handler to
request_irq().The second error of yours is because you are saying that handler receives 3 parameters while it's supposed to receive only two.
The first error is because that the definitions are wrong you say handler is returning
irq_handler_twhile it's supposed to returnirqreturn_twhich is a typedef for an enum. whileirq_handler_tis typedef for a function pointer.