aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hardware/mISDN/hfcpci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/hardware/mISDN/hfcpci.c')
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c59
1 files changed, 19 insertions, 40 deletions
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index 27743754ab81..1bd8bc7eb5c7 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -565,11 +565,6 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *rxbz,
565 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL)) 565 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL))
566 new_z2 -= B_FIFO_SIZE; /* buffer wrap */ 566 new_z2 -= B_FIFO_SIZE; /* buffer wrap */
567 567
568 if (fcnt_rx > MAX_DATA_SIZE) { /* flush, if oversized */
569 *z2r = cpu_to_le16(new_z2); /* new position */
570 return;
571 }
572
573 fcnt_tx = le16_to_cpu(*z2t) - le16_to_cpu(*z1t); 568 fcnt_tx = le16_to_cpu(*z2t) - le16_to_cpu(*z1t);
574 if (fcnt_tx <= 0) 569 if (fcnt_tx <= 0)
575 fcnt_tx += B_FIFO_SIZE; 570 fcnt_tx += B_FIFO_SIZE;
@@ -761,9 +756,14 @@ hfcpci_fill_fifo(struct bchannel *bch)
761 756
762 if ((bch->debug & DEBUG_HW_BCHANNEL) && !(bch->debug & DEBUG_HW_BFIFO)) 757 if ((bch->debug & DEBUG_HW_BCHANNEL) && !(bch->debug & DEBUG_HW_BFIFO))
763 printk(KERN_DEBUG "%s\n", __func__); 758 printk(KERN_DEBUG "%s\n", __func__);
764 if ((!bch->tx_skb) || bch->tx_skb->len <= 0) 759 if ((!bch->tx_skb) || bch->tx_skb->len == 0) {
765 return; 760 if (!test_bit(FLG_FILLEMPTY, &bch->Flags) &&
766 count = bch->tx_skb->len - bch->tx_idx; 761 !test_bit(FLG_TRANSPARENT, &bch->Flags))
762 return;
763 count = HFCPCI_FILLEMPTY;
764 } else {
765 count = bch->tx_skb->len - bch->tx_idx;
766 }
767 if ((bch->nr & 2) && (!hc->hw.bswapped)) { 767 if ((bch->nr & 2) && (!hc->hw.bswapped)) {
768 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b2; 768 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.txbz_b2;
769 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.txdat_b2; 769 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.txdat_b2;
@@ -782,16 +782,10 @@ hfcpci_fill_fifo(struct bchannel *bch)
782 fcnt = le16_to_cpu(*z2t) - le16_to_cpu(*z1t); 782 fcnt = le16_to_cpu(*z2t) - le16_to_cpu(*z1t);
783 if (fcnt <= 0) 783 if (fcnt <= 0)
784 fcnt += B_FIFO_SIZE; 784 fcnt += B_FIFO_SIZE;
785 /* fcnt contains available bytes in fifo */ 785 if (test_bit(FLG_FILLEMPTY, &bch->Flags)) {
786 fcnt = B_FIFO_SIZE - fcnt; 786 /* fcnt contains available bytes in fifo */
787 /* remaining bytes to send (bytes in fifo) */ 787 if (count > fcnt)
788 788 count = fcnt;
789 /* "fill fifo if empty" feature */
790 if (test_bit(FLG_FILLEMPTY, &bch->Flags) && !fcnt) {
791 /* printk(KERN_DEBUG "%s: buffer empty, so we have "
792 "underrun\n", __func__); */
793 /* fill buffer, to prevent future underrun */
794 count = HFCPCI_FILLEMPTY;
795 new_z1 = le16_to_cpu(*z1t) + count; 789 new_z1 = le16_to_cpu(*z1t) + count;
796 /* new buffer Position */ 790 /* new buffer Position */
797 if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL)) 791 if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL))
@@ -803,17 +797,20 @@ hfcpci_fill_fifo(struct bchannel *bch)
803 printk(KERN_DEBUG "hfcpci_FFt fillempty " 797 printk(KERN_DEBUG "hfcpci_FFt fillempty "
804 "fcnt(%d) maxl(%d) nz1(%x) dst(%p)\n", 798 "fcnt(%d) maxl(%d) nz1(%x) dst(%p)\n",
805 fcnt, maxlen, new_z1, dst); 799 fcnt, maxlen, new_z1, dst);
806 fcnt += count;
807 if (maxlen > count) 800 if (maxlen > count)
808 maxlen = count; /* limit size */ 801 maxlen = count; /* limit size */
809 memset(dst, 0x2a, maxlen); /* first copy */ 802 memset(dst, bch->fill[0], maxlen); /* first copy */
810 count -= maxlen; /* remaining bytes */ 803 count -= maxlen; /* remaining bytes */
811 if (count) { 804 if (count) {
812 dst = bdata; /* start of buffer */ 805 dst = bdata; /* start of buffer */
813 memset(dst, 0x2a, count); 806 memset(dst, bch->fill[0], count);
814 } 807 }
815 *z1t = cpu_to_le16(new_z1); /* now send data */ 808 *z1t = cpu_to_le16(new_z1); /* now send data */
809 return;
816 } 810 }
811 /* fcnt contains available bytes in fifo */
812 fcnt = B_FIFO_SIZE - fcnt;
813 /* remaining bytes to send (bytes in fifo) */
817 814
818 next_t_frame: 815 next_t_frame:
819 count = bch->tx_skb->len - bch->tx_idx; 816 count = bch->tx_skb->len - bch->tx_idx;
@@ -1531,24 +1528,7 @@ deactivate_bchannel(struct bchannel *bch)
1531static int 1528static int
1532channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) 1529channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
1533{ 1530{
1534 int ret = 0; 1531 return mISDN_ctrl_bchannel(bch, cq);
1535
1536 switch (cq->op) {
1537 case MISDN_CTRL_GETOP:
1538 ret = mISDN_ctrl_bchannel(bch, cq);
1539 cq->op |= MISDN_CTRL_FILL_EMPTY;
1540 break;
1541 case MISDN_CTRL_FILL_EMPTY: /* fill fifo, if empty */
1542 test_and_set_bit(FLG_FILLEMPTY, &bch->Flags);
1543 if (debug & DEBUG_HW_OPEN)
1544 printk(KERN_DEBUG "%s: FILL_EMPTY request (nr=%d "
1545 "off=%d)\n", __func__, bch->nr, !!cq->p1);
1546 break;
1547 default:
1548 ret = mISDN_ctrl_bchannel(bch, cq);
1549 break;
1550 }
1551 return ret;
1552} 1532}
1553static int 1533static int
1554hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) 1534hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
@@ -1964,7 +1944,6 @@ open_bchannel(struct hfc_pci *hc, struct channel_req *rq)
1964 bch = &hc->bch[rq->adr.channel - 1]; 1944 bch = &hc->bch[rq->adr.channel - 1];
1965 if (test_and_set_bit(FLG_OPEN, &bch->Flags)) 1945 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
1966 return -EBUSY; /* b-channel can be only open once */ 1946 return -EBUSY; /* b-channel can be only open once */
1967 test_and_clear_bit(FLG_FILLEMPTY, &bch->Flags);
1968 bch->ch.protocol = rq->protocol; 1947 bch->ch.protocol = rq->protocol;
1969 rq->ch = &bch->ch; /* TODO: E-channel */ 1948 rq->ch = &bch->ch; /* TODO: E-channel */
1970 if (!try_module_get(THIS_MODULE)) 1949 if (!try_module_get(THIS_MODULE))