summaryrefslogtreecommitdiffstats
path: root/net/atm/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/atm/proc.c')
-rw-r--r--net/atm/proc.c131
1 files changed, 17 insertions, 114 deletions
diff --git a/net/atm/proc.c b/net/atm/proc.c
index 55410c00c7e2..0b0495a41bbe 100644
--- a/net/atm/proc.c
+++ b/net/atm/proc.c
@@ -68,7 +68,6 @@ static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
68struct vcc_state { 68struct vcc_state {
69 int bucket; 69 int bucket;
70 struct sock *sk; 70 struct sock *sk;
71 int family;
72}; 71};
73 72
74static inline int compare_family(struct sock *sk, int family) 73static inline int compare_family(struct sock *sk, int family)
@@ -106,23 +105,13 @@ out:
106 return (l < 0); 105 return (l < 0);
107} 106}
108 107
109static inline void *vcc_walk(struct vcc_state *state, loff_t l) 108static inline void *vcc_walk(struct seq_file *seq, loff_t l)
110{ 109{
111 return __vcc_walk(&state->sk, state->family, &state->bucket, l) ? 110 struct vcc_state *state = seq->private;
112 state : NULL; 111 int family = (uintptr_t)(PDE_DATA(file_inode(seq->file)));
113}
114
115static int __vcc_seq_open(struct inode *inode, struct file *file,
116 int family, const struct seq_operations *ops)
117{
118 struct vcc_state *state;
119
120 state = __seq_open_private(file, ops, sizeof(*state));
121 if (state == NULL)
122 return -ENOMEM;
123 112
124 state->family = family; 113 return __vcc_walk(&state->sk, family, &state->bucket, l) ?
125 return 0; 114 state : NULL;
126} 115}
127 116
128static void *vcc_seq_start(struct seq_file *seq, loff_t *pos) 117static void *vcc_seq_start(struct seq_file *seq, loff_t *pos)
@@ -133,7 +122,7 @@ static void *vcc_seq_start(struct seq_file *seq, loff_t *pos)
133 122
134 read_lock(&vcc_sklist_lock); 123 read_lock(&vcc_sklist_lock);
135 state->sk = SEQ_START_TOKEN; 124 state->sk = SEQ_START_TOKEN;
136 return left ? vcc_walk(state, left) : SEQ_START_TOKEN; 125 return left ? vcc_walk(seq, left) : SEQ_START_TOKEN;
137} 126}
138 127
139static void vcc_seq_stop(struct seq_file *seq, void *v) 128static void vcc_seq_stop(struct seq_file *seq, void *v)
@@ -144,9 +133,7 @@ static void vcc_seq_stop(struct seq_file *seq, void *v)
144 133
145static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos) 134static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
146{ 135{
147 struct vcc_state *state = seq->private; 136 v = vcc_walk(seq, 1);
148
149 v = vcc_walk(state, 1);
150 *pos += !!PTR_ERR(v); 137 *pos += !!PTR_ERR(v);
151 return v; 138 return v;
152} 139}
@@ -257,18 +244,6 @@ static const struct seq_operations atm_dev_seq_ops = {
257 .show = atm_dev_seq_show, 244 .show = atm_dev_seq_show,
258}; 245};
259 246
260static int atm_dev_seq_open(struct inode *inode, struct file *file)
261{
262 return seq_open(file, &atm_dev_seq_ops);
263}
264
265static const struct file_operations devices_seq_fops = {
266 .open = atm_dev_seq_open,
267 .read = seq_read,
268 .llseek = seq_lseek,
269 .release = seq_release,
270};
271
272static int pvc_seq_show(struct seq_file *seq, void *v) 247static int pvc_seq_show(struct seq_file *seq, void *v)
273{ 248{
274 static char atm_pvc_banner[] = 249 static char atm_pvc_banner[] =
@@ -292,18 +267,6 @@ static const struct seq_operations pvc_seq_ops = {
292 .show = pvc_seq_show, 267 .show = pvc_seq_show,
293}; 268};
294 269
295static int pvc_seq_open(struct inode *inode, struct file *file)
296{
297 return __vcc_seq_open(inode, file, PF_ATMPVC, &pvc_seq_ops);
298}
299
300static const struct file_operations pvc_seq_fops = {
301 .open = pvc_seq_open,
302 .read = seq_read,
303 .llseek = seq_lseek,
304 .release = seq_release_private,
305};
306
307static int vcc_seq_show(struct seq_file *seq, void *v) 270static int vcc_seq_show(struct seq_file *seq, void *v)
308{ 271{
309 if (v == SEQ_START_TOKEN) { 272 if (v == SEQ_START_TOKEN) {
@@ -326,18 +289,6 @@ static const struct seq_operations vcc_seq_ops = {
326 .show = vcc_seq_show, 289 .show = vcc_seq_show,
327}; 290};
328 291
329static int vcc_seq_open(struct inode *inode, struct file *file)
330{
331 return __vcc_seq_open(inode, file, 0, &vcc_seq_ops);
332}
333
334static const struct file_operations vcc_seq_fops = {
335 .open = vcc_seq_open,
336 .read = seq_read,
337 .llseek = seq_lseek,
338 .release = seq_release_private,
339};
340
341static int svc_seq_show(struct seq_file *seq, void *v) 292static int svc_seq_show(struct seq_file *seq, void *v)
342{ 293{
343 static const char atm_svc_banner[] = 294 static const char atm_svc_banner[] =
@@ -361,18 +312,6 @@ static const struct seq_operations svc_seq_ops = {
361 .show = svc_seq_show, 312 .show = svc_seq_show,
362}; 313};
363 314
364static int svc_seq_open(struct inode *inode, struct file *file)
365{
366 return __vcc_seq_open(inode, file, PF_ATMSVC, &svc_seq_ops);
367}
368
369static const struct file_operations svc_seq_fops = {
370 .open = svc_seq_open,
371 .read = seq_read,
372 .llseek = seq_lseek,
373 .release = seq_release_private,
374};
375
376static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, 315static ssize_t proc_dev_atm_read(struct file *file, char __user *buf,
377 size_t count, loff_t *pos) 316 size_t count, loff_t *pos)
378{ 317{
@@ -440,58 +379,22 @@ void atm_proc_dev_deregister(struct atm_dev *dev)
440 kfree(dev->proc_name); 379 kfree(dev->proc_name);
441} 380}
442 381
443static struct atm_proc_entry {
444 char *name;
445 const struct file_operations *proc_fops;
446 struct proc_dir_entry *dirent;
447} atm_proc_ents[] = {
448 { .name = "devices", .proc_fops = &devices_seq_fops },
449 { .name = "pvc", .proc_fops = &pvc_seq_fops },
450 { .name = "svc", .proc_fops = &svc_seq_fops },
451 { .name = "vc", .proc_fops = &vcc_seq_fops },
452 { .name = NULL, .proc_fops = NULL }
453};
454
455static void atm_proc_dirs_remove(void)
456{
457 static struct atm_proc_entry *e;
458
459 for (e = atm_proc_ents; e->name; e++) {
460 if (e->dirent)
461 remove_proc_entry(e->name, atm_proc_root);
462 }
463 remove_proc_entry("atm", init_net.proc_net);
464}
465
466int __init atm_proc_init(void) 382int __init atm_proc_init(void)
467{ 383{
468 static struct atm_proc_entry *e;
469 int ret;
470
471 atm_proc_root = proc_net_mkdir(&init_net, "atm", init_net.proc_net); 384 atm_proc_root = proc_net_mkdir(&init_net, "atm", init_net.proc_net);
472 if (!atm_proc_root) 385 if (!atm_proc_root)
473 goto err_out; 386 return -ENOMEM;
474 for (e = atm_proc_ents; e->name; e++) { 387 proc_create_seq("devices", 0444, atm_proc_root, &atm_dev_seq_ops);
475 struct proc_dir_entry *dirent; 388 proc_create_seq_private("pvc", 0444, atm_proc_root, &pvc_seq_ops,
476 389 sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMPVC);
477 dirent = proc_create(e->name, 0444, 390 proc_create_seq_private("svc", 0444, atm_proc_root, &svc_seq_ops,
478 atm_proc_root, e->proc_fops); 391 sizeof(struct vcc_state), (void *)(uintptr_t)PF_ATMSVC);
479 if (!dirent) 392 proc_create_seq_private("vc", 0444, atm_proc_root, &vcc_seq_ops,
480 goto err_out_remove; 393 sizeof(struct vcc_state), NULL);
481 e->dirent = dirent; 394 return 0;
482 }
483 ret = 0;
484out:
485 return ret;
486
487err_out_remove:
488 atm_proc_dirs_remove();
489err_out:
490 ret = -ENOMEM;
491 goto out;
492} 395}
493 396
494void atm_proc_exit(void) 397void atm_proc_exit(void)
495{ 398{
496 atm_proc_dirs_remove(); 399 remove_proc_subtree("atm", init_net.proc_net);
497} 400}