patch-2.4.0-test5 linux/drivers/isdn/avmb1/kcapi.c
Next file: linux/drivers/isdn/avmb1/t1pci.c
Previous file: linux/drivers/isdn/avmb1/capi.c
Back to the patch index
Back to the overall index
- Lines: 298
- Date:
Mon Jul 24 18:48:49 2000
- Orig file:
v2.4.0-test4/linux/drivers/isdn/avmb1/kcapi.c
- Orig date:
Mon Jul 10 16:47:23 2000
diff -u --recursive --new-file v2.4.0-test4/linux/drivers/isdn/avmb1/kcapi.c linux/drivers/isdn/avmb1/kcapi.c
@@ -1,11 +1,14 @@
/*
- * $Id: kcapi.c,v 1.17 2000/04/21 13:00:56 calle Exp $
+ * $Id: kcapi.c,v 1.18 2000/07/20 10:22:27 calle Exp $
*
* Kernel CAPI 2.0 Module
*
* (c) Copyright 1999 by Carsten Paeth (calle@calle.in-berlin.de)
*
* $Log: kcapi.c,v $
+ * Revision 1.18 2000/07/20 10:22:27 calle
+ * - Made procfs function cleaner and removed variable "begin".
+ *
* Revision 1.17 2000/04/21 13:00:56 calle
* Bugfix: driver_proc_info was also wrong.
*
@@ -115,7 +118,7 @@
#include <linux/b1lli.h>
#endif
-static char *revision = "$Revision: 1.17 $";
+static char *revision = "$Revision: 1.18 $";
/* ------------------------------------------------------------- */
@@ -263,7 +266,6 @@
struct capi_appl *ap;
int i;
int len = 0;
- off_t begin = 0;
for (i=0; i < CAPI_MAXAPPL; i++) {
ap = &applications[i];
@@ -275,20 +277,21 @@
ap->rparam.datablklen,
ap->nncci,
skb_queue_len(&ap->recv_queue));
- if (len+begin > off+count)
- goto endloop;
- if (len+begin < off) {
- begin += len;
+ if (len <= off) {
+ off -= len;
len = 0;
+ } else {
+ if (len-off > count)
+ goto endloop;
}
}
endloop:
- if (i >= CAPI_MAXAPPL)
+ *start = page+off;
+ if (len < count)
*eof = 1;
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
- return ((count < begin+len-off) ? count : begin+len-off);
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
}
/*
@@ -302,7 +305,6 @@
struct capi_ncci *np;
int i;
int len = 0;
- off_t begin = 0;
for (i=0; i < CAPI_MAXAPPL; i++) {
ap = &applications[i];
@@ -313,21 +315,22 @@
np->ncci,
np->winsize,
np->nmsg);
- if (len+begin > off+count)
- goto endloop;
- if (len+begin < off) {
- begin += len;
+ if (len <= off) {
+ off -= len;
len = 0;
+ } else {
+ if (len-off > count)
+ goto endloop;
}
}
}
endloop:
- if (i >= CAPI_MAXAPPL)
+ *start = page+off;
+ if (len < count)
*eof = 1;
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
- return ((count < begin+len-off) ? count : begin+len-off);
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
}
/*
@@ -339,7 +342,6 @@
{
struct capi_driver *driver;
int len = 0;
- off_t begin = 0;
spin_lock(&drivers_lock);
for (driver = drivers; driver; driver = driver->next) {
@@ -347,21 +349,22 @@
driver->name,
driver->ncontroller,
driver->revision);
- if (len+begin > off+count)
- goto endloop;
- if (len+begin < off) {
- begin += len;
+ if (len <= off) {
+ off -= len;
len = 0;
+ } else {
+ if (len-off > count)
+ goto endloop;
}
}
endloop:
spin_unlock(&drivers_lock);
- if (!driver)
+ *start = page+off;
+ if (len < count)
*eof = 1;
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
- return ((count < begin+len-off) ? count : begin+len-off);
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
}
/*
@@ -373,26 +376,26 @@
{
struct capi_interface_user *cp;
int len = 0;
- off_t begin = 0;
spin_lock(&capi_users_lock);
for (cp = capi_users; cp ; cp = cp->next) {
len += sprintf(page+len, "%s\n", cp->name);
- if (len+begin > off+count)
- goto endloop;
- if (len+begin < off) {
- begin += len;
+ if (len <= off) {
+ off -= len;
len = 0;
+ } else {
+ if (len-off > count)
+ goto endloop;
}
}
endloop:
spin_unlock(&capi_users_lock);
- if (cp == 0)
+ *start = page+off;
+ if (len < count)
*eof = 1;
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
- return ((count < begin+len-off) ? count : begin+len-off);
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
}
/*
@@ -405,7 +408,6 @@
struct capi_ctr *cp;
int i;
int len = 0;
- off_t begin = 0;
for (i=0; i < CAPI_MAXCONTR; i++) {
cp = &cards[i];
@@ -416,20 +418,21 @@
cp->name,
cp->driver->procinfo ? cp->driver->procinfo(cp) : ""
);
- if (len+begin > off+count)
- goto endloop;
- if (len+begin < off) {
- begin += len;
+ if (len <= off) {
+ off -= len;
len = 0;
+ } else {
+ if (len-off > count)
+ goto endloop;
}
}
endloop:
- if (i >= CAPI_MAXCONTR)
+ *start = page+off;
+ if (len < count)
*eof = 1;
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
- return ((count < begin+len-off) ? count : begin+len-off);
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
}
/*
@@ -442,7 +445,6 @@
struct capi_appl *ap;
int i;
int len = 0;
- off_t begin = 0;
for (i=0; i < CAPI_MAXAPPL; i++) {
ap = &applications[i];
@@ -453,20 +455,21 @@
ap->nrecvdatapkt,
ap->nsentctlpkt,
ap->nsentdatapkt);
- if (len+begin > off+count)
- goto endloop;
- if (len+begin < off) {
- begin += len;
+ if (len <= off) {
+ off -= len;
len = 0;
+ } else {
+ if (len-off > count)
+ goto endloop;
}
}
endloop:
- if (i >= CAPI_MAXAPPL)
+ *start = page+off;
+ if (len < count)
*eof = 1;
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
- return ((count < begin+len-off) ? count : begin+len-off);
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
}
/*
@@ -479,7 +482,6 @@
struct capi_ctr *cp;
int i;
int len = 0;
- off_t begin = 0;
for (i=0; i < CAPI_MAXCONTR; i++) {
cp = &cards[i];
@@ -490,20 +492,21 @@
cp->nrecvdatapkt,
cp->nsentctlpkt,
cp->nsentdatapkt);
- if (len+begin > off+count)
- goto endloop;
- if (len+begin < off) {
- begin += len;
+ if (len <= off) {
+ off -= len;
len = 0;
+ } else {
+ if (len-off > count)
+ goto endloop;
}
}
endloop:
- if (i >= CAPI_MAXCONTR)
+ *start = page+off;
+ if (len < count)
*eof = 1;
- if (off >= len+begin)
- return 0;
- *start = page + (off-begin);
- return ((count < begin+len-off) ? count : begin+len-off);
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
}
static struct procfsentries {
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)