interrupts.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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);