Skip to content

Commit 764e558

Browse files
committed
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: David S. Miller <davem@davemloft.net>
2 parents a1dd387 + 45d0da4 commit 764e558

2 files changed

Lines changed: 8 additions & 22 deletions

File tree

‎drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/io.h>
9+
#include <linux/iopoll.h>
910
#include <linux/delay.h>
1011
#include "common.h"
1112
#include "dwmac4_dma.h"
@@ -14,22 +15,14 @@
1415
int dwmac4_dma_reset(void __iomem *ioaddr)
1516
{
1617
u32 value = readl(ioaddr + DMA_BUS_MODE);
17-
int limit;
1818

1919
/* DMA SW reset */
2020
value |= DMA_BUS_MODE_SFT_RESET;
2121
writel(value, ioaddr + DMA_BUS_MODE);
22-
limit = 10;
23-
while (limit--) {
24-
if (!(readl(ioaddr + DMA_BUS_MODE) & DMA_BUS_MODE_SFT_RESET))
25-
break;
26-
mdelay(10);
27-
}
28-
29-
if (limit < 0)
30-
return -EBUSY;
3122

32-
return 0;
23+
return readl_poll_timeout(ioaddr + DMA_BUS_MODE, value,
24+
!(value & DMA_BUS_MODE_SFT_RESET),
25+
10000, 100000);
3326
}
3427

3528
void dwmac4_set_rx_tail_ptr(void __iomem *ioaddr, u32 tail_ptr, u32 chan)

‎drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*******************************************************************************/
1111

1212
#include <linux/io.h>
13+
#include <linux/iopoll.h>
1314
#include <linux/delay.h>
1415
#include "common.h"
1516
#include "stmmac_ptp.h"
@@ -53,7 +54,6 @@ static void config_sub_second_increment(void __iomem *ioaddr,
5354

5455
static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
5556
{
56-
int limit;
5757
u32 value;
5858

5959
writel(sec, ioaddr + PTP_STSUR);
@@ -64,16 +64,9 @@ static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
6464
writel(value, ioaddr + PTP_TCR);
6565

6666
/* wait for present system time initialize to complete */
67-
limit = 10;
68-
while (limit--) {
69-
if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSINIT))
70-
break;
71-
mdelay(10);
72-
}
73-
if (limit < 0)
74-
return -EBUSY;
75-
76-
return 0;
67+
return readl_poll_timeout(ioaddr + PTP_TCR, value,
68+
!(value & PTP_TCR_TSINIT),
69+
10000, 100000);
7770
}
7871

7972
static int config_addend(void __iomem *ioaddr, u32 addend)

0 commit comments

Comments
 (0)