aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/isocdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/isocdata.c')
-rw-r--r--drivers/isdn/gigaset/isocdata.c109
1 files changed, 56 insertions, 53 deletions
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index e2d93e935530..4a00d22c496e 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -83,14 +83,14 @@ static inline int isowbuf_startwrite(struct isowbuf_t *iwb)
83{ 83{
84 if (!atomic_dec_and_test(&iwb->writesem)) { 84 if (!atomic_dec_and_test(&iwb->writesem)) {
85 atomic_inc(&iwb->writesem); 85 atomic_inc(&iwb->writesem);
86 dbg(DEBUG_ISO, 86 gig_dbg(DEBUG_ISO, "%s: couldn't acquire iso write semaphore",
87 "%s: couldn't acquire iso write semaphore", __func__); 87 __func__);
88 return 0; 88 return 0;
89 } 89 }
90#ifdef CONFIG_GIGASET_DEBUG 90#ifdef CONFIG_GIGASET_DEBUG
91 dbg(DEBUG_ISO, 91 gig_dbg(DEBUG_ISO,
92 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d", 92 "%s: acquired iso write semaphore, data[write]=%02x, nbits=%d",
93 __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits); 93 __func__, iwb->data[atomic_read(&iwb->write)], iwb->wbits);
94#endif 94#endif
95 return 1; 95 return 1;
96} 96}
@@ -143,7 +143,7 @@ static inline void isowbuf_putflag(struct isowbuf_t *iwb)
143 /* recover the idle flag byte */ 143 /* recover the idle flag byte */
144 write = atomic_read(&iwb->write); 144 write = atomic_read(&iwb->write);
145 iwb->idle = iwb->data[write]; 145 iwb->idle = iwb->data[write];
146 dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle); 146 gig_dbg(DEBUG_ISO, "idle fill byte %02x", iwb->idle);
147 /* mask extraneous bits in buffer */ 147 /* mask extraneous bits in buffer */
148 iwb->data[write] &= (1 << iwb->wbits) - 1; 148 iwb->data[write] &= (1 << iwb->wbits) - 1;
149} 149}
@@ -162,15 +162,14 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
162 read = atomic_read(&iwb->nextread); 162 read = atomic_read(&iwb->nextread);
163 write = atomic_read(&iwb->write); 163 write = atomic_read(&iwb->write);
164 if (likely(read == write)) { 164 if (likely(read == write)) {
165 //dbg(DEBUG_STREAM, "%s: send buffer empty", __func__);
166 /* return idle frame */ 165 /* return idle frame */
167 return read < BAS_OUTBUFPAD ? 166 return read < BAS_OUTBUFPAD ?
168 BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD; 167 BAS_OUTBUFSIZE : read - BAS_OUTBUFPAD;
169 } 168 }
170 169
171 limit = read + size; 170 limit = read + size;
172 dbg(DEBUG_STREAM, 171 gig_dbg(DEBUG_STREAM, "%s: read=%d write=%d limit=%d",
173 "%s: read=%d write=%d limit=%d", __func__, read, write, limit); 172 __func__, read, write, limit);
174#ifdef CONFIG_GIGASET_DEBUG 173#ifdef CONFIG_GIGASET_DEBUG
175 if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) { 174 if (unlikely(size < 0 || size > BAS_OUTBUFPAD)) {
176 err("invalid size %d", size); 175 err("invalid size %d", size);
@@ -195,9 +194,9 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
195 pbyte = iwb->data[write]; /* save 194 pbyte = iwb->data[write]; /* save
196 partial byte */ 195 partial byte */
197 limit = write + BAS_OUTBUFPAD; 196 limit = write + BAS_OUTBUFPAD;
198 dbg(DEBUG_STREAM, 197 gig_dbg(DEBUG_STREAM,
199 "%s: filling %d->%d with %02x", 198 "%s: filling %d->%d with %02x",
200 __func__, write, limit, iwb->idle); 199 __func__, write, limit, iwb->idle);
201 if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE) 200 if (write + BAS_OUTBUFPAD < BAS_OUTBUFSIZE)
202 memset(iwb->data + write, iwb->idle, 201 memset(iwb->data + write, iwb->idle,
203 BAS_OUTBUFPAD); 202 BAS_OUTBUFPAD);
@@ -208,8 +207,9 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
208 - write); 207 - write);
209 limit = 0; 208 limit = 0;
210 } 209 }
211 dbg(DEBUG_STREAM, "%s: restoring %02x at %d", 210 gig_dbg(DEBUG_STREAM,
212 __func__, pbyte, limit); 211 "%s: restoring %02x at %d",
212 __func__, pbyte, limit);
213 iwb->data[limit] = pbyte; /* restore 213 iwb->data[limit] = pbyte; /* restore
214 partial byte */ 214 partial byte */
215 atomic_set(&iwb->write, limit); 215 atomic_set(&iwb->write, limit);
@@ -240,7 +240,7 @@ int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size)
240 * write hex bytes to syslog for debugging 240 * write hex bytes to syslog for debugging
241 */ 241 */
242static inline void dump_bytes(enum debuglevel level, const char *tag, 242static inline void dump_bytes(enum debuglevel level, const char *tag,
243 unsigned char *bytes, int count) 243 unsigned char *bytes, int count)
244{ 244{
245#ifdef CONFIG_GIGASET_DEBUG 245#ifdef CONFIG_GIGASET_DEBUG
246 unsigned char c; 246 unsigned char c;
@@ -252,7 +252,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
252 while (count-- > 0) { 252 while (count-- > 0) {
253 if (i > sizeof(dbgline) - 4) { 253 if (i > sizeof(dbgline) - 4) {
254 dbgline[i] = '\0'; 254 dbgline[i] = '\0';
255 dbg(level, "%s:%s", tag, dbgline); 255 gig_dbg(level, "%s:%s", tag, dbgline);
256 i = 0; 256 i = 0;
257 } 257 }
258 c = *bytes++; 258 c = *bytes++;
@@ -262,7 +262,7 @@ static inline void dump_bytes(enum debuglevel level, const char *tag,
262 dbgline[i++] = hexdigit[c & 0x0f]; 262 dbgline[i++] = hexdigit[c & 0x0f];
263 } 263 }
264 dbgline[i] = '\0'; 264 dbgline[i] = '\0';
265 dbg(level, "%s:%s", tag, dbgline); 265 gig_dbg(level, "%s:%s", tag, dbgline);
266#endif 266#endif
267} 267}
268 268
@@ -378,7 +378,7 @@ static u16 stufftab[5 * 256] = {
378 */ 378 */
379 379
380static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin, 380static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin,
381 int ones) 381 int ones)
382{ 382{
383 u16 stuff; 383 u16 stuff;
384 int shiftinc, newones; 384 int shiftinc, newones;
@@ -420,7 +420,7 @@ static inline int hdlc_bitstuff_byte(struct isowbuf_t *iwb, unsigned char cin,
420 */ 420 */
421 421
422static inline int hdlc_buildframe(struct isowbuf_t *iwb, 422static inline int hdlc_buildframe(struct isowbuf_t *iwb,
423 unsigned char *in, int count) 423 unsigned char *in, int count)
424{ 424{
425 int ones; 425 int ones;
426 u16 fcs; 426 u16 fcs;
@@ -429,8 +429,8 @@ static inline int hdlc_buildframe(struct isowbuf_t *iwb,
429 429
430 if (isowbuf_freebytes(iwb) < count + count / 5 + 6 || 430 if (isowbuf_freebytes(iwb) < count + count / 5 + 6 ||
431 !isowbuf_startwrite(iwb)) { 431 !isowbuf_startwrite(iwb)) {
432 dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN", 432 gig_dbg(DEBUG_ISO, "%s: %d bytes free -> -EAGAIN",
433 __func__, isowbuf_freebytes(iwb)); 433 __func__, isowbuf_freebytes(iwb));
434 return -EAGAIN; 434 return -EAGAIN;
435 } 435 }
436 436
@@ -482,11 +482,11 @@ static inline int trans_buildframe(struct isowbuf_t *iwb,
482 482
483 if (isowbuf_freebytes(iwb) < count || 483 if (isowbuf_freebytes(iwb) < count ||
484 !isowbuf_startwrite(iwb)) { 484 !isowbuf_startwrite(iwb)) {
485 dbg(DEBUG_ISO, "can't put %d bytes", count); 485 gig_dbg(DEBUG_ISO, "can't put %d bytes", count);
486 return -EAGAIN; 486 return -EAGAIN;
487 } 487 }
488 488
489 dbg(DEBUG_STREAM, "put %d bytes", count); 489 gig_dbg(DEBUG_STREAM, "put %d bytes", count);
490 write = atomic_read(&iwb->write); 490 write = atomic_read(&iwb->write);
491 do { 491 do {
492 c = gigaset_invtab[*in++]; 492 c = gigaset_invtab[*in++];
@@ -506,13 +506,13 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
506 switch (bcs->proto2) { 506 switch (bcs->proto2) {
507 case ISDN_PROTO_L2_HDLC: 507 case ISDN_PROTO_L2_HDLC:
508 result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len); 508 result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len);
509 dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d", 509 gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d",
510 __func__, len, result); 510 __func__, len, result);
511 break; 511 break;
512 default: /* assume transparent */ 512 default: /* assume transparent */
513 result = trans_buildframe(bcs->hw.bas->isooutbuf, in, len); 513 result = trans_buildframe(bcs->hw.bas->isooutbuf, in, len);
514 dbg(DEBUG_ISO, "%s: %d bytes trans -> %d", 514 gig_dbg(DEBUG_ISO, "%s: %d bytes trans -> %d",
515 __func__, len, result); 515 __func__, len, result);
516 } 516 }
517 return result; 517 return result;
518} 518}
@@ -528,7 +528,7 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
528 return; 528 return;
529 } 529 }
530 if (unlikely(bcs->skb->len == SBUFSIZE)) { 530 if (unlikely(bcs->skb->len == SBUFSIZE)) {
531 warn("received oversized packet discarded"); 531 dev_warn(bcs->cs->dev, "received oversized packet discarded\n");
532 bcs->hw.bas->giants++; 532 bcs->hw.bas->giants++;
533 dev_kfree_skb_any(bcs->skb); 533 dev_kfree_skb_any(bcs->skb);
534 bcs->skb = NULL; 534 bcs->skb = NULL;
@@ -549,7 +549,7 @@ static inline void hdlc_flush(struct bc_state *bcs)
549 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 549 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
550 skb_reserve(bcs->skb, HW_HDR_LEN); 550 skb_reserve(bcs->skb, HW_HDR_LEN);
551 else 551 else
552 err("could not allocate skb"); 552 dev_err(bcs->cs->dev, "could not allocate skb\n");
553 } 553 }
554 554
555 /* reset packet state */ 555 /* reset packet state */
@@ -571,23 +571,25 @@ static inline void hdlc_done(struct bc_state *bcs)
571 571
572 if ((procskb = bcs->skb) == NULL) { 572 if ((procskb = bcs->skb) == NULL) {
573 /* previous error */ 573 /* previous error */
574 dbg(DEBUG_ISO, "%s: skb=NULL", __func__); 574 gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
575 gigaset_rcv_error(NULL, bcs->cs, bcs); 575 gigaset_rcv_error(NULL, bcs->cs, bcs);
576 } else if (procskb->len < 2) { 576 } else if (procskb->len < 2) {
577 notice("received short frame (%d octets)", procskb->len); 577 dev_notice(bcs->cs->dev, "received short frame (%d octets)\n",
578 procskb->len);
578 bcs->hw.bas->runts++; 579 bcs->hw.bas->runts++;
579 gigaset_rcv_error(procskb, bcs->cs, bcs); 580 gigaset_rcv_error(procskb, bcs->cs, bcs);
580 } else if (bcs->fcs != PPP_GOODFCS) { 581 } else if (bcs->fcs != PPP_GOODFCS) {
581 notice("frame check error (0x%04x)", bcs->fcs); 582 dev_notice(bcs->cs->dev, "frame check error (0x%04x)\n",
583 bcs->fcs);
582 bcs->hw.bas->fcserrs++; 584 bcs->hw.bas->fcserrs++;
583 gigaset_rcv_error(procskb, bcs->cs, bcs); 585 gigaset_rcv_error(procskb, bcs->cs, bcs);
584 } else { 586 } else {
585 procskb->len -= 2; /* subtract FCS */ 587 procskb->len -= 2; /* subtract FCS */
586 procskb->tail -= 2; 588 procskb->tail -= 2;
587 dbg(DEBUG_ISO, 589 gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)",
588 "%s: good frame (%d octets)", __func__, procskb->len); 590 __func__, procskb->len);
589 dump_bytes(DEBUG_STREAM, 591 dump_bytes(DEBUG_STREAM,
590 "rcv data", procskb->data, procskb->len); 592 "rcv data", procskb->data, procskb->len);
591 bcs->hw.bas->goodbytes += procskb->len; 593 bcs->hw.bas->goodbytes += procskb->len;
592 gigaset_rcv_skb(procskb, bcs->cs, bcs); 594 gigaset_rcv_skb(procskb, bcs->cs, bcs);
593 } 595 }
@@ -595,7 +597,7 @@ static inline void hdlc_done(struct bc_state *bcs)
595 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 597 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
596 skb_reserve(bcs->skb, HW_HDR_LEN); 598 skb_reserve(bcs->skb, HW_HDR_LEN);
597 else 599 else
598 err("could not allocate skb"); 600 dev_err(bcs->cs->dev, "could not allocate skb\n");
599 bcs->fcs = PPP_INITFCS; 601 bcs->fcs = PPP_INITFCS;
600} 602}
601 603
@@ -610,14 +612,14 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
610 return; 612 return;
611 } 613 }
612 614
613 notice("received partial byte (%d bits)", inbits); 615 dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
614 bcs->hw.bas->alignerrs++; 616 bcs->hw.bas->alignerrs++;
615 gigaset_rcv_error(bcs->skb, bcs->cs, bcs); 617 gigaset_rcv_error(bcs->skb, bcs->cs, bcs);
616 618
617 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 619 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
618 skb_reserve(bcs->skb, HW_HDR_LEN); 620 skb_reserve(bcs->skb, HW_HDR_LEN);
619 else 621 else
620 err("could not allocate skb"); 622 dev_err(bcs->cs->dev, "could not allocate skb\n");
621 bcs->fcs = PPP_INITFCS; 623 bcs->fcs = PPP_INITFCS;
622} 624}
623 625
@@ -659,7 +661,7 @@ static unsigned char bitcounts[256] = {
659 * bcs receiving B channel structure 661 * bcs receiving B channel structure
660 */ 662 */
661static inline void hdlc_unpack(unsigned char *src, unsigned count, 663static inline void hdlc_unpack(unsigned char *src, unsigned count,
662 struct bc_state *bcs) 664 struct bc_state *bcs)
663{ 665{
664 struct bas_bc_state *ubc; 666 struct bas_bc_state *ubc;
665 int inputstate; 667 int inputstate;
@@ -856,7 +858,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
856 * bcs receiving B channel structure 858 * bcs receiving B channel structure
857 */ 859 */
858static inline void trans_receive(unsigned char *src, unsigned count, 860static inline void trans_receive(unsigned char *src, unsigned count,
859 struct bc_state *bcs) 861 struct bc_state *bcs)
860{ 862{
861 struct sk_buff *skb; 863 struct sk_buff *skb;
862 int dobytes; 864 int dobytes;
@@ -870,7 +872,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
870 if (unlikely((skb = bcs->skb) == NULL)) { 872 if (unlikely((skb = bcs->skb) == NULL)) {
871 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); 873 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
872 if (!skb) { 874 if (!skb) {
873 err("could not allocate skb"); 875 dev_err(bcs->cs->dev, "could not allocate skb\n");
874 return; 876 return;
875 } 877 }
876 skb_reserve(skb, HW_HDR_LEN); 878 skb_reserve(skb, HW_HDR_LEN);
@@ -888,7 +890,8 @@ static inline void trans_receive(unsigned char *src, unsigned count,
888 gigaset_rcv_skb(skb, bcs->cs, bcs); 890 gigaset_rcv_skb(skb, bcs->cs, bcs);
889 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); 891 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN);
890 if (!skb) { 892 if (!skb) {
891 err("could not allocate skb"); 893 dev_err(bcs->cs->dev,
894 "could not allocate skb\n");
892 return; 895 return;
893 } 896 }
894 skb_reserve(bcs->skb, HW_HDR_LEN); 897 skb_reserve(bcs->skb, HW_HDR_LEN);
@@ -921,8 +924,8 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
921 case '\r': 924 case '\r':
922 case '\n': 925 case '\n':
923 /* end of line */ 926 /* end of line */
924 dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)", 927 gig_dbg(DEBUG_TRANSCMD, "%s: End of Command (%d Bytes)",
925 __func__, cbytes); 928 __func__, cbytes);
926 cs->cbytes = cbytes; 929 cs->cbytes = cbytes;
927 gigaset_handle_modem_response(cs); 930 gigaset_handle_modem_response(cs);
928 cbytes = 0; 931 cbytes = 0;
@@ -932,7 +935,7 @@ static void cmd_loop(unsigned char *src, int numbytes, struct inbuf_t *inbuf)
932 if (cbytes < MAX_RESP_SIZE - 1) 935 if (cbytes < MAX_RESP_SIZE - 1)
933 cbytes++; 936 cbytes++;
934 else 937 else
935 warn("response too large"); 938 dev_warn(cs->dev, "response too large\n");
936 } 939 }
937 } 940 }
938 941
@@ -951,27 +954,27 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
951 954
952 head = atomic_read(&inbuf->head); 955 head = atomic_read(&inbuf->head);
953 while (head != (tail = atomic_read(&inbuf->tail))) { 956 while (head != (tail = atomic_read(&inbuf->tail))) {
954 dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); 957 gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail);
955 if (head > tail) 958 if (head > tail)
956 tail = RBUFSIZE; 959 tail = RBUFSIZE;
957 src = inbuf->data + head; 960 src = inbuf->data + head;
958 numbytes = tail - head; 961 numbytes = tail - head;
959 dbg(DEBUG_INTR, "processing %u bytes", numbytes); 962 gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
960 963
961 if (atomic_read(&cs->mstate) == MS_LOCKED) { 964 if (atomic_read(&cs->mstate) == MS_LOCKED) {
962 gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response", 965 gigaset_dbg_buffer(DEBUG_LOCKCMD, "received response",
963 numbytes, src, 0); 966 numbytes, src, 0);
964 gigaset_if_receive(inbuf->cs, src, numbytes); 967 gigaset_if_receive(inbuf->cs, src, numbytes);
965 } else { 968 } else {
966 gigaset_dbg_buffer(DEBUG_CMD, "received response", 969 gigaset_dbg_buffer(DEBUG_CMD, "received response",
967 numbytes, src, 0); 970 numbytes, src, 0);
968 cmd_loop(src, numbytes, inbuf); 971 cmd_loop(src, numbytes, inbuf);
969 } 972 }
970 973
971 head += numbytes; 974 head += numbytes;
972 if (head == RBUFSIZE) 975 if (head == RBUFSIZE)
973 head = 0; 976 head = 0;
974 dbg(DEBUG_INTR, "setting head to %u", head); 977 gig_dbg(DEBUG_INTR, "setting head to %u", head);
975 atomic_set(&inbuf->head, head); 978 atomic_set(&inbuf->head, head);
976 } 979 }
977} 980}
@@ -999,8 +1002,8 @@ int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb)
999 len = skb->len; 1002 len = skb->len;
1000 1003
1001 skb_queue_tail(&bcs->squeue, skb); 1004 skb_queue_tail(&bcs->squeue, skb);
1002 dbg(DEBUG_ISO, 1005 gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d",
1003 "%s: skb queued, qlen=%d", __func__, skb_queue_len(&bcs->squeue)); 1006 __func__, skb_queue_len(&bcs->squeue));
1004 1007
1005 /* tasklet submits URB if necessary */ 1008 /* tasklet submits URB if necessary */
1006 tasklet_schedule(&bcs->hw.bas->sent_tasklet); 1009 tasklet_schedule(&bcs->hw.bas->sent_tasklet);