aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/capi/capi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/capi/capi.c')
-rw-r--r--drivers/isdn/capi/capi.c99
1 files changed, 35 insertions, 64 deletions
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 65bf91e16a42..79f9364aded6 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -33,6 +33,7 @@
33#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ 33#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
34#include <linux/skbuff.h> 34#include <linux/skbuff.h>
35#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
36#include <linux/seq_file.h>
36#include <linux/poll.h> 37#include <linux/poll.h>
37#include <linux/capi.h> 38#include <linux/capi.h>
38#include <linux/kernelcapi.h> 39#include <linux/kernelcapi.h>
@@ -1407,114 +1408,84 @@ static void capinc_tty_exit(void)
1407 * /proc/capi/capi20: 1408 * /proc/capi/capi20:
1408 * minor applid nrecvctlpkt nrecvdatapkt nsendctlpkt nsenddatapkt 1409 * minor applid nrecvctlpkt nrecvdatapkt nsendctlpkt nsenddatapkt
1409 */ 1410 */
1410static int proc_capidev_read_proc(char *page, char **start, off_t off, 1411static int capi20_proc_show(struct seq_file *m, void *v)
1411 int count, int *eof, void *data)
1412{ 1412{
1413 struct capidev *cdev; 1413 struct capidev *cdev;
1414 struct list_head *l; 1414 struct list_head *l;
1415 int len = 0;
1416 1415
1417 read_lock(&capidev_list_lock); 1416 read_lock(&capidev_list_lock);
1418 list_for_each(l, &capidev_list) { 1417 list_for_each(l, &capidev_list) {
1419 cdev = list_entry(l, struct capidev, list); 1418 cdev = list_entry(l, struct capidev, list);
1420 len += sprintf(page+len, "0 %d %lu %lu %lu %lu\n", 1419 seq_printf(m, "0 %d %lu %lu %lu %lu\n",
1421 cdev->ap.applid, 1420 cdev->ap.applid,
1422 cdev->ap.nrecvctlpkt, 1421 cdev->ap.nrecvctlpkt,
1423 cdev->ap.nrecvdatapkt, 1422 cdev->ap.nrecvdatapkt,
1424 cdev->ap.nsentctlpkt, 1423 cdev->ap.nsentctlpkt,
1425 cdev->ap.nsentdatapkt); 1424 cdev->ap.nsentdatapkt);
1426 if (len <= off) {
1427 off -= len;
1428 len = 0;
1429 } else {
1430 if (len-off > count)
1431 goto endloop;
1432 }
1433 } 1425 }
1434
1435endloop:
1436 read_unlock(&capidev_list_lock); 1426 read_unlock(&capidev_list_lock);
1437 if (len < count) 1427 return 0;
1438 *eof = 1;
1439 if (len > count) len = count;
1440 if (len < 0) len = 0;
1441 return len;
1442} 1428}
1443 1429
1430static int capi20_proc_open(struct inode *inode, struct file *file)
1431{
1432 return single_open(file, capi20_proc_show, NULL);
1433}
1434
1435static const struct file_operations capi20_proc_fops = {
1436 .owner = THIS_MODULE,
1437 .open = capi20_proc_open,
1438 .read = seq_read,
1439 .llseek = seq_lseek,
1440 .release = single_release,
1441};
1442
1444/* 1443/*
1445 * /proc/capi/capi20ncci: 1444 * /proc/capi/capi20ncci:
1446 * applid ncci 1445 * applid ncci
1447 */ 1446 */
1448static int proc_capincci_read_proc(char *page, char **start, off_t off, 1447static int capi20ncci_proc_show(struct seq_file *m, void *v)
1449 int count, int *eof, void *data)
1450{ 1448{
1451 struct capidev *cdev; 1449 struct capidev *cdev;
1452 struct capincci *np; 1450 struct capincci *np;
1453 struct list_head *l; 1451 struct list_head *l;
1454 int len = 0;
1455 1452
1456 read_lock(&capidev_list_lock); 1453 read_lock(&capidev_list_lock);
1457 list_for_each(l, &capidev_list) { 1454 list_for_each(l, &capidev_list) {
1458 cdev = list_entry(l, struct capidev, list); 1455 cdev = list_entry(l, struct capidev, list);
1459 for (np=cdev->nccis; np; np = np->next) { 1456 for (np=cdev->nccis; np; np = np->next) {
1460 len += sprintf(page+len, "%d 0x%x\n", 1457 seq_printf(m, "%d 0x%x\n",
1461 cdev->ap.applid, 1458 cdev->ap.applid,
1462 np->ncci); 1459 np->ncci);
1463 if (len <= off) {
1464 off -= len;
1465 len = 0;
1466 } else {
1467 if (len-off > count)
1468 goto endloop;
1469 }
1470 } 1460 }
1471 } 1461 }
1472endloop:
1473 read_unlock(&capidev_list_lock); 1462 read_unlock(&capidev_list_lock);
1474 *start = page+off; 1463 return 0;
1475 if (len < count)
1476 *eof = 1;
1477 if (len>count) len = count;
1478 if (len<0) len = 0;
1479 return len;
1480} 1464}
1481 1465
1482static struct procfsentries { 1466static int capi20ncci_proc_open(struct inode *inode, struct file *file)
1483 char *name; 1467{
1484 mode_t mode; 1468 return single_open(file, capi20ncci_proc_show, NULL);
1485 int (*read_proc)(char *page, char **start, off_t off, 1469}
1486 int count, int *eof, void *data); 1470
1487 struct proc_dir_entry *procent; 1471static const struct file_operations capi20ncci_proc_fops = {
1488} procfsentries[] = { 1472 .owner = THIS_MODULE,
1489 /* { "capi", S_IFDIR, 0 }, */ 1473 .open = capi20ncci_proc_open,
1490 { "capi/capi20", 0 , proc_capidev_read_proc }, 1474 .read = seq_read,
1491 { "capi/capi20ncci", 0 , proc_capincci_read_proc }, 1475 .llseek = seq_lseek,
1476 .release = single_release,
1492}; 1477};
1493 1478
1494static void __init proc_init(void) 1479static void __init proc_init(void)
1495{ 1480{
1496 int nelem = ARRAY_SIZE(procfsentries); 1481 proc_create("capi/capi20", 0, NULL, &capi20_proc_fops);
1497 int i; 1482 proc_create("capi/capi20ncci", 0, NULL, &capi20ncci_proc_fops);
1498
1499 for (i=0; i < nelem; i++) {
1500 struct procfsentries *p = procfsentries + i;
1501 p->procent = create_proc_entry(p->name, p->mode, NULL);
1502 if (p->procent) p->procent->read_proc = p->read_proc;
1503 }
1504} 1483}
1505 1484
1506static void __exit proc_exit(void) 1485static void __exit proc_exit(void)
1507{ 1486{
1508 int nelem = ARRAY_SIZE(procfsentries); 1487 remove_proc_entry("capi/capi20", NULL);
1509 int i; 1488 remove_proc_entry("capi/capi20ncci", NULL);
1510
1511 for (i=nelem-1; i >= 0; i--) {
1512 struct procfsentries *p = procfsentries + i;
1513 if (p->procent) {
1514 remove_proc_entry(p->name, NULL);
1515 p->procent = NULL;
1516 }
1517 }
1518} 1489}
1519 1490
1520/* -------- init function and module interface ---------------------- */ 1491/* -------- init function and module interface ---------------------- */