* [PATCH net-next v2 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code
@ 2020-03-15 15:02 Dejin Zheng
2020-03-15 15:03 ` [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
2020-03-15 15:03 ` [PATCH net-next v2 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
0 siblings, 2 replies; 6+ messages in thread
From: Dejin Zheng @ 2020-03-15 15:02 UTC (permalink / raw)
To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
mcoquelin.stm32, netdev, linux-stm32
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.
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 | 14 ++++++--------
.../net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 14 ++++++--------
2 files changed, 12 insertions(+), 16 deletions(-)
--
2.25.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime()
2020-03-15 15:02 [PATCH net-next v2 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code Dejin Zheng
@ 2020-03-15 15:03 ` Dejin Zheng
2020-03-15 18:25 ` Andrew Lunn
2020-03-15 15:03 ` [PATCH net-next v2 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
1 sibling, 1 reply; 6+ messages in thread
From: Dejin Zheng @ 2020-03-15 15:03 UTC (permalink / raw)
To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
mcoquelin.stm32, netdev, linux-stm32
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>
---
v1 -> v2:
- no changed.
.../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] 6+ messages in thread
* [PATCH net-next v2 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset()
2020-03-15 15:02 [PATCH net-next v2 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code Dejin Zheng
2020-03-15 15:03 ` [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
@ 2020-03-15 15:03 ` Dejin Zheng
1 sibling, 0 replies; 6+ messages in thread
From: Dejin Zheng @ 2020-03-15 15:03 UTC (permalink / raw)
To: peppe.cavallaro, alexandre.torgue, joabreu, davem,
mcoquelin.stm32, netdev, linux-stm32
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>
---
v1 -> v2:
- no changed.
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 9becca280074..af68ef952cd6 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] 6+ messages in thread
* Re: [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime()
2020-03-15 15:03 ` [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
@ 2020-03-15 18:25 ` Andrew Lunn
2020-03-16 0:03 ` David Miller
2020-03-16 2:17 ` Dejin Zheng
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Lunn @ 2020-03-15 18:25 UTC (permalink / raw)
To: Dejin Zheng
Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem,
mcoquelin.stm32, netdev, linux-stm32, linux-kernel,
linux-arm-kernel
On Sun, Mar 15, 2020 at 11:03:00PM +0800, Dejin Zheng wrote:
> 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>
> ---
> v1 -> v2:
> - no changed.
>
> .../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;
Hi Dejin
It is normal to just return whatever error code readl_poll_timeout()
returned.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime()
2020-03-15 18:25 ` Andrew Lunn
@ 2020-03-16 0:03 ` David Miller
2020-03-16 2:17 ` Dejin Zheng
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2020-03-16 0:03 UTC (permalink / raw)
To: andrew
Cc: zhengdejin5, peppe.cavallaro, alexandre.torgue, joabreu,
mcoquelin.stm32, netdev, linux-stm32, linux-kernel,
linux-arm-kernel
From: Andrew Lunn <andrew@lunn.ch>
Date: Sun, 15 Mar 2020 19:25:04 +0100
> It is normal to just return whatever error code readl_poll_timeout()
> returned.
Agreed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime()
2020-03-15 18:25 ` Andrew Lunn
2020-03-16 0:03 ` David Miller
@ 2020-03-16 2:17 ` Dejin Zheng
1 sibling, 0 replies; 6+ messages in thread
From: Dejin Zheng @ 2020-03-16 2:17 UTC (permalink / raw)
To: Andrew Lunn
Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem,
mcoquelin.stm32, netdev, linux-stm32, linux-kernel,
linux-arm-kernel
On Sun, Mar 15, 2020 at 07:25:04PM +0100, Andrew Lunn wrote:
Hi Andrew and David :
> On Sun, Mar 15, 2020 at 11:03:00PM +0800, Dejin Zheng wrote:
> > 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>
> > ---
> > v1 -> v2:
> > - no changed.
> >
> > .../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;
>
> Hi Dejin
>
> It is normal to just return whatever error code readl_poll_timeout()
> returned.
>
> Andrew
You are right. I will modify it. Thanks!
BR,
Dejin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-03-16 2:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-15 15:02 [PATCH net-next v2 0/2] net: stmmac: Use readl_poll_timeout() to simplify the code Dejin Zheng
2020-03-15 15:03 ` [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime() Dejin Zheng
2020-03-15 18:25 ` Andrew Lunn
2020-03-16 0:03 ` David Miller
2020-03-16 2:17 ` Dejin Zheng
2020-03-15 15:03 ` [PATCH net-next v2 2/2] net: stmmac: use readl_poll_timeout() function in dwmac4_dma_reset() Dejin Zheng
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).