diff options
Diffstat (limited to 'net/atm')
-rw-r--r-- | net/atm/proc.c | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/net/atm/proc.c b/net/atm/proc.c index ab8419a324b6..476779d845eb 100644 --- a/net/atm/proc.c +++ b/net/atm/proc.c | |||
@@ -24,15 +24,15 @@ | |||
24 | #include <linux/init.h> /* for __init */ | 24 | #include <linux/init.h> /* for __init */ |
25 | #include <net/net_namespace.h> | 25 | #include <net/net_namespace.h> |
26 | #include <net/atmclip.h> | 26 | #include <net/atmclip.h> |
27 | #include <asm/uaccess.h> | 27 | #include <linux/uaccess.h> |
28 | #include <linux/param.h> /* for HZ */ | ||
28 | #include <asm/atomic.h> | 29 | #include <asm/atomic.h> |
29 | #include <asm/param.h> /* for HZ */ | ||
30 | #include "resources.h" | 30 | #include "resources.h" |
31 | #include "common.h" /* atm_proc_init prototype */ | 31 | #include "common.h" /* atm_proc_init prototype */ |
32 | #include "signaling.h" /* to get sigd - ugly too */ | 32 | #include "signaling.h" /* to get sigd - ugly too */ |
33 | 33 | ||
34 | static ssize_t proc_dev_atm_read(struct file *file,char __user *buf,size_t count, | 34 | static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, |
35 | loff_t *pos); | 35 | size_t count, loff_t *pos); |
36 | 36 | ||
37 | static const struct file_operations proc_atm_dev_ops = { | 37 | static const struct file_operations proc_atm_dev_ops = { |
38 | .owner = THIS_MODULE, | 38 | .owner = THIS_MODULE, |
@@ -43,9 +43,9 @@ static void add_stats(struct seq_file *seq, const char *aal, | |||
43 | const struct k_atm_aal_stats *stats) | 43 | const struct k_atm_aal_stats *stats) |
44 | { | 44 | { |
45 | seq_printf(seq, "%s ( %d %d %d %d %d )", aal, | 45 | seq_printf(seq, "%s ( %d %d %d %d %d )", aal, |
46 | atomic_read(&stats->tx),atomic_read(&stats->tx_err), | 46 | atomic_read(&stats->tx), atomic_read(&stats->tx_err), |
47 | atomic_read(&stats->rx),atomic_read(&stats->rx_err), | 47 | atomic_read(&stats->rx), atomic_read(&stats->rx_err), |
48 | atomic_read(&stats->rx_drop)); | 48 | atomic_read(&stats->rx_drop)); |
49 | } | 49 | } |
50 | 50 | ||
51 | static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev) | 51 | static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev) |
@@ -151,8 +151,8 @@ static void *vcc_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
151 | 151 | ||
152 | static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) | 152 | static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) |
153 | { | 153 | { |
154 | static const char *const class_name[] = | 154 | static const char *const class_name[] = { |
155 | {"off","UBR","CBR","VBR","ABR"}; | 155 | "off", "UBR", "CBR", "VBR", "ABR"}; |
156 | static const char *const aal_name[] = { | 156 | static const char *const aal_name[] = { |
157 | "---", "1", "2", "3/4", /* 0- 3 */ | 157 | "---", "1", "2", "3/4", /* 0- 3 */ |
158 | "???", "5", "???", "???", /* 4- 7 */ | 158 | "???", "5", "???", "???", /* 4- 7 */ |
@@ -160,11 +160,12 @@ static void pvc_info(struct seq_file *seq, struct atm_vcc *vcc) | |||
160 | "???", "0", "???", "???"}; /* 12-15 */ | 160 | "???", "0", "???", "???"}; /* 12-15 */ |
161 | 161 | ||
162 | seq_printf(seq, "%3d %3d %5d %-3s %7d %-5s %7d %-6s", | 162 | seq_printf(seq, "%3d %3d %5d %-3s %7d %-5s %7d %-6s", |
163 | vcc->dev->number,vcc->vpi,vcc->vci, | 163 | vcc->dev->number, vcc->vpi, vcc->vci, |
164 | vcc->qos.aal >= ARRAY_SIZE(aal_name) ? "err" : | 164 | vcc->qos.aal >= ARRAY_SIZE(aal_name) ? "err" : |
165 | aal_name[vcc->qos.aal],vcc->qos.rxtp.min_pcr, | 165 | aal_name[vcc->qos.aal], vcc->qos.rxtp.min_pcr, |
166 | class_name[vcc->qos.rxtp.traffic_class],vcc->qos.txtp.min_pcr, | 166 | class_name[vcc->qos.rxtp.traffic_class], |
167 | class_name[vcc->qos.txtp.traffic_class]); | 167 | vcc->qos.txtp.min_pcr, |
168 | class_name[vcc->qos.txtp.traffic_class]); | ||
168 | if (test_bit(ATM_VF_IS_CLIP, &vcc->flags)) { | 169 | if (test_bit(ATM_VF_IS_CLIP, &vcc->flags)) { |
169 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); | 170 | struct clip_vcc *clip_vcc = CLIP_VCC(vcc); |
170 | struct net_device *dev; | 171 | struct net_device *dev; |
@@ -195,19 +196,20 @@ static void vcc_info(struct seq_file *seq, struct atm_vcc *vcc) | |||
195 | seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi, | 196 | seq_printf(seq, "%3d %3d %5d ", vcc->dev->number, vcc->vpi, |
196 | vcc->vci); | 197 | vcc->vci); |
197 | switch (sk->sk_family) { | 198 | switch (sk->sk_family) { |
198 | case AF_ATMPVC: | 199 | case AF_ATMPVC: |
199 | seq_printf(seq, "PVC"); | 200 | seq_printf(seq, "PVC"); |
200 | break; | 201 | break; |
201 | case AF_ATMSVC: | 202 | case AF_ATMSVC: |
202 | seq_printf(seq, "SVC"); | 203 | seq_printf(seq, "SVC"); |
203 | break; | 204 | break; |
204 | default: | 205 | default: |
205 | seq_printf(seq, "%3d", sk->sk_family); | 206 | seq_printf(seq, "%3d", sk->sk_family); |
206 | } | 207 | } |
207 | seq_printf(seq, " %04lx %5d %7d/%7d %7d/%7d [%d]\n", vcc->flags, sk->sk_err, | 208 | seq_printf(seq, " %04lx %5d %7d/%7d %7d/%7d [%d]\n", |
208 | sk_wmem_alloc_get(sk), sk->sk_sndbuf, | 209 | vcc->flags, sk->sk_err, |
209 | sk_rmem_alloc_get(sk), sk->sk_rcvbuf, | 210 | sk_wmem_alloc_get(sk), sk->sk_sndbuf, |
210 | atomic_read(&sk->sk_refcnt)); | 211 | sk_rmem_alloc_get(sk), sk->sk_rcvbuf, |
212 | atomic_read(&sk->sk_refcnt)); | ||
211 | } | 213 | } |
212 | 214 | ||
213 | static void svc_info(struct seq_file *seq, struct atm_vcc *vcc) | 215 | static void svc_info(struct seq_file *seq, struct atm_vcc *vcc) |
@@ -376,32 +378,35 @@ static ssize_t proc_dev_atm_read(struct file *file, char __user *buf, | |||
376 | unsigned long page; | 378 | unsigned long page; |
377 | int length; | 379 | int length; |
378 | 380 | ||
379 | if (count == 0) return 0; | 381 | if (count == 0) |
382 | return 0; | ||
380 | page = get_zeroed_page(GFP_KERNEL); | 383 | page = get_zeroed_page(GFP_KERNEL); |
381 | if (!page) return -ENOMEM; | 384 | if (!page) |
385 | return -ENOMEM; | ||
382 | dev = PDE(file->f_path.dentry->d_inode)->data; | 386 | dev = PDE(file->f_path.dentry->d_inode)->data; |
383 | if (!dev->ops->proc_read) | 387 | if (!dev->ops->proc_read) |
384 | length = -EINVAL; | 388 | length = -EINVAL; |
385 | else { | 389 | else { |
386 | length = dev->ops->proc_read(dev,pos,(char *) page); | 390 | length = dev->ops->proc_read(dev, pos, (char *)page); |
387 | if (length > count) length = -EINVAL; | 391 | if (length > count) |
392 | length = -EINVAL; | ||
388 | } | 393 | } |
389 | if (length >= 0) { | 394 | if (length >= 0) { |
390 | if (copy_to_user(buf,(char *) page,length)) length = -EFAULT; | 395 | if (copy_to_user(buf, (char *)page, length)) |
396 | length = -EFAULT; | ||
391 | (*pos)++; | 397 | (*pos)++; |
392 | } | 398 | } |
393 | free_page(page); | 399 | free_page(page); |
394 | return length; | 400 | return length; |
395 | } | 401 | } |
396 | 402 | ||
397 | |||
398 | struct proc_dir_entry *atm_proc_root; | 403 | struct proc_dir_entry *atm_proc_root; |
399 | EXPORT_SYMBOL(atm_proc_root); | 404 | EXPORT_SYMBOL(atm_proc_root); |
400 | 405 | ||
401 | 406 | ||
402 | int atm_proc_dev_register(struct atm_dev *dev) | 407 | int atm_proc_dev_register(struct atm_dev *dev) |
403 | { | 408 | { |
404 | int digits,num; | 409 | int digits, num; |
405 | int error; | 410 | int error; |
406 | 411 | ||
407 | /* No proc info */ | 412 | /* No proc info */ |
@@ -410,26 +415,28 @@ int atm_proc_dev_register(struct atm_dev *dev) | |||
410 | 415 | ||
411 | error = -ENOMEM; | 416 | error = -ENOMEM; |
412 | digits = 0; | 417 | digits = 0; |
413 | for (num = dev->number; num; num /= 10) digits++; | 418 | for (num = dev->number; num; num /= 10) |
414 | if (!digits) digits++; | 419 | digits++; |
420 | if (!digits) | ||
421 | digits++; | ||
415 | 422 | ||
416 | dev->proc_name = kmalloc(strlen(dev->type) + digits + 2, GFP_KERNEL); | 423 | dev->proc_name = kmalloc(strlen(dev->type) + digits + 2, GFP_KERNEL); |
417 | if (!dev->proc_name) | 424 | if (!dev->proc_name) |
418 | goto err_out; | 425 | goto err_out; |
419 | sprintf(dev->proc_name,"%s:%d",dev->type, dev->number); | 426 | sprintf(dev->proc_name, "%s:%d", dev->type, dev->number); |
420 | 427 | ||
421 | dev->proc_entry = proc_create_data(dev->proc_name, 0, atm_proc_root, | 428 | dev->proc_entry = proc_create_data(dev->proc_name, 0, atm_proc_root, |
422 | &proc_atm_dev_ops, dev); | 429 | &proc_atm_dev_ops, dev); |
423 | if (!dev->proc_entry) | 430 | if (!dev->proc_entry) |
424 | goto err_free_name; | 431 | goto err_free_name; |
425 | return 0; | 432 | return 0; |
433 | |||
426 | err_free_name: | 434 | err_free_name: |
427 | kfree(dev->proc_name); | 435 | kfree(dev->proc_name); |
428 | err_out: | 436 | err_out: |
429 | return error; | 437 | return error; |
430 | } | 438 | } |
431 | 439 | ||
432 | |||
433 | void atm_proc_dev_deregister(struct atm_dev *dev) | 440 | void atm_proc_dev_deregister(struct atm_dev *dev) |
434 | { | 441 | { |
435 | if (!dev->ops->proc_read) | 442 | if (!dev->ops->proc_read) |