Commit e22f628395432b967f2f505858c64450f7835365
Committed by
Benjamin Herrenschmidt
1 parent
5a1eb5c445
Exists in
master
and in
7 other branches
Convert /proc/device-tree/ to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Showing 1 changed file with 21 additions and 20 deletions Side-by-side Diff
fs/proc/proc_devtree.c
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | #include <linux/init.h> |
8 | 8 | #include <linux/time.h> |
9 | 9 | #include <linux/proc_fs.h> |
10 | +#include <linux/seq_file.h> | |
10 | 11 | #include <linux/stat.h> |
11 | 12 | #include <linux/string.h> |
12 | 13 | #include <asm/prom.h> |
13 | 14 | |
14 | 15 | |
15 | 16 | |
... | ... | @@ -25,26 +26,27 @@ |
25 | 26 | /* |
26 | 27 | * Supply data on a read from /proc/device-tree/node/property. |
27 | 28 | */ |
28 | -static int property_read_proc(char *page, char **start, off_t off, | |
29 | - int count, int *eof, void *data) | |
29 | +static int property_proc_show(struct seq_file *m, void *v) | |
30 | 30 | { |
31 | - struct property *pp = data; | |
32 | - int n; | |
31 | + struct property *pp = m->private; | |
33 | 32 | |
34 | - if (off >= pp->length) { | |
35 | - *eof = 1; | |
36 | - return 0; | |
37 | - } | |
38 | - n = pp->length - off; | |
39 | - if (n > count) | |
40 | - n = count; | |
41 | - else | |
42 | - *eof = 1; | |
43 | - memcpy(page, (char *)pp->value + off, n); | |
44 | - *start = page; | |
45 | - return n; | |
33 | + seq_write(m, pp->value, pp->length); | |
34 | + return 0; | |
46 | 35 | } |
47 | 36 | |
37 | +static int property_proc_open(struct inode *inode, struct file *file) | |
38 | +{ | |
39 | + return single_open(file, property_proc_show, PDE(inode)->data); | |
40 | +} | |
41 | + | |
42 | +static const struct file_operations property_proc_fops = { | |
43 | + .owner = THIS_MODULE, | |
44 | + .open = property_proc_open, | |
45 | + .read = seq_read, | |
46 | + .llseek = seq_lseek, | |
47 | + .release = single_release, | |
48 | +}; | |
49 | + | |
48 | 50 | /* |
49 | 51 | * For a node with a name like "gc@10", we make symlinks called "gc" |
50 | 52 | * and "@10" to it. |
... | ... | @@ -63,10 +65,9 @@ |
63 | 65 | * Unfortunately proc_register puts each new entry |
64 | 66 | * at the beginning of the list. So we rearrange them. |
65 | 67 | */ |
66 | - ent = create_proc_read_entry(name, | |
67 | - strncmp(name, "security-", 9) | |
68 | - ? S_IRUGO : S_IRUSR, de, | |
69 | - property_read_proc, pp); | |
68 | + ent = proc_create_data(name, | |
69 | + strncmp(name, "security-", 9) ? S_IRUGO : S_IRUSR, | |
70 | + de, &property_proc_fops, pp); | |
70 | 71 | if (ent == NULL) |
71 | 72 | return NULL; |
72 | 73 |