X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fnet%2Fcpsw.c;h=9919d3919fafda77a0bcc399cfe670a5e5215fcf;hb=ae485b540f3b5555f5e043eaf2c8e859052f3b14;hp=b72258f83bfec9694d42637da38620e35b1c09ed;hpb=002e91087c817f8281fccee327e0d8e98c691a2f;p=u-boot diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index b72258f83b..9919d3919f 100644 --- a/drivers/net/cpsw.c +++ b/drivers/net/cpsw.c @@ -910,8 +910,22 @@ out: return ret; } +static int cpsw_reap_completed_packets(struct cpsw_priv *priv) +{ + int timeout = CPDMA_TIMEOUT; + + /* reap completed packets */ + while (timeout-- && + (cpdma_process(priv, &priv->tx_chan, NULL, NULL) >= 0)) + ; + + return timeout; +} + static void _cpsw_halt(struct cpsw_priv *priv) { + cpsw_reap_completed_packets(priv); + writel(0, priv->dma_regs + CPDMA_TXCONTROL); writel(0, priv->dma_regs + CPDMA_RXCONTROL); @@ -925,18 +939,12 @@ static void _cpsw_halt(struct cpsw_priv *priv) static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length) { - void *buffer; - int len; - int timeout = CPDMA_TIMEOUT; + int timeout; flush_dcache_range((unsigned long)packet, (unsigned long)packet + ALIGN(length, PKTALIGN)); - /* first reap completed packets */ - while (timeout-- && - (cpdma_process(priv, &priv->tx_chan, &buffer, &len) >= 0)) - ; - + timeout = cpsw_reap_completed_packets(priv); if (timeout == -1) { printf("cpdma_process timeout\n"); return -ETIMEDOUT; @@ -949,7 +957,7 @@ static int _cpsw_recv(struct cpsw_priv *priv, uchar **pkt) { void *buffer; int len; - int ret = -EAGAIN; + int ret; ret = cpdma_process(priv, &priv->rx_chan, &buffer, &len); if (ret < 0)