From: Andrew Lunn <andrew@lunn•ch>
To: Dejin Zheng <zhengdejin5@gmail•com>
Cc: peppe.cavallaro@st•com, alexandre.torgue@st•com,
joabreu@synopsys•com, davem@davemloft•net,
mcoquelin.stm32@gmail•com, netdev@vger•kernel.org,
linux-stm32@st-md-mailman•stormreply.com,
linux-kernel@vger•kernel.org,
linux-arm-kernel@lists•infradead.org
Subject: Re: [PATCH net-next v2 1/2] net: stmmac: use readl_poll_timeout() function in init_systime()
Date: Sun, 15 Mar 2020 19:25:04 +0100 [thread overview]
Message-ID: <20200315182504.GA8524@lunn.ch> (raw)
In-Reply-To: <20200315150301.32129-2-zhengdejin5@gmail.com>
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
next prev parent reply other threads:[~2020-03-15 18:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200315182504.GA8524@lunn.ch \
--to=andrew@lunn$(echo .)ch \
--cc=alexandre.torgue@st$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=joabreu@synopsys$(echo .)com \
--cc=linux-arm-kernel@lists$(echo .)infradead.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-stm32@st-md-mailman$(echo .)stormreply.com \
--cc=mcoquelin.stm32@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=peppe.cavallaro@st$(echo .)com \
--cc=zhengdejin5@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox