net: stmmac: Use readl_poll_timeout
[sfrench/cifs-2.6.git] / drivers / net / ethernet / stmicro / stmmac / dwmac_lib.c
index e4cda39fb3b55859e00e69c4a1a7c75ba0f85dac..e60bfca2a763325880215bab4592d9dbe5056fbb 100644 (file)
@@ -17,6 +17,7 @@
 *******************************************************************************/
 
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include "common.h"
 #include "dwmac_dma.h"
 
 int dwmac_dma_reset(void __iomem *ioaddr)
 {
        u32 value = readl(ioaddr + DMA_BUS_MODE);
-       int limit;
+       int err;
 
        /* 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)
+       err = readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
+                                !(value & DMA_BUS_MODE_SFT_RESET),
+                                100000, 10000);
+       if (err)
                return -EBUSY;
 
        return 0;