From f0b51ddf4d6c3cafcb39b414be115c3cc7e03583 Mon Sep 17 00:00:00 2001 From: Matthew Fredrickson Date: Mon, 23 Nov 2009 19:41:42 +0000 Subject: Commit fix for problem frames being received for WCB4XXP_HDLC_BUF_LEN multiple sized frames. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@7640 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/wcb4xxp/base.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'drivers/dahdi/wcb4xxp/base.c') diff --git a/drivers/dahdi/wcb4xxp/base.c b/drivers/dahdi/wcb4xxp/base.c index b6d1c8c..d7484a7 100644 --- a/drivers/dahdi/wcb4xxp/base.c +++ b/drivers/dahdi/wcb4xxp/base.c @@ -1617,6 +1617,7 @@ static int hdlc_rx_frame(struct b4xxp_span *bspan) char debugbuf[256]; unsigned long irq_flags; struct b4xxp *b4 = bspan->parent; + unsigned char stat; fifo = bspan->fifos[2]; @@ -1644,10 +1645,14 @@ static int hdlc_rx_frame(struct b4xxp_span *bspan) zleft = zlen + 1; /* include STAT byte that the HFC injects after FCS */ do { - if (zleft > WCB4XXP_HDLC_BUF_LEN) + int truncated; + if (zleft > WCB4XXP_HDLC_BUF_LEN) { + truncated = 1; j = WCB4XXP_HDLC_BUF_LEN; - else + } else { + truncated = 0; j = zleft; + } spin_lock_irqsave(&b4->fifolock, irq_flags); hfc_setreg_waitbusy(b4, R_FIFO, (fifo << V_FIFO_NUM_SHIFT) | V_FIFO_DIR); @@ -1656,8 +1661,8 @@ static int hdlc_rx_frame(struct b4xxp_span *bspan) spin_unlock_irqrestore(&b4->fifolock, irq_flags); /* don't send STAT byte to DAHDI */ - if (bspan->sigchan) - dahdi_hdlc_putbuf(bspan->sigchan, buf, (j == WCB4XXP_HDLC_BUF_LEN) ? j : j - 1); + if ((bspan->sigchan) && (j > 1)) + dahdi_hdlc_putbuf(bspan->sigchan, buf, truncated ? j : j - 1); zleft -= j; if (DBG_HDLC && DBG_SPANFILTER) { @@ -1666,6 +1671,7 @@ static int hdlc_rx_frame(struct b4xxp_span *bspan) for (i=0; i < j; i++) printk("%02x%c", buf[i], (i < ( j - 1)) ? ' ':'\n'); } } while (zleft > 0); + stat = buf[j - 1]; /* Frame received, increment F2 and get an updated count of frames left */ spin_lock_irqsave(&b4->fifolock, irq_flags); @@ -1684,7 +1690,6 @@ static int hdlc_rx_frame(struct b4xxp_span *bspan) dev_notice(b4->dev, "odd, zlen less then 3?\n"); dahdi_hdlc_abort(bspan->sigchan, DAHDI_EVENT_ABORT); } else { - unsigned char stat = buf[i - 1]; /* if STAT != 0, indicates bad frame */ if (stat != 0x00) { -- cgit v1.2.3