From: Krzysztof Kozlowski <krzk@kernel.org>
To: Anand Moon <linux.amoon@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
Kishon Vijay Abraham I <kishon@ti.com>,
Vinod Koul <vkoul@kernel.org>, Kukjin Kim <kgene@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH v3] phy: samsung: Use readl_poll_timeout function
Date: Tue, 7 Jul 2020 13:36:45 +0200 [thread overview]
Message-ID: <20200707113645.GA27280@kozik-lap> (raw)
In-Reply-To: <20200707095908.372-1-linux.amoon@gmail.com>
On Tue, Jul 07, 2020 at 09:59:08AM +0000, Anand Moon wrote:
> Instead of a busy waiting loop while loop using udelay
You doubled "loop".
> use readl_poll_timeout function to check the condition
> is met or timeout occurs in crport_handshake function.
Still you did not mention that you convert the function to use sleeping
primitive. You also did not mention whether it is actually allowed in
this context and I am not sure if you investigated it.
Best regards,
Krzysztof
>
> Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800")
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Changes v3:
> --Fix the commit message.
> --Drop the variable, used the value directly.
> Changes v2:
> --used the default timeout values.
> --Added missing Fixed tags.
> ---
> drivers/phy/samsung/phy-exynos5-usbdrd.c | 35 +++++++-----------------
> 1 file changed, 10 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> index e510732afb8b..fa75fa88da33 100644
> --- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
> +++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> @@ -16,6 +16,7 @@
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/of_device.h>
> +#include <linux/iopoll.h>
> #include <linux/phy/phy.h>
> #include <linux/platform_device.h>
> #include <linux/mutex.h>
> @@ -556,40 +557,24 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy)
> static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd,
> u32 val, u32 cmd)
> {
> - u32 usec = 100;
> unsigned int result;
> + int err;
>
> writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
>
> - do {
> - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1);
> - if (result & PHYREG1_CR_ACK)
> - break;
> -
> - udelay(1);
> - } while (usec-- > 0);
> -
> - if (!usec) {
> - dev_err(phy_drd->dev,
> - "CRPORT handshake timeout1 (0x%08x)\n", val);
> + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
> + result, (result & PHYREG1_CR_ACK), 1, 100);
> + if (err) {
> + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val);
> return -ETIME;
> }
>
> - usec = 100;
> -
> writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
>
> - do {
> - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1);
> - if (!(result & PHYREG1_CR_ACK))
> - break;
> -
> - udelay(1);
> - } while (usec-- > 0);
> -
> - if (!usec) {
> - dev_err(phy_drd->dev,
> - "CRPORT handshake timeout2 (0x%08x)\n", val);
> + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
> + result, !(result & PHYREG1_CR_ACK), 1, 100);
> + if (err) {
> + dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val);
> return -ETIME;
> }
>
> --
> 2.27.0
>
WARNING: multiple messages have this Message-ID (diff)
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Anand Moon <linux.amoon@gmail.com>
Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
Kishon Vijay Abraham I <kishon@ti.com>,
Vinod Koul <vkoul@kernel.org>, Kukjin Kim <kgene@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH v3] phy: samsung: Use readl_poll_timeout function
Date: Tue, 7 Jul 2020 13:36:45 +0200 [thread overview]
Message-ID: <20200707113645.GA27280@kozik-lap> (raw)
In-Reply-To: <20200707095908.372-1-linux.amoon@gmail.com>
On Tue, Jul 07, 2020 at 09:59:08AM +0000, Anand Moon wrote:
> Instead of a busy waiting loop while loop using udelay
You doubled "loop".
> use readl_poll_timeout function to check the condition
> is met or timeout occurs in crport_handshake function.
Still you did not mention that you convert the function to use sleeping
primitive. You also did not mention whether it is actually allowed in
this context and I am not sure if you investigated it.
Best regards,
Krzysztof
>
> Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800")
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Changes v3:
> --Fix the commit message.
> --Drop the variable, used the value directly.
> Changes v2:
> --used the default timeout values.
> --Added missing Fixed tags.
> ---
> drivers/phy/samsung/phy-exynos5-usbdrd.c | 35 +++++++-----------------
> 1 file changed, 10 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> index e510732afb8b..fa75fa88da33 100644
> --- a/drivers/phy/samsung/phy-exynos5-usbdrd.c
> +++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c
> @@ -16,6 +16,7 @@
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/of_device.h>
> +#include <linux/iopoll.h>
> #include <linux/phy/phy.h>
> #include <linux/platform_device.h>
> #include <linux/mutex.h>
> @@ -556,40 +557,24 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy)
> static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd,
> u32 val, u32 cmd)
> {
> - u32 usec = 100;
> unsigned int result;
> + int err;
>
> writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
>
> - do {
> - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1);
> - if (result & PHYREG1_CR_ACK)
> - break;
> -
> - udelay(1);
> - } while (usec-- > 0);
> -
> - if (!usec) {
> - dev_err(phy_drd->dev,
> - "CRPORT handshake timeout1 (0x%08x)\n", val);
> + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
> + result, (result & PHYREG1_CR_ACK), 1, 100);
> + if (err) {
> + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val);
> return -ETIME;
> }
>
> - usec = 100;
> -
> writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0);
>
> - do {
> - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1);
> - if (!(result & PHYREG1_CR_ACK))
> - break;
> -
> - udelay(1);
> - } while (usec-- > 0);
> -
> - if (!usec) {
> - dev_err(phy_drd->dev,
> - "CRPORT handshake timeout2 (0x%08x)\n", val);
> + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1,
> + result, !(result & PHYREG1_CR_ACK), 1, 100);
> + if (err) {
> + dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val);
> return -ETIME;
> }
>
> --
> 2.27.0
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-07-07 11:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 9:59 [PATCH v3] phy: samsung: Use readl_poll_timeout function Anand Moon
2020-07-07 9:59 ` Anand Moon
2020-07-07 11:36 ` Krzysztof Kozlowski [this message]
2020-07-07 11:36 ` Krzysztof Kozlowski
2020-07-08 8:29 ` Anand Moon
2020-07-08 8:29 ` Anand Moon
2020-07-08 12:31 ` Krzysztof Kozlowski
2020-07-08 12:31 ` Krzysztof Kozlowski
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=20200707113645.GA27280@kozik-lap \
--to=krzk@kernel.org \
--cc=kgene@kernel.org \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux.amoon@gmail.com \
--cc=m.szyprowski@samsung.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.