aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/isocdata.c
diff options
context:
space:
mode:
authorTilman Schmidt <tilman@imap.cc>2009-10-06 08:19:07 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-07 01:43:50 -0400
commit088ec0cc96e2befd5f3c035123f95c17bdf26e64 (patch)
tree4d0fdcc26e6bfd9ee320cf716f56a695e38be8ae /drivers/isdn/gigaset/isocdata.c
parent7ecc59c1b7fd5749667fc31f8683099cbef38977 (diff)
gigaset: prepare for CAPI implementation
Reorganize the code of the Gigaset driver, moving all isdn4linux dependencies to the source file i4l.c so that it can be replaced by a file capi.c interfacing to Kernel CAPI instead. Impact: refactoring, no functional change Signed-off-by: Tilman Schmidt <tilman@imap.cc> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset/isocdata.c')
-rw-r--r--drivers/isdn/gigaset/isocdata.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c
index 9f3ef7b4248c..7dabfd35874c 100644
--- a/drivers/isdn/gigaset/isocdata.c
+++ b/drivers/isdn/gigaset/isocdata.c
@@ -500,7 +500,7 @@ int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len)
500 int result; 500 int result;
501 501
502 switch (bcs->proto2) { 502 switch (bcs->proto2) {
503 case ISDN_PROTO_L2_HDLC: 503 case L2_HDLC:
504 result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len); 504 result = hdlc_buildframe(bcs->hw.bas->isooutbuf, in, len);
505 gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d", 505 gig_dbg(DEBUG_ISO, "%s: %d bytes HDLC -> %d",
506 __func__, len, result); 506 __func__, len, result);
@@ -542,8 +542,9 @@ static inline void hdlc_flush(struct bc_state *bcs)
542 if (likely(bcs->skb != NULL)) 542 if (likely(bcs->skb != NULL))
543 skb_trim(bcs->skb, 0); 543 skb_trim(bcs->skb, 0);
544 else if (!bcs->ignore) { 544 else if (!bcs->ignore) {
545 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 545 bcs->skb = dev_alloc_skb(SBUFSIZE + bcs->cs->hw_hdr_len);
546 skb_reserve(bcs->skb, HW_HDR_LEN); 546 if (bcs->skb)
547 skb_reserve(bcs->skb, bcs->cs->hw_hdr_len);
547 else 548 else
548 dev_err(bcs->cs->dev, "could not allocate skb\n"); 549 dev_err(bcs->cs->dev, "could not allocate skb\n");
549 } 550 }
@@ -557,7 +558,9 @@ static inline void hdlc_flush(struct bc_state *bcs)
557 */ 558 */
558static inline void hdlc_done(struct bc_state *bcs) 559static inline void hdlc_done(struct bc_state *bcs)
559{ 560{
561 struct cardstate *cs = bcs->cs;
560 struct sk_buff *procskb; 562 struct sk_buff *procskb;
563 unsigned int len;
561 564
562 if (unlikely(bcs->ignore)) { 565 if (unlikely(bcs->ignore)) {
563 bcs->ignore--; 566 bcs->ignore--;
@@ -568,32 +571,33 @@ static inline void hdlc_done(struct bc_state *bcs)
568 if ((procskb = bcs->skb) == NULL) { 571 if ((procskb = bcs->skb) == NULL) {
569 /* previous error */ 572 /* previous error */
570 gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__); 573 gig_dbg(DEBUG_ISO, "%s: skb=NULL", __func__);
571 gigaset_rcv_error(NULL, bcs->cs, bcs); 574 gigaset_isdn_rcv_err(bcs);
572 } else if (procskb->len < 2) { 575 } else if (procskb->len < 2) {
573 dev_notice(bcs->cs->dev, "received short frame (%d octets)\n", 576 dev_notice(cs->dev, "received short frame (%d octets)\n",
574 procskb->len); 577 procskb->len);
575 bcs->hw.bas->runts++; 578 bcs->hw.bas->runts++;
576 gigaset_rcv_error(procskb, bcs->cs, bcs); 579 dev_kfree_skb(procskb);
580 gigaset_isdn_rcv_err(bcs);
577 } else if (bcs->fcs != PPP_GOODFCS) { 581 } else if (bcs->fcs != PPP_GOODFCS) {
578 dev_notice(bcs->cs->dev, "frame check error (0x%04x)\n", 582 dev_notice(cs->dev, "frame check error (0x%04x)\n", bcs->fcs);
579 bcs->fcs);
580 bcs->hw.bas->fcserrs++; 583 bcs->hw.bas->fcserrs++;
581 gigaset_rcv_error(procskb, bcs->cs, bcs); 584 dev_kfree_skb(procskb);
585 gigaset_isdn_rcv_err(bcs);
582 } else { 586 } else {
583 procskb->len -= 2; /* subtract FCS */ 587 len = procskb->len;
584 procskb->tail -= 2; 588 __skb_trim(procskb, len -= 2); /* subtract FCS */
585 gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)", 589 gig_dbg(DEBUG_ISO, "%s: good frame (%d octets)", __func__, len);
586 __func__, procskb->len);
587 dump_bytes(DEBUG_STREAM_DUMP, 590 dump_bytes(DEBUG_STREAM_DUMP,
588 "rcv data", procskb->data, procskb->len); 591 "rcv data", procskb->data, len);
589 bcs->hw.bas->goodbytes += procskb->len; 592 bcs->hw.bas->goodbytes += len;
590 gigaset_rcv_skb(procskb, bcs->cs, bcs); 593 gigaset_skb_rcvd(bcs, procskb);
591 } 594 }
592 595
593 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 596 bcs->skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
594 skb_reserve(bcs->skb, HW_HDR_LEN); 597 if (bcs->skb)
598 skb_reserve(bcs->skb, cs->hw_hdr_len);
595 else 599 else
596 dev_err(bcs->cs->dev, "could not allocate skb\n"); 600 dev_err(cs->dev, "could not allocate skb\n");
597 bcs->fcs = PPP_INITFCS; 601 bcs->fcs = PPP_INITFCS;
598} 602}
599 603
@@ -610,12 +614,8 @@ static inline void hdlc_frag(struct bc_state *bcs, unsigned inbits)
610 614
611 dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits); 615 dev_notice(bcs->cs->dev, "received partial byte (%d bits)\n", inbits);
612 bcs->hw.bas->alignerrs++; 616 bcs->hw.bas->alignerrs++;
613 gigaset_rcv_error(bcs->skb, bcs->cs, bcs); 617 gigaset_isdn_rcv_err(bcs);
614 618 __skb_trim(bcs->skb, 0);
615 if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
616 skb_reserve(bcs->skb, HW_HDR_LEN);
617 else
618 dev_err(bcs->cs->dev, "could not allocate skb\n");
619 bcs->fcs = PPP_INITFCS; 619 bcs->fcs = PPP_INITFCS;
620} 620}
621 621
@@ -648,8 +648,8 @@ static const unsigned char bitcounts[256] = {
648/* hdlc_unpack 648/* hdlc_unpack
649 * perform HDLC frame processing (bit unstuffing, flag detection, FCS calculation) 649 * perform HDLC frame processing (bit unstuffing, flag detection, FCS calculation)
650 * on a sequence of received data bytes (8 bits each, LSB first) 650 * on a sequence of received data bytes (8 bits each, LSB first)
651 * pass on successfully received, complete frames as SKBs via gigaset_rcv_skb 651 * pass on successfully received, complete frames as SKBs via gigaset_skb_rcvd
652 * notify of errors via gigaset_rcv_error 652 * notify of errors via gigaset_isdn_rcv_err
653 * tally frames, errors etc. in BC structure counters 653 * tally frames, errors etc. in BC structure counters
654 * parameters: 654 * parameters:
655 * src received data 655 * src received data
@@ -841,7 +841,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
841} 841}
842 842
843/* trans_receive 843/* trans_receive
844 * pass on received USB frame transparently as SKB via gigaset_rcv_skb 844 * pass on received USB frame transparently as SKB via gigaset_skb_rcvd
845 * invert bytes 845 * invert bytes
846 * tally frames, errors etc. in BC structure counters 846 * tally frames, errors etc. in BC structure counters
847 * parameters: 847 * parameters:
@@ -852,6 +852,7 @@ static inline void hdlc_unpack(unsigned char *src, unsigned count,
852static inline void trans_receive(unsigned char *src, unsigned count, 852static inline void trans_receive(unsigned char *src, unsigned count,
853 struct bc_state *bcs) 853 struct bc_state *bcs)
854{ 854{
855 struct cardstate *cs = bcs->cs;
855 struct sk_buff *skb; 856 struct sk_buff *skb;
856 int dobytes; 857 int dobytes;
857 unsigned char *dst; 858 unsigned char *dst;
@@ -862,12 +863,12 @@ static inline void trans_receive(unsigned char *src, unsigned count,
862 return; 863 return;
863 } 864 }
864 if (unlikely((skb = bcs->skb) == NULL)) { 865 if (unlikely((skb = bcs->skb) == NULL)) {
865 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); 866 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
866 if (!skb) { 867 if (!skb) {
867 dev_err(bcs->cs->dev, "could not allocate skb\n"); 868 dev_err(cs->dev, "could not allocate skb\n");
868 return; 869 return;
869 } 870 }
870 skb_reserve(skb, HW_HDR_LEN); 871 skb_reserve(skb, cs->hw_hdr_len);
871 } 872 }
872 bcs->hw.bas->goodbytes += skb->len; 873 bcs->hw.bas->goodbytes += skb->len;
873 dobytes = TRANSBUFSIZE - skb->len; 874 dobytes = TRANSBUFSIZE - skb->len;
@@ -881,14 +882,14 @@ static inline void trans_receive(unsigned char *src, unsigned count,
881 if (dobytes == 0) { 882 if (dobytes == 0) {
882 dump_bytes(DEBUG_STREAM_DUMP, 883 dump_bytes(DEBUG_STREAM_DUMP,
883 "rcv data", skb->data, skb->len); 884 "rcv data", skb->data, skb->len);
884 gigaset_rcv_skb(skb, bcs->cs, bcs); 885 gigaset_skb_rcvd(bcs, skb);
885 bcs->skb = skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN); 886 bcs->skb = skb =
887 dev_alloc_skb(SBUFSIZE + cs->hw_hdr_len);
886 if (!skb) { 888 if (!skb) {
887 dev_err(bcs->cs->dev, 889 dev_err(cs->dev, "could not allocate skb\n");
888 "could not allocate skb\n");
889 return; 890 return;
890 } 891 }
891 skb_reserve(bcs->skb, HW_HDR_LEN); 892 skb_reserve(skb, cs->hw_hdr_len);
892 dobytes = TRANSBUFSIZE; 893 dobytes = TRANSBUFSIZE;
893 } 894 }
894 } 895 }
@@ -897,7 +898,7 @@ static inline void trans_receive(unsigned char *src, unsigned count,
897void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs) 898void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs)
898{ 899{
899 switch (bcs->proto2) { 900 switch (bcs->proto2) {
900 case ISDN_PROTO_L2_HDLC: 901 case L2_HDLC:
901 hdlc_unpack(src, count, bcs); 902 hdlc_unpack(src, count, bcs);
902 break; 903 break;
903 default: /* assume transparent */ 904 default: /* assume transparent */
@@ -981,8 +982,10 @@ void gigaset_isoc_input(struct inbuf_t *inbuf)
981 * @bcs: B channel descriptor structure. 982 * @bcs: B channel descriptor structure.
982 * @skb: data to send. 983 * @skb: data to send.
983 * 984 *
984 * Called by i4l.c to queue an skb for sending, and start transmission if 985 * Called by LL to queue an skb for sending, and start transmission if
985 * necessary. 986 * necessary.
987 * Once the payload data has been transmitted completely, gigaset_skb_sent()
988 * will be called with the first cs->hw_hdr_len bytes of skb->head preserved.
986 * 989 *
987 * Return value: 990 * Return value:
988 * number of bytes accepted for sending (skb->len) if ok, 991 * number of bytes accepted for sending (skb->len) if ok,