linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2]  use readl_poll_timeout() function
@ 2020-02-06 14:24 Dejin Zheng
  2020-02-06 14:24 ` [PATCH 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dejin Zheng @ 2020-02-06 14:24 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
	mcoquelin.stm32, netdev
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, Dejin Zheng

This patch series just for use readl_poll_timeout() function
to replace the open coded handling of use readl_poll_timeout()
in the stmmac driver. There are two modification positions,
the one in the init_systime() function and the other in the
dwmac4_dma_reset() function.

Dejin Zheng (2):
  net: stmmac: use readl_poll_timeout() function in init_systime()
  net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset()

 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c   | 14 ++++++--------
 .../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c  | 14 ++++++--------
 2 files changed, 12 insertions(+), 16 deletions(-)

-- 
2.25.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] net: stmmac: use readl_poll_timeout() function in init_systime()
  2020-02-06 14:24 [PATCH 0/2] use readl_poll_timeout() function Dejin Zheng
@ 2020-02-06 14:24 ` Dejin Zheng
  2020-02-06 14:24 ` [PATCH 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
  2020-02-06 14:51 ` [PATCH 0/2] use readl_poll_timeout() function David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Dejin Zheng @ 2020-02-06 14:24 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
	mcoquelin.stm32, netdev
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, Dejin Zheng

The init_systime() 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>
---
 .../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c  | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index 020159622559..2a24e2a7db3b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -10,6 +10,7 @@
 *******************************************************************************/
 
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/delay.h>
 #include "common.h"
 #include "stmmac_ptp.h"
@@ -53,8 +54,8 @@ static void config_sub_second_increment(void __iomem *ioaddr,
 
 static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
 {
-	int limit;
 	u32 value;
+	int err;
 
 	writel(sec, ioaddr + PTP_STSUR);
 	writel(nsec, ioaddr + PTP_STNSUR);
@@ -64,13 +65,10 @@ static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
 	writel(value, ioaddr + PTP_TCR);
 
 	/* wait for present system time initialize to complete */
-	limit = 10;
-	while (limit--) {
-		if (!(readl(ioaddr + PTP_TCR) & PTP_TCR_TSINIT))
-			break;
-		mdelay(10);
-	}
-	if (limit < 0)
+	err = readl_poll_timeout(ioaddr + PTP_TCR, value,
+				 !(value & PTP_TCR_TSINIT),
+				 10000, 100000);
+	if (err)
 		return -EBUSY;
 
 	return 0;
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset()
  2020-02-06 14:24 [PATCH 0/2] use readl_poll_timeout() function Dejin Zheng
  2020-02-06 14:24 ` [PATCH 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
@ 2020-02-06 14:24 ` Dejin Zheng
  2020-02-06 14:51 ` [PATCH 0/2] use readl_poll_timeout() function David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Dejin Zheng @ 2020-02-06 14:24 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
	mcoquelin.stm32, netdev
  Cc: linux-stm32, linux-arm-kernel, linux-kernel, Dejin Zheng

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>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index f2a29a90e085..6b911e360e27 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -6,6 +6,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/delay.h>
 #include "common.h"
 #include "dwmac4_dma.h"
@@ -14,19 +15,16 @@
 int dwmac4_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),
+				 10000, 100000);
+	if (err)
 		return -EBUSY;
 
 	return 0;
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] use readl_poll_timeout() function
  2020-02-06 14:24 [PATCH 0/2] use readl_poll_timeout() function Dejin Zheng
  2020-02-06 14:24 ` [PATCH 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
  2020-02-06 14:24 ` [PATCH 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
@ 2020-02-06 14:51 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-02-06 14:51 UTC (permalink / raw)
  To: zhengdejin5
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-stm32, linux-arm-kernel, linux-kernel

From: Dejin Zheng <zhengdejin5@gmail.com>
Date: Thu,  6 Feb 2020 22:24:02 +0800

> This patch series just for use readl_poll_timeout() function
> to replace the open coded handling of use readl_poll_timeout()
> in the stmmac driver. There are two modification positions,
> the one in the init_systime() function and the other in the
> dwmac4_dma_reset() function.

This is a cleanup and thus appropriate only for net-next, which
is closed right now.

When you submit networking patches you must indicate the tree
you are targetting in the Subject line, for example:

	Subject: [PATCH net-next 0/2] ...

Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-06 14:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-06 14:24 [PATCH 0/2] use readl_poll_timeout() function Dejin Zheng
2020-02-06 14:24 ` [PATCH 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
2020-02-06 14:24 ` [PATCH 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
2020-02-06 14:51 ` [PATCH 0/2] use readl_poll_timeout() function David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).