What does dmesg look like?
I would have made the variable var look like this “static int var;” Also, I would have added a proc to display the current value of var. Finally, I would have added something this to hello_init(): printk(“Entered hello_init().\n”); None of these things are strictly necessary, but that’s how I do it. . . Regards, Dave Chapman From: beagleboard@googlegroups.com [mailto:beagleboard@googlegroups.com] On Behalf Of santhosh205...@gmail.com Sent: Tuesday, October 30, 2018 1:58 AM To: BeagleBoard Subject: [beagleboard] Re: How to write GPIO interrupt handler in Linux device driver? It is working thank you On Sunday, January 25, 2015 at 8:24:39 PM UTC+5:30, TheInventor1993 wrote: I am writing GPIO Device Driver for linux 3.14 on Beagleboard XM (RevB). I have done with simple ON/OFF LED blinking. But stuck at interrupt handler implementation. BB XM has GPIO_7 pin connected to user button. Following is code sample I have implemented. But it is not working. I am able to insert module using insmod. Interrupt is also registered in /proc/interrupts. But handler is not getting invoked. Am I on right track? #include <linux/gpio.h> #include <linux/interrupt.h> #define GPIO 7 int var; static irqreturn_t irq_handler(int irq, void *dev_id) { var++; printk("In the Interrupt handler, Count: %d\n", var); return IRQ_HANDLED; } static int __init hello_init(void) { int errno, irq_line; if((errno = gpio_direction_input(GPIO)) !=0) { printk(KERN_INFO "Can't set GPIO direction, error %i\n", errno); gpio_free(GPIO); return -EINVAL; } irq_line = gpio_to_irq(GPIO); printk ("IRQ Line is %d \n",irq_line); errno = request_irq( irq_line, (irq_handler_t)irq_handler, IRQF_TRIGGER_FALLING, "Interrupt123", NULL ); if(errno<0) { printk(KERN_INFO "Problem requesting IRQ, error %i\n", errno); } return 0; } static void __exit hello_exit(void) { int irq_line; printk ("Unloading my module.\n"); irq_line = gpio_to_irq(GPIO); free_irq(irq_line,NULL); printk("Hello Example Exit\n"); return; } module_init(hello_init); module_exit(hello_exit); MODULE_AUTHOR("TheInventor"); MODULE_DESCRIPTION("Interrupt Module"); MODULE_LICENSE("GPL"); -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/830130c8-0310-4d3c-b0f8-d08caef6ccdf%40googlegroups.com <https://groups.google.com/d/msgid/beagleboard/830130c8-0310-4d3c-b0f8-d08caef6ccdf%40googlegroups.com?utm_medium=email&utm_source=footer> . For more options, visit https://groups.google.com/d/optout. -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/8581A3E2E4ACC34AB9898A268AB09C0806F17789%40exchange.aciusa. For more options, visit https://groups.google.com/d/optout.