Commit 764e5582 authored by David S. Miller's avatar David S. Miller

Merge branch 'net-stmmac-Use-readl_poll_timeout-to-simplify-the-code'

Dejin Zheng says:

====================
net: stmmac: Use readl_poll_timeout() to simplify the code

This patch sets just for replace the open-coded loop to the
readl_poll_timeout() helper macro for simplify the code in
stmmac driver.

v2 -> v3:
	- return whatever error code by readl_poll_timeout() returned.
v1 -> v2:
	- no changed. I am a newbie and sent this patch a month
	  ago (February 6th). So far, I have not received any comments or
	  suggestion. I think it may be lost somewhere in the world, so
	  resend it.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a1dd3875 45d0da49
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "common.h" #include "common.h"
#include "dwmac4_dma.h" #include "dwmac4_dma.h"
...@@ -14,22 +15,14 @@ ...@@ -14,22 +15,14 @@
int dwmac4_dma_reset(void __iomem *ioaddr) int dwmac4_dma_reset(void __iomem *ioaddr)
{ {
u32 value = readl(ioaddr + DMA_BUS_MODE); u32 value = readl(ioaddr + DMA_BUS_MODE);
int limit;
/* DMA SW reset */ /* DMA SW reset */
value |= DMA_BUS_MODE_SFT_RESET; value |= DMA_BUS_MODE_SFT_RESET;
writel(value, ioaddr + DMA_BUS_MODE); 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) void dwmac4_set_rx_tail_ptr(void __iomem *ioaddr, u32 tail_ptr, u32 chan)
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
*******************************************************************************/ *******************************************************************************/
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/delay.h> #include <linux/delay.h>
#include "common.h" #include "common.h"
#include "stmmac_ptp.h" #include "stmmac_ptp.h"
...@@ -53,7 +54,6 @@ static void config_sub_second_increment(void __iomem *ioaddr, ...@@ -53,7 +54,6 @@ static void config_sub_second_increment(void __iomem *ioaddr,
static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec) static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
{ {
int limit;
u32 value; u32 value;
writel(sec, ioaddr + PTP_STSUR); writel(sec, ioaddr + PTP_STSUR);
...@@ -64,16 +64,9 @@ static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec) ...@@ -64,16 +64,9 @@ static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
writel(value, ioaddr + PTP_TCR); writel(value, ioaddr + PTP_TCR);
/* wait for present system time initialize to complete */ /* wait for present system time initialize to complete */
limit = 10; return readl_poll_timeout(ioaddr + PTP_TCR, value,
while (limit--) { !(value & PTP_TCR_TSINIT),
if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSINIT)) 10000, 100000);
break;
mdelay(10);
}
if (limit < 0)
return -EBUSY;
return 0;
} }
static int config_addend(void __iomem *ioaddr, u32 addend) static int config_addend(void __iomem *ioaddr, u32 addend)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment