mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code
@ 2020-03-16  2:32 Dejin Zheng
  2020-03-16  2:32 ` [PATCH net-next v3 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-03-16  2:32 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
	mcoquelin.stm32, netdev, linux-stm32, andrew
  Cc: linux-arm-kernel, linux-kernel, Dejin Zheng

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.

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  | 15 ++++-----------
 .../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 15 ++++-----------
 2 files changed, 8 insertions(+), 22 deletions(-)

-- 
2.25.0


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

* [PATCH net-next v3 1/2] net: stmmac: use readl_poll_timeout() function in init_systime()
  2020-03-16  2:32 [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code Dejin Zheng
@ 2020-03-16  2:32 ` Dejin Zheng
  2020-03-16  2:32 ` [PATCH net-next v3 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
  2020-03-16  9:10 ` [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Dejin Zheng @ 2020-03-16  2:32 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
	mcoquelin.stm32, netdev, linux-stm32, andrew
  Cc: 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>
---
v2 -> v3:
	- return whatever error code by readl_poll_timeout() returned.
v1 -> v2:
	- no changed.

 .../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index 020159622559..fcf080243a0f 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,7 +54,6 @@ static void config_sub_second_increment(void __iomem *ioaddr,
 
 static int init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
 {
-	int limit;
 	u32 value;
 
 	writel(sec, ioaddr + PTP_STSUR);
@@ -64,16 +64,9 @@ 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)
-		return -EBUSY;
-
-	return 0;
+	return readl_poll_timeout(ioaddr + PTP_TCR, value,
+				 !(value & PTP_TCR_TSINIT),
+				 10000, 100000);
 }
 
 static int config_addend(void __iomem *ioaddr, u32 addend)
-- 
2.25.0


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

* [PATCH net-next v3 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset()
  2020-03-16  2:32 [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code Dejin Zheng
  2020-03-16  2:32 ` [PATCH net-next v3 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
@ 2020-03-16  2:32 ` Dejin Zheng
  2020-03-16  9:10 ` [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Dejin Zheng @ 2020-03-16  2:32 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
	mcoquelin.stm32, netdev, linux-stm32, andrew
  Cc: 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>
---
v2 -> v3:
	- return whatever error code by readl_poll_timeout() returned.
v1 -> v2:
	- no changed.

 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index 9becca280074..6e30d7eb4983 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,22 +15,14 @@
 int dwmac4_dma_reset(void __iomem *ioaddr)
 {
 	u32 value = readl(ioaddr + DMA_BUS_MODE);
-	int limit;
 
 	/* 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)
-		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)
-- 
2.25.0


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

* Re: [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code
  2020-03-16  2:32 [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code Dejin Zheng
  2020-03-16  2:32 ` [PATCH net-next v3 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
  2020-03-16  2:32 ` [PATCH net-next v3 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
@ 2020-03-16  9:10 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-03-16  9:10 UTC (permalink / raw)
  To: zhengdejin5
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-stm32, andrew, linux-arm-kernel, linux-kernel

From: Dejin Zheng <zhengdejin5@gmail.com>
Date: Mon, 16 Mar 2020 10:32:52 +0800

> 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.

Looks good, series applied, thank you.

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

end of thread, other threads:[~2020-03-16  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16  2:32 [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code Dejin Zheng
2020-03-16  2:32 ` [PATCH net-next v3 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
2020-03-16  2:32 ` [PATCH net-next v3 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
2020-03-16  9:10 ` [PATCH net-next v3 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®