interrupts.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <linux/fs.h>
  2. #include <linux/init.h>
  3. #include <linux/interrupt.h>
  4. #include <linux/irqnr.h>
  5. #include <linux/proc_fs.h>
  6. #include <linux/seq_file.h>
  7. /*
  8. * /proc/interrupts
  9. */
  10. static void *int_seq_start(struct seq_file *f, loff_t *pos)
  11. {
  12. return (*pos <= nr_irqs) ? pos : NULL;
  13. }
  14. static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
  15. {
  16. (*pos)++;
  17. if (*pos > nr_irqs)
  18. return NULL;
  19. return pos;
  20. }
  21. static void int_seq_stop(struct seq_file *f, void *v)
  22. {
  23. /* Nothing to do */
  24. }
  25. static const struct seq_operations int_seq_ops = {
  26. .start = int_seq_start,
  27. .next = int_seq_next,
  28. .stop = int_seq_stop,
  29. .show = show_interrupts
  30. };
  31. static int interrupts_open(struct inode *inode, struct file *filp)
  32. {
  33. return seq_open(filp, &int_seq_ops);
  34. }
  35. static const struct file_operations proc_interrupts_operations = {
  36. .open = interrupts_open,
  37. .read = seq_read,
  38. .llseek = seq_lseek,
  39. .release = seq_release,
  40. };
  41. static int __init proc_interrupts_init(void)
  42. {
  43. proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
  44. return 0;
  45. }
  46. fs_initcall(proc_interrupts_init);