aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/i4l/isdn_v110.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-02-19 22:52:38 -0500
committerJoe Perches <joe@perches.com>2012-02-21 12:04:01 -0500
commit475be4d85a274d0961593db41cf85689db1d583c (patch)
treeb2b8931eb747794730522c3cf1898e46948527b9 /drivers/isdn/i4l/isdn_v110.c
parent0b0a635f79f91f3755b6518627ea06dd0dbfd523 (diff)
isdn: whitespace coding style cleanup
isdn source code uses a not-current coding style. Update the coding style used on a per-line basis so that git diff -w shows only elided blank lines at EOF. Done with emacs and some scripts and some typing. Built x86 allyesconfig. No detected change in objdump -d or size. Signed-off-by: Joe Perches <joe@perches.com>
Diffstat (limited to 'drivers/isdn/i4l/isdn_v110.c')
-rw-r--r--drivers/isdn/i4l/isdn_v110.c294
1 files changed, 147 insertions, 147 deletions
diff --git a/drivers/isdn/i4l/isdn_v110.c b/drivers/isdn/i4l/isdn_v110.c
index c5d02b6aafab..52827a80c51f 100644
--- a/drivers/isdn/i4l/isdn_v110.c
+++ b/drivers/isdn/i4l/isdn_v110.c
@@ -26,8 +26,8 @@ char *isdn_v110_revision = "$Revision: 1.1.2.2 $";
26#define V110_19200 15 26#define V110_19200 15
27#define V110_9600 3 27#define V110_9600 3
28 28
29/* 29/*
30 * The following data are precoded matrices, online and offline matrix 30 * The following data are precoded matrices, online and offline matrix
31 * for 9600, 19200 und 38400, respectively 31 * for 9600, 19200 und 38400, respectively
32 */ 32 */
33static unsigned char V110_OnMatrix_9600[] = 33static unsigned char V110_OnMatrix_9600[] =
@@ -56,7 +56,7 @@ static unsigned char V110_OnMatrix_38400[] =
56static unsigned char V110_OffMatrix_38400[] = 56static unsigned char V110_OffMatrix_38400[] =
57{0x00, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff}; 57{0x00, 0xff, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff};
58 58
59/* 59/*
60 * FlipBits reorders sequences of keylen bits in one byte. 60 * FlipBits reorders sequences of keylen bits in one byte.
61 * E.g. source order 7654321 will be converted to 45670123 when keylen = 4, 61 * E.g. source order 7654321 will be converted to 45670123 when keylen = 4,
62 * and to 67452301 when keylen = 2. This is necessary because ordering on 62 * and to 67452301 when keylen = 2. This is necessary because ordering on
@@ -103,18 +103,18 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
103 v->decodelen = 0; 103 v->decodelen = 0;
104 104
105 switch (key) { 105 switch (key) {
106 case V110_38400: 106 case V110_38400:
107 v->OnlineFrame = V110_OnMatrix_38400; 107 v->OnlineFrame = V110_OnMatrix_38400;
108 v->OfflineFrame = V110_OffMatrix_38400; 108 v->OfflineFrame = V110_OffMatrix_38400;
109 break; 109 break;
110 case V110_19200: 110 case V110_19200:
111 v->OnlineFrame = V110_OnMatrix_19200; 111 v->OnlineFrame = V110_OnMatrix_19200;
112 v->OfflineFrame = V110_OffMatrix_19200; 112 v->OfflineFrame = V110_OffMatrix_19200;
113 break; 113 break;
114 default: 114 default:
115 v->OnlineFrame = V110_OnMatrix_9600; 115 v->OnlineFrame = V110_OnMatrix_9600;
116 v->OfflineFrame = V110_OffMatrix_9600; 116 v->OfflineFrame = V110_OffMatrix_9600;
117 break; 117 break;
118 } 118 }
119 v->framelen = v->nbytes * 10; 119 v->framelen = v->nbytes * 10;
120 v->SyncInit = 5; 120 v->SyncInit = 5;
@@ -132,7 +132,7 @@ isdn_v110_open(unsigned char key, int hdrlen, int maxsize)
132 132
133/* isdn_v110_close frees private V.110 data structures */ 133/* isdn_v110_close frees private V.110 data structures */
134void 134void
135isdn_v110_close(isdn_v110_stream * v) 135isdn_v110_close(isdn_v110_stream *v)
136{ 136{
137 if (v == NULL) 137 if (v == NULL)
138 return; 138 return;
@@ -144,11 +144,11 @@ isdn_v110_close(isdn_v110_stream * v)
144} 144}
145 145
146 146
147/* 147/*
148 * ValidHeaderBytes return the number of valid bytes in v->decodebuf 148 * ValidHeaderBytes return the number of valid bytes in v->decodebuf
149 */ 149 */
150static int 150static int
151ValidHeaderBytes(isdn_v110_stream * v) 151ValidHeaderBytes(isdn_v110_stream *v)
152{ 152{
153 int i; 153 int i;
154 for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++) 154 for (i = 0; (i < v->decodelen) && (i < v->nbytes); i++)
@@ -157,11 +157,11 @@ ValidHeaderBytes(isdn_v110_stream * v)
157 return i; 157 return i;
158} 158}
159 159
160/* 160/*
161 * SyncHeader moves the decodebuf ptr to the next valid header 161 * SyncHeader moves the decodebuf ptr to the next valid header
162 */ 162 */
163static void 163static void
164SyncHeader(isdn_v110_stream * v) 164SyncHeader(isdn_v110_stream *v)
165{ 165{
166 unsigned char *rbuf = v->decodebuf; 166 unsigned char *rbuf = v->decodebuf;
167 int len = v->decodelen; 167 int len = v->decodelen;
@@ -185,9 +185,9 @@ SyncHeader(isdn_v110_stream * v)
185 only complete matices must be given. 185 only complete matices must be given.
186 From these, netto data is extracted and returned in buf. The return-value 186 From these, netto data is extracted and returned in buf. The return-value
187 is the bytecount of the decoded data. 187 is the bytecount of the decoded data.
188 */ 188*/
189static int 189static int
190DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf) 190DecodeMatrix(isdn_v110_stream *v, unsigned char *m, int len, unsigned char *buf)
191{ 191{
192 int line = 0; 192 int line = 0;
193 int buflen = 0; 193 int buflen = 0;
@@ -203,7 +203,7 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf
203 printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n"); 203 printk(KERN_DEBUG "isdn_v110: DecodeMatrix, V110 Bad Header\n");
204 /* returning now is not the right thing, though :-( */ 204 /* returning now is not the right thing, though :-( */
205#endif 205#endif
206 } 206 }
207 line++; /* next line of matrix */ 207 line++; /* next line of matrix */
208 continue; 208 continue;
209 } else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */ 209 } else if ((line % 10) == 5) { /* in line 5 there's only e-bits ! */
@@ -217,7 +217,7 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf
217 continue; 217 continue;
218 } else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */ 218 } else if (!introducer) { /* every byte starts with 10 (stopbit, startbit) */
219 introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */ 219 introducer = (m[line] & mbit) ? 0 : 1; /* current bit of the matrix */
220 next_byte: 220 next_byte:
221 if (mbit > 2) { /* was it the last bit in this line ? */ 221 if (mbit > 2) { /* was it the last bit in this line ? */
222 mbit >>= 1; /* no -> take next */ 222 mbit >>= 1; /* no -> take next */
223 continue; 223 continue;
@@ -246,13 +246,13 @@ DecodeMatrix(isdn_v110_stream * v, unsigned char *m, int len, unsigned char *buf
246 return buflen; /* return number of bytes in the output buffer */ 246 return buflen; /* return number of bytes in the output buffer */
247} 247}
248 248
249/* 249/*
250 * DecodeStream receives V.110 coded data from the input stream. It recovers the 250 * DecodeStream receives V.110 coded data from the input stream. It recovers the
251 * original frames. 251 * original frames.
252 * The input stream doesn't need to be framed 252 * The input stream doesn't need to be framed
253 */ 253 */
254struct sk_buff * 254struct sk_buff *
255isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb) 255isdn_v110_decode(isdn_v110_stream *v, struct sk_buff *skb)
256{ 256{
257 int i; 257 int i;
258 int j; 258 int j;
@@ -283,7 +283,7 @@ isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb)
283 /* copy new data to decode-buffer */ 283 /* copy new data to decode-buffer */
284 memcpy(&(v->decodebuf[v->decodelen]), rbuf, len); 284 memcpy(&(v->decodebuf[v->decodelen]), rbuf, len);
285 v->decodelen += len; 285 v->decodelen += len;
286 ReSync: 286ReSync:
287 if (v->decodelen < v->nbytes) { /* got a new header ? */ 287 if (v->decodelen < v->nbytes) { /* got a new header ? */
288 dev_kfree_skb(skb); 288 dev_kfree_skb(skb);
289 return NULL; /* no, try later */ 289 return NULL; /* no, try later */
@@ -320,7 +320,7 @@ isdn_v110_decode(isdn_v110_stream * v, struct sk_buff *skb)
320/* EncodeMatrix takes input data in buf, len is the bytecount. 320/* EncodeMatrix takes input data in buf, len is the bytecount.
321 Data is encoded into v110 frames in m. Return value is the number of 321 Data is encoded into v110 frames in m. Return value is the number of
322 matrix-lines generated. 322 matrix-lines generated.
323 */ 323*/
324static int 324static int
325EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen) 325EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
326{ 326{
@@ -333,14 +333,14 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
333 333
334 while ((i < len) && (line < mlen)) { /* while we still have input data */ 334 while ((i < len) && (line < mlen)) { /* while we still have input data */
335 switch (line % 10) { /* in which line of the matrix are we? */ 335 switch (line % 10) { /* in which line of the matrix are we? */
336 case 0: 336 case 0:
337 m[line++] = 0x00; /* line 0 is always 0 */ 337 m[line++] = 0x00; /* line 0 is always 0 */
338 mbit = 128; /* go on with the 7th bit */ 338 mbit = 128; /* go on with the 7th bit */
339 break; 339 break;
340 case 5: 340 case 5:
341 m[line++] = 0xbf; /* line 5 is always 10111111 */ 341 m[line++] = 0xbf; /* line 5 is always 10111111 */
342 mbit = 128; /* go on with the 7th bit */ 342 mbit = 128; /* go on with the 7th bit */
343 break; 343 break;
344 } 344 }
345 if (line >= mlen) { 345 if (line >= mlen) {
346 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n"); 346 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
@@ -348,16 +348,16 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
348 } 348 }
349 next_bit: 349 next_bit:
350 switch (mbit) { /* leftmost or rightmost bit ? */ 350 switch (mbit) { /* leftmost or rightmost bit ? */
351 case 1: 351 case 1:
352 line++; /* rightmost -> go to next line */ 352 line++; /* rightmost -> go to next line */
353 if (line >= mlen) { 353 if (line >= mlen) {
354 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n"); 354 printk(KERN_WARNING "isdn_v110 (EncodeMatrix): buffer full!\n");
355 return line; 355 return line;
356 } 356 }
357 case 128: 357 case 128:
358 m[line] = 128; /* leftmost -> set byte to 1000000 */ 358 m[line] = 128; /* leftmost -> set byte to 1000000 */
359 mbit = 64; /* current bit in the matrix line */ 359 mbit = 64; /* current bit in the matrix line */
360 continue; 360 continue;
361 } 361 }
362 if (introducer) { /* set 110 sequence ? */ 362 if (introducer) { /* set 110 sequence ? */
363 introducer--; /* set on digit less */ 363 introducer--; /* set on digit less */
@@ -384,24 +384,24 @@ EncodeMatrix(unsigned char *buf, int len, unsigned char *m, int mlen)
384 /* if necessary, generate remaining lines of the matrix... */ 384 /* if necessary, generate remaining lines of the matrix... */
385 if ((line) && ((line + 10) < mlen)) 385 if ((line) && ((line + 10) < mlen))
386 switch (++line % 10) { 386 switch (++line % 10) {
387 case 1: 387 case 1:
388 m[line++] = 0xfe; 388 m[line++] = 0xfe;
389 case 2: 389 case 2:
390 m[line++] = 0xfe; 390 m[line++] = 0xfe;
391 case 3: 391 case 3:
392 m[line++] = 0xfe; 392 m[line++] = 0xfe;
393 case 4: 393 case 4:
394 m[line++] = 0xfe; 394 m[line++] = 0xfe;
395 case 5: 395 case 5:
396 m[line++] = 0xbf; 396 m[line++] = 0xbf;
397 case 6: 397 case 6:
398 m[line++] = 0xfe; 398 m[line++] = 0xfe;
399 case 7: 399 case 7:
400 m[line++] = 0xfe; 400 m[line++] = 0xfe;
401 case 8: 401 case 8:
402 m[line++] = 0xfe; 402 m[line++] = 0xfe;
403 case 9: 403 case 9:
404 m[line++] = 0xfe; 404 m[line++] = 0xfe;
405 } 405 }
406 return line; /* that's how many lines we have */ 406 return line; /* that's how many lines we have */
407} 407}
@@ -447,7 +447,7 @@ isdn_v110_idle(isdn_v110_stream *v)
447} 447}
448 448
449struct sk_buff * 449struct sk_buff *
450isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb) 450isdn_v110_encode(isdn_v110_stream *v, struct sk_buff *skb)
451{ 451{
452 int i; 452 int i;
453 int j; 453 int j;
@@ -524,93 +524,93 @@ isdn_v110_stat_callback(int idx, isdn_ctrl *c)
524 if (idx < 0) 524 if (idx < 0)
525 return 0; 525 return 0;
526 switch (c->command) { 526 switch (c->command) {
527 case ISDN_STAT_BSENT: 527 case ISDN_STAT_BSENT:
528 /* Keep the send-queue of the driver filled 528 /* Keep the send-queue of the driver filled
529 * with frames: 529 * with frames:
530 * If number of outstanding frames < 3, 530 * If number of outstanding frames < 3,
531 * send down an Idle-Frame (or an Sync-Frame, if 531 * send down an Idle-Frame (or an Sync-Frame, if
532 * v->SyncInit != 0). 532 * v->SyncInit != 0).
533 */ 533 */
534 if (!(v = dev->v110[idx])) 534 if (!(v = dev->v110[idx]))
535 return 0; 535 return 0;
536 atomic_inc(&dev->v110use[idx]); 536 atomic_inc(&dev->v110use[idx]);
537 for (i=0; i * v->framelen < c->parm.length; i++) { 537 for (i = 0; i * v->framelen < c->parm.length; i++) {
538 if (v->skbidle > 0) { 538 if (v->skbidle > 0) {
539 v->skbidle--; 539 v->skbidle--;
540 ret = 1; 540 ret = 1;
541 } else {
542 if (v->skbuser > 0)
543 v->skbuser--;
544 ret = 0;
545 }
546 }
547 for (i = v->skbuser + v->skbidle; i < 2; i++) {
548 struct sk_buff *skb;
549 if (v->SyncInit > 0)
550 skb = isdn_v110_sync(v);
551 else
552 skb = isdn_v110_idle(v);
553 if (skb) {
554 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
555 dev_kfree_skb(skb);
556 break;
541 } else { 557 } else {
542 if (v->skbuser > 0) 558 if (v->SyncInit)
543 v->skbuser--; 559 v->SyncInit--;
544 ret = 0; 560 v->skbidle++;
545 } 561 }
562 } else
563 break;
564 }
565 atomic_dec(&dev->v110use[idx]);
566 return ret;
567 case ISDN_STAT_DHUP:
568 case ISDN_STAT_BHUP:
569 while (1) {
570 atomic_inc(&dev->v110use[idx]);
571 if (atomic_dec_and_test(&dev->v110use[idx])) {
572 isdn_v110_close(dev->v110[idx]);
573 dev->v110[idx] = NULL;
574 break;
575 }
576 mdelay(1);
577 }
578 break;
579 case ISDN_STAT_BCONN:
580 if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) {
581 int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
582 int maxsize = dev->drv[c->driver]->interface->maxbufsize;
583 atomic_inc(&dev->v110use[idx]);
584 switch (dev->v110emu[idx]) {
585 case ISDN_PROTO_L2_V11096:
586 dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
587 break;
588 case ISDN_PROTO_L2_V11019:
589 dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
590 break;
591 case ISDN_PROTO_L2_V11038:
592 dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
593 break;
594 default:;
546 } 595 }
547 for (i = v->skbuser + v->skbidle; i < 2; i++) { 596 if ((v = dev->v110[idx])) {
548 struct sk_buff *skb; 597 while (v->SyncInit) {
549 if (v->SyncInit > 0) 598 struct sk_buff *skb = isdn_v110_sync(v);
550 skb = isdn_v110_sync(v);
551 else
552 skb = isdn_v110_idle(v);
553 if (skb) {
554 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { 599 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
555 dev_kfree_skb(skb); 600 dev_kfree_skb(skb);
601 /* Unable to send, try later */
556 break; 602 break;
557 } else {
558 if (v->SyncInit)
559 v->SyncInit--;
560 v->skbidle++;
561 } 603 }
562 } else 604 v->SyncInit--;
563 break; 605 v->skbidle++;
564 }
565 atomic_dec(&dev->v110use[idx]);
566 return ret;
567 case ISDN_STAT_DHUP:
568 case ISDN_STAT_BHUP:
569 while (1) {
570 atomic_inc(&dev->v110use[idx]);
571 if (atomic_dec_and_test(&dev->v110use[idx])) {
572 isdn_v110_close(dev->v110[idx]);
573 dev->v110[idx] = NULL;
574 break;
575 } 606 }
576 mdelay(1); 607 } else
577 } 608 printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
578 break; 609 atomic_dec(&dev->v110use[idx]);
579 case ISDN_STAT_BCONN: 610 }
580 if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) { 611 break;
581 int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen; 612 default:
582 int maxsize = dev->drv[c->driver]->interface->maxbufsize; 613 return 0;
583 atomic_inc(&dev->v110use[idx]);
584 switch (dev->v110emu[idx]) {
585 case ISDN_PROTO_L2_V11096:
586 dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize);
587 break;
588 case ISDN_PROTO_L2_V11019:
589 dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize);
590 break;
591 case ISDN_PROTO_L2_V11038:
592 dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize);
593 break;
594 default:;
595 }
596 if ((v = dev->v110[idx])) {
597 while (v->SyncInit) {
598 struct sk_buff *skb = isdn_v110_sync(v);
599 if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
600 dev_kfree_skb(skb);
601 /* Unable to send, try later */
602 break;
603 }
604 v->SyncInit--;
605 v->skbidle++;
606 }
607 } else
608 printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx);
609 atomic_dec(&dev->v110use[idx]);
610 }
611 break;
612 default:
613 return 0;
614 } 614 }
615 return 0; 615 return 0;
616} 616}