]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset()
authorDejin Zheng <zhengdejin5@gmail.com>
Mon, 16 Mar 2020 02:32:54 +0000 (10:32 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Mar 2020 09:10:09 +0000 (02:10 -0700)
The dwmac4_dma_reset() function use an open coded of readl_poll_timeout().
Replace the open coded handling with the proper function.

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c

index 9becca2800740968b6b2c995ef4a63c977eade9b..6e30d7eb4983d1f8e903e2d4d57a20f18894964f 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/delay.h>
 #include "common.h"
 #include "dwmac4_dma.h"
 int dwmac4_dma_reset(void __iomem *ioaddr)
 {
        u32 value = readl(ioaddr + DMA_BUS_MODE);
-       int limit;
 
        /* DMA SW reset */
        value |= DMA_BUS_MODE_SFT_RESET;
        writel(value, ioaddr + DMA_BUS_MODE);
-       limit = 10;
-       while (limit--) {
-               if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET))
-                       break;
-               mdelay(10);
-       }
-
-       if (limit < 0)
-               return -EBUSY;
 
-       return 0;
+       return readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
+                                !(value & DMA_BUS_MODE_SFT_RESET),
+                                10000, 100000);
 }
 
 void dwmac4_set_rx_tail_ptr(void __iomem *ioaddr, u32 tail_ptr, u32 chan)