aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nubus/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/nubus/proc.c')
-rw-r--r--drivers/nubus/proc.c80
1 files changed, 76 insertions, 4 deletions
diff --git a/drivers/nubus/proc.c b/drivers/nubus/proc.c
index 208dd12825bc..b8286ed65919 100644
--- a/drivers/nubus/proc.c
+++ b/drivers/nubus/proc.c
@@ -52,7 +52,6 @@ static int nubus_devices_proc_open(struct inode *inode, struct file *file)
52} 52}
53 53
54static const struct file_operations nubus_devices_proc_fops = { 54static const struct file_operations nubus_devices_proc_fops = {
55 .owner = THIS_MODULE,
56 .open = nubus_devices_proc_open, 55 .open = nubus_devices_proc_open,
57 .read = seq_read, 56 .read = seq_read,
58 .llseek = seq_lseek, 57 .llseek = seq_lseek,
@@ -61,6 +60,10 @@ static const struct file_operations nubus_devices_proc_fops = {
61 60
62static struct proc_dir_entry *proc_bus_nubus_dir; 61static struct proc_dir_entry *proc_bus_nubus_dir;
63 62
63static const struct file_operations nubus_proc_subdir_fops = {
64#warning Need to set some I/O handlers here
65};
66
64static void nubus_proc_subdir(struct nubus_dev* dev, 67static void nubus_proc_subdir(struct nubus_dev* dev,
65 struct proc_dir_entry* parent, 68 struct proc_dir_entry* parent,
66 struct nubus_dir* dir) 69 struct nubus_dir* dir)
@@ -73,9 +76,10 @@ static void nubus_proc_subdir(struct nubus_dev* dev,
73 struct proc_dir_entry* e; 76 struct proc_dir_entry* e;
74 77
75 sprintf(name, "%x", ent.type); 78 sprintf(name, "%x", ent.type);
76 e = create_proc_entry(name, S_IFREG | S_IRUGO | 79 e = proc_create(name, S_IFREG | S_IRUGO | S_IWUSR, parent,
77 S_IWUSR, parent); 80 &nubus_proc_subdir_fops);
78 if (!e) return; 81 if (!e)
82 return;
79 } 83 }
80} 84}
81 85
@@ -158,6 +162,73 @@ int nubus_proc_detach_device(struct nubus_dev *dev)
158} 162}
159EXPORT_SYMBOL(nubus_proc_detach_device); 163EXPORT_SYMBOL(nubus_proc_detach_device);
160 164
165/*
166 * /proc/nubus stuff
167 */
168static int nubus_proc_show(struct seq_file *m, void *v)
169{
170 const struct nubus_board *board = v;
171
172 /* Display header on line 1 */
173 if (v == SEQ_START_TOKEN)
174 seq_puts(m, "Nubus devices found:\n");
175 else
176 seq_printf(m, "Slot %X: %s\n", board->slot, board->name);
177 return 0;
178}
179
180static void *nubus_proc_start(struct seq_file *m, loff_t *_pos)
181{
182 struct nubus_board *board;
183 unsigned pos;
184
185 if (*_pos > LONG_MAX)
186 return NULL;
187 pos = *_pos;
188 if (pos == 0)
189 return SEQ_START_TOKEN;
190 for (board = nubus_boards; board; board = board->next)
191 if (--pos == 0)
192 break;
193 return board;
194}
195
196static void *nubus_proc_next(struct seq_file *p, void *v, loff_t *_pos)
197{
198 /* Walk the list of NuBus boards */
199 struct nubus_board *board = v;
200
201 ++*_pos;
202 if (v == SEQ_START_TOKEN)
203 board = nubus_boards;
204 else if (board)
205 board = board->next;
206 return board;
207}
208
209static void nubus_proc_stop(struct seq_file *p, void *v)
210{
211}
212
213static const struct seq_operations nubus_proc_seqops = {
214 .start = nubus_proc_start,
215 .next = nubus_proc_next,
216 .stop = nubus_proc_stop,
217 .show = nubus_proc_show,
218};
219
220static int nubus_proc_open(struct inode *inode, struct file *file)
221{
222 return seq_open(file, &nubus_proc_seqops);
223}
224
225static const struct file_operations nubus_proc_fops = {
226 .open = nubus_proc_open,
227 .read = seq_read,
228 .llseek = seq_lseek,
229 .release = seq_release,
230};
231
161void __init proc_bus_nubus_add_devices(void) 232void __init proc_bus_nubus_add_devices(void)
162{ 233{
163 struct nubus_dev *dev; 234 struct nubus_dev *dev;
@@ -168,6 +239,7 @@ void __init proc_bus_nubus_add_devices(void)
168 239
169void __init nubus_proc_init(void) 240void __init nubus_proc_init(void)
170{ 241{
242 proc_create("nubus", 0, NULL, &nubus_proc_fops);
171 if (!MACH_IS_MAC) 243 if (!MACH_IS_MAC)
172 return; 244 return;
173 proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL); 245 proc_bus_nubus_dir = proc_mkdir("bus/nubus", NULL);