diff options
author | Alexey Dobriyan <adobriyan@sw.ru> | 2008-04-29 04:01:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:19 -0400 |
commit | 076ec04b8ac84a04df67840f15f36218d7519510 (patch) | |
tree | 3c1e0ca629bed45cd7f642f2648dd3606e714386 | |
parent | 3ae02d6bc1c1b3784fec9e9e016e7e3dcc2f8727 (diff) |
proc: convert /proc/bus/nubus to seq_file interface
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/nubus/proc.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c index cb83acef947..208dd12825b 100644 --- a/drivers/nubus/proc.c +++ b/drivers/nubus/proc.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/nubus.h> | 22 | #include <linux/nubus.h> |
23 | #include <linux/proc_fs.h> | 23 | #include <linux/proc_fs.h> |
24 | #include <linux/seq_file.h> | ||
24 | #include <linux/init.h> | 25 | #include <linux/init.h> |
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
26 | 27 | ||
@@ -28,38 +29,36 @@ | |||
28 | #include <asm/byteorder.h> | 29 | #include <asm/byteorder.h> |
29 | 30 | ||
30 | static int | 31 | static int |
31 | get_nubus_dev_info(char *buf, char **start, off_t pos, int count) | 32 | nubus_devices_proc_show(struct seq_file *m, void *v) |
32 | { | 33 | { |
33 | struct nubus_dev *dev = nubus_devices; | 34 | struct nubus_dev *dev = nubus_devices; |
34 | off_t at = 0; | ||
35 | int len, cnt; | ||
36 | 35 | ||
37 | cnt = 0; | 36 | while (dev) { |
38 | while (dev && count > cnt) { | 37 | seq_printf(m, "%x\t%04x %04x %04x %04x", |
39 | len = sprintf(buf, "%x\t%04x %04x %04x %04x", | ||
40 | dev->board->slot, | 38 | dev->board->slot, |
41 | dev->category, | 39 | dev->category, |
42 | dev->type, | 40 | dev->type, |
43 | dev->dr_sw, | 41 | dev->dr_sw, |
44 | dev->dr_hw); | 42 | dev->dr_hw); |
45 | len += sprintf(buf+len, | 43 | seq_printf(m, "\t%08lx\n", dev->board->slot_addr); |
46 | "\t%08lx", | ||
47 | dev->board->slot_addr); | ||
48 | buf[len++] = '\n'; | ||
49 | at += len; | ||
50 | if (at >= pos) { | ||
51 | if (!*start) { | ||
52 | *start = buf + (pos - (at - len)); | ||
53 | cnt = at - pos; | ||
54 | } else | ||
55 | cnt += len; | ||
56 | buf += len; | ||
57 | } | ||
58 | dev = dev->next; | 44 | dev = dev->next; |
59 | } | 45 | } |
60 | return (count > cnt) ? cnt : count; | 46 | return 0; |
47 | } | ||
48 | |||
49 | static int nubus_devices_proc_open(struct inode *inode, struct file *file) | ||
50 | { | ||
51 | return single_open(file, nubus_devices_proc_show, NULL); | ||
61 | } | 52 | } |
62 | 53 | ||
54 | static const struct file_operations nubus_devices_proc_fops = { | ||
55 | .owner = THIS_MODULE, | ||
56 | .open = nubus_devices_proc_open, | ||
57 | .read = seq_read, | ||
58 | .llseek = seq_lseek, | ||
59 | .release = single_release, | ||
60 | }; | ||
61 | |||
63 | static struct proc_dir_entry *proc_bus_nubus_dir; | 62 | static struct proc_dir_entry *proc_bus_nubus_dir; |
64 | 63 | ||
65 | static void nubus_proc_subdir(struct nubus_dev* dev, | 64 | static void nubus_proc_subdir(struct nubus_dev* dev, |
@@ -172,7 +171,6 @@ void __init nubus_proc_init(void) | |||
172 | if (!MACH_IS_MAC) | 171 | if (!MACH_IS_MAC) |
173 | return; | 172 | return; |
174 | proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL); | 173 | proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL); |
175 | create_proc_info_entry("devices", 0, proc_bus_nubus_dir, | 174 | proc_create("devices", 0, proc_bus_nubus_dir, &nubus_devices_proc_fops); |
176 | get_nubus_dev_info); | ||
177 | proc_bus_nubus_add_devices(); | 175 | proc_bus_nubus_add_devices(); |
178 | } | 176 | } |