interrupts.c 1.1 KB

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