diff options
Diffstat (limited to 'drivers/zorro/proc.c')
-rw-r--r-- | drivers/zorro/proc.c | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c index b7a8c7b7f66e..1b4317d7d7aa 100644 --- a/drivers/zorro/proc.c +++ b/drivers/zorro/proc.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/zorro.h> | 14 | #include <linux/zorro.h> |
15 | #include <linux/proc_fs.h> | 15 | #include <linux/proc_fs.h> |
16 | #include <linux/seq_file.h> | ||
16 | #include <linux/init.h> | 17 | #include <linux/init.h> |
17 | #include <linux/smp_lock.h> | 18 | #include <linux/smp_lock.h> |
18 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
@@ -80,32 +81,53 @@ static const struct file_operations proc_bus_zorro_operations = { | |||
80 | .read = proc_bus_zorro_read, | 81 | .read = proc_bus_zorro_read, |
81 | }; | 82 | }; |
82 | 83 | ||
83 | static int | 84 | static void * zorro_seq_start(struct seq_file *m, loff_t *pos) |
84 | get_zorro_dev_info(char *buf, char **start, off_t pos, int count) | ||
85 | { | 85 | { |
86 | u_int slot; | 86 | return (*pos < zorro_num_autocon) ? pos : NULL; |
87 | off_t at = 0; | 87 | } |
88 | int len, cnt; | 88 | |
89 | 89 | static void * zorro_seq_next(struct seq_file *m, void *v, loff_t *pos) | |
90 | for (slot = cnt = 0; slot < zorro_num_autocon && count > cnt; slot++) { | 90 | { |
91 | struct zorro_dev *z = &zorro_autocon[slot]; | 91 | (*pos)++; |
92 | len = sprintf(buf, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot, | 92 | return (*pos < zorro_num_autocon) ? pos : NULL; |
93 | z->id, (unsigned long)zorro_resource_start(z), | 93 | } |
94 | (unsigned long)zorro_resource_len(z), | 94 | |
95 | z->rom.er_Type); | 95 | static void zorro_seq_stop(struct seq_file *m, void *v) |
96 | at += len; | 96 | { |
97 | if (at >= pos) { | 97 | } |
98 | if (!*start) { | 98 | |
99 | *start = buf + (pos - (at - len)); | 99 | static int zorro_seq_show(struct seq_file *m, void *v) |
100 | cnt = at - pos; | 100 | { |
101 | } else | 101 | u_int slot = *(loff_t *)v; |
102 | cnt += len; | 102 | struct zorro_dev *z = &zorro_autocon[slot]; |
103 | buf += len; | 103 | |
104 | } | 104 | seq_printf(m, "%02x\t%08x\t%08lx\t%08lx\t%02x\n", slot, z->id, |
105 | } | 105 | (unsigned long)zorro_resource_start(z), |
106 | return (count > cnt) ? cnt : count; | 106 | (unsigned long)zorro_resource_len(z), |
107 | z->rom.er_Type); | ||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static const struct seq_operations zorro_devices_seq_ops = { | ||
112 | .start = zorro_seq_start, | ||
113 | .next = zorro_seq_next, | ||
114 | .stop = zorro_seq_stop, | ||
115 | .show = zorro_seq_show, | ||
116 | }; | ||
117 | |||
118 | static int zorro_devices_proc_open(struct inode *inode, struct file *file) | ||
119 | { | ||
120 | return seq_open(file, &zorro_devices_seq_ops); | ||
107 | } | 121 | } |
108 | 122 | ||
123 | static const struct file_operations zorro_devices_proc_fops = { | ||
124 | .owner = THIS_MODULE, | ||
125 | .open = zorro_devices_proc_open, | ||
126 | .read = seq_read, | ||
127 | .llseek = seq_lseek, | ||
128 | .release = seq_release, | ||
129 | }; | ||
130 | |||
109 | static struct proc_dir_entry *proc_bus_zorro_dir; | 131 | static struct proc_dir_entry *proc_bus_zorro_dir; |
110 | 132 | ||
111 | static int __init zorro_proc_attach_device(u_int slot) | 133 | static int __init zorro_proc_attach_device(u_int slot) |
@@ -129,8 +151,8 @@ static int __init zorro_proc_init(void) | |||
129 | 151 | ||
130 | if (MACH_IS_AMIGA && AMIGAHW_PRESENT(ZORRO)) { | 152 | if (MACH_IS_AMIGA && AMIGAHW_PRESENT(ZORRO)) { |
131 | proc_bus_zorro_dir = proc_mkdir("bus/zorro", NULL); | 153 | proc_bus_zorro_dir = proc_mkdir("bus/zorro", NULL); |
132 | create_proc_info_entry("devices", 0, proc_bus_zorro_dir, | 154 | proc_create("devices", 0, proc_bus_zorro_dir, |
133 | get_zorro_dev_info); | 155 | &zorro_devices_proc_fops); |
134 | for (slot = 0; slot < zorro_num_autocon; slot++) | 156 | for (slot = 0; slot < zorro_num_autocon; slot++) |
135 | zorro_proc_attach_device(slot); | 157 | zorro_proc_attach_device(slot); |
136 | } | 158 | } |