Commit ff8ed737 authored by Dejin Zheng's avatar Dejin Zheng Committed by David S. Miller

net: stmmac: use readl_poll_timeout() function in init_systime()

The init_systime() function use an open coded of readl_poll_timeout().
Replace the open coded handling with the proper function.
Signed-off-by: default avatarDejin Zheng <zhengdejin5@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a1dd3875
...@@ -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