irq.c 867 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. TODO: get handler running multiple times on some existing interrupt from /proc/interrupts.
  3. */
  4. #include <linux/interrupt.h>
  5. #include <linux/jiffies.h>
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. MODULE_LICENSE("GPL");
  9. /**
  10. * Return value from kernel docs:*
  11. *
  12. * enum irqreturn
  13. * @IRQ_NON interrupt was not from this device or was not handled
  14. * @IRQ_HANDLED interrupt was handled by this device
  15. * @IRQ_WAKE_THREAD handler requests to wake the handler thread
  16. */
  17. static irqreturn_t handler(int i, void *v)
  18. {
  19. pr_info("handler %llu\n", (unsigned long long)jiffies);
  20. return IRQ_HANDLED;
  21. }
  22. static int myinit(void)
  23. {
  24. irqreturn_t r;
  25. r = request_irq(
  26. 1,
  27. handler,
  28. IRQF_SHARED,
  29. "myirqhandler0",
  30. 0
  31. );
  32. pr_info("request_irq %llu\n", (unsigned long long)r);
  33. return 0;
  34. }
  35. static void myexit(void)
  36. {
  37. }
  38. module_init(myinit)
  39. module_exit(myexit)