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