dummy-irq.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Dummy IRQ handler driver.
  3. *
  4. * This module only registers itself as a handler that is specified to it
  5. * by the 'irq' parameter.
  6. *
  7. * The sole purpose of this module is to help with debugging of systems on
  8. * which spurious IRQs would happen on disabled IRQ vector.
  9. *
  10. * Copyright (C) 2013 Jiri Kosina
  11. */
  12. /*
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License version 2 as published by
  15. * the Free Software Foundation.
  16. */
  17. #include <linux/module.h>
  18. #include <linux/irq.h>
  19. #include <linux/interrupt.h>
  20. static int irq = -1;
  21. static irqreturn_t dummy_interrupt(int irq, void *dev_id)
  22. {
  23. static int count = 0;
  24. if (count == 0) {
  25. printk(KERN_INFO "dummy-irq: interrupt occurred on IRQ %d\n",
  26. irq);
  27. count++;
  28. }
  29. return IRQ_NONE;
  30. }
  31. static int __init dummy_irq_init(void)
  32. {
  33. if (irq < 0) {
  34. printk(KERN_ERR "dummy-irq: no IRQ given. Use irq=N\n");
  35. return -EIO;
  36. }
  37. if (request_irq(irq, &dummy_interrupt, IRQF_SHARED, "dummy_irq", &irq)) {
  38. printk(KERN_ERR "dummy-irq: cannot register IRQ %d\n", irq);
  39. return -EIO;
  40. }
  41. printk(KERN_INFO "dummy-irq: registered for IRQ %d\n", irq);
  42. return 0;
  43. }
  44. static void __exit dummy_irq_exit(void)
  45. {
  46. printk(KERN_INFO "dummy-irq unloaded\n");
  47. free_irq(irq, &irq);
  48. }
  49. module_init(dummy_irq_init);
  50. module_exit(dummy_irq_exit);
  51. MODULE_LICENSE("GPL");
  52. MODULE_AUTHOR("Jiri Kosina");
  53. module_param(irq, uint, 0444);
  54. MODULE_PARM_DESC(irq, "The IRQ to register for");
  55. MODULE_DESCRIPTION("Dummy IRQ handler driver");