Kyle Swenson | 8d8f654 | 2021-03-15 11:02:55 -0600 | [diff] [blame^] | 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 | /* |
| 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 | |
| 16 | static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos) |
| 17 | { |
| 18 | (*pos)++; |
| 19 | if (*pos > nr_irqs) |
| 20 | return NULL; |
| 21 | return pos; |
| 22 | } |
| 23 | |
| 24 | static void int_seq_stop(struct seq_file *f, void *v) |
| 25 | { |
| 26 | /* Nothing to do */ |
| 27 | } |
| 28 | |
| 29 | static const struct seq_operations int_seq_ops = { |
| 30 | .start = int_seq_start, |
| 31 | .next = int_seq_next, |
| 32 | .stop = int_seq_stop, |
| 33 | .show = show_interrupts |
| 34 | }; |
| 35 | |
| 36 | static int interrupts_open(struct inode *inode, struct file *filp) |
| 37 | { |
| 38 | return seq_open(filp, &int_seq_ops); |
| 39 | } |
| 40 | |
| 41 | static const struct file_operations proc_interrupts_operations = { |
| 42 | .open = interrupts_open, |
| 43 | .read = seq_read, |
| 44 | .llseek = seq_lseek, |
| 45 | .release = seq_release, |
| 46 | }; |
| 47 | |
| 48 | static int __init proc_interrupts_init(void) |
| 49 | { |
| 50 | proc_create("interrupts", 0, NULL, &proc_interrupts_operations); |
| 51 | return 0; |
| 52 | } |
| 53 | fs_initcall(proc_interrupts_init); |