diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-02-06 17:22:09 -0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-02-11 08:47:46 +0100 |
commit | a794c02e9e4f68a0e33a867d5864d7615124d376 (patch) | |
tree | 5f349aa64f84750c226ac0f9a75e369b8e407ff8 /drivers/net/e1000 | |
parent | 2b1a27247dde23539bef23559492054f2ae63cf8 (diff) | |
download | barebox-a794c02e9e4f68a0e33a867d5864d7615124d376.tar.gz barebox-a794c02e9e4f68a0e33a867d5864d7615124d376.tar.xz |
net/e1000: Make use of readl_poll_timeout() in e1000_transmit()
Simplify code of e1000_transmit() with readl_poll_timeout().
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/e1000')
-rw-r--r-- | drivers/net/e1000/main.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c index 866d8def3d..425d478edc 100644 --- a/drivers/net/e1000/main.c +++ b/drivers/net/e1000/main.c @@ -33,6 +33,7 @@ tested on both gig copper and gig fiber boards #include <init.h> #include <malloc.h> #include <linux/pci.h> +#include <linux/iopoll.h> #include <dma.h> #include "e1000.h" #include <io-64-nonatomic-lo-hi.h> @@ -3415,9 +3416,9 @@ static int e1000_transmit(struct eth_device *edev, void *txpacket, int length) { struct e1000_hw *hw = edev->priv; struct e1000_tx_desc *txp = &hw->tx_base[hw->tx_tail]; - uint64_t to; dma_addr_t dma; - int ret = 0; + uint32_t stat; + int ret; hw->tx_tail = (hw->tx_tail + 1) % 8; @@ -3433,16 +3434,11 @@ static int e1000_transmit(struct eth_device *edev, void *txpacket, int length) e1000_write_flush(hw); - to = get_time_ns(); - while (1) { - if (readl(&txp->upper.data) & E1000_TXD_STAT_DD) - break; - if (is_timeout(to, MSECOND)) { - dev_dbg(hw->dev, "e1000: tx timeout\n"); - ret = -ETIMEDOUT; - break; - } - } + ret = readl_poll_timeout(&txp->upper.data, + stat, stat & E1000_TXD_STAT_DD, + MSECOND / USECOND); + if (ret) + dev_dbg(hw->dev, "e1000: tx timeout\n"); dma_unmap_single(hw->dev, dma, length, DMA_TO_DEVICE); |