Skip to content

Commit d6917e1

Browse files
author
Alexey Dobriyan
committed
proc: move /proc/interrupts boilerplate code to fs/proc/interrupts.c
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
1 parent df8106d commit d6917e1

3 files changed

Lines changed: 54 additions & 40 deletions

File tree

‎fs/proc/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ proc-y += inode.o root.o base.o generic.o array.o \
1212
proc-y += cmdline.o
1313
proc-y += cpuinfo.o
1414
proc-y += devices.o
15+
proc-y += interrupts.o
1516
proc-y += loadavg.o
1617
proc-y += meminfo.o
1718
proc-y += stat.o

‎fs/proc/interrupts.c‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
module_init(proc_interrupts_init);

‎fs/proc/proc_misc.c‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -198,45 +198,6 @@ static const struct file_operations proc_vmalloc_operations = {
198198
};
199199
#endif
200200

201-
/*
202-
* /proc/interrupts
203-
*/
204-
static void *int_seq_start(struct seq_file *f, loff_t *pos)
205-
{
206-
return (*pos <= nr_irqs) ? pos : NULL;
207-
}
208-
209-
210-
static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
211-
{
212-
(*pos)++;
213-
return (*pos <= nr_irqs) ? pos : NULL;
214-
}
215-
216-
static void int_seq_stop(struct seq_file *f, void *v)
217-
{
218-
/* Nothing to do */
219-
}
220-
221-
static const struct seq_operations int_seq_ops = {
222-
.start = int_seq_start,
223-
.next = int_seq_next,
224-
.stop = int_seq_stop,
225-
.show = show_interrupts
226-
};
227-
228-
static int interrupts_open(struct inode *inode, struct file *filp)
229-
{
230-
return seq_open(filp, &int_seq_ops);
231-
}
232-
233-
static const struct file_operations proc_interrupts_operations = {
234-
.open = interrupts_open,
235-
.read = seq_read,
236-
.llseek = seq_lseek,
237-
.release = seq_release,
238-
};
239-
240201
#ifdef CONFIG_PROC_PAGE_MONITOR
241202
#define KPMSIZE sizeof(u64)
242203
#define KPMMASK (KPMSIZE - 1)
@@ -375,7 +336,6 @@ void __init proc_misc_init(void)
375336
proc_symlink("mounts", NULL, "self/mounts");
376337

377338
/* And now for trickier ones */
378-
proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
379339
#ifdef CONFIG_SLABINFO
380340
proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations);
381341
#ifdef CONFIG_DEBUG_SLAB_LEAK

0 commit comments

Comments
 (0)