Commit d6917e19f3fda8e1f88bc23ddceed952927bd716
1 parent
df8106dbb5
proc: move /proc/interrupts boilerplate code to fs/proc/interrupts.c
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Showing 3 changed files with 54 additions and 40 deletions Side-by-side Diff
fs/proc/Makefile
fs/proc/interrupts.c
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
... | ... | @@ -198,45 +198,6 @@ |
198 | 198 | }; |
199 | 199 | #endif |
200 | 200 | |
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 | - | |
240 | 201 | #ifdef CONFIG_PROC_PAGE_MONITOR |
241 | 202 | #define KPMSIZE sizeof(u64) |
242 | 203 | #define KPMMASK (KPMSIZE - 1) |
... | ... | @@ -375,7 +336,6 @@ |
375 | 336 | proc_symlink("mounts", NULL, "self/mounts"); |
376 | 337 | |
377 | 338 | /* And now for trickier ones */ |
378 | - proc_create("interrupts", 0, NULL, &proc_interrupts_operations); | |
379 | 339 | #ifdef CONFIG_SLABINFO |
380 | 340 | proc_create("slabinfo",S_IWUSR|S_IRUGO,NULL,&proc_slabinfo_operations); |
381 | 341 | #ifdef CONFIG_DEBUG_SLAB_LEAK |