[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d422fd7b-05e8-c29b-90f6-f2a4742411f1@foss.st.com>
Date: Wed, 8 Mar 2023 09:48:08 +0100
From: Patrice CHOTARD <patrice.chotard@...s.st.com>
To: Alain Volmat <avolmat@...com>, Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>
CC: <linux-arm-kernel@...ts.infradead.org>,
<linux-phy@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] phy: st: miphy28lp: use _poll_timeout functions for waits
Hi Alain
On 2/10/23 23:43, Alain Volmat wrote:
> This commit introduces _poll_timeout functions usage instead of
> wait loops waiting for a status bit.
>
> Signed-off-by: Alain Volmat <avolmat@...com>
> ---
> drivers/phy/st/phy-miphy28lp.c | 42 ++++++++--------------------------
> 1 file changed, 10 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
> index 068160a34f5c..e30305b77f0d 100644
> --- a/drivers/phy/st/phy-miphy28lp.c
> +++ b/drivers/phy/st/phy-miphy28lp.c
> @@ -9,6 +9,7 @@
>
> #include <linux/platform_device.h>
> #include <linux/io.h>
> +#include <linux/iopoll.h>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/of.h>
> @@ -484,19 +485,11 @@ static inline void miphy28lp_pcie_config_gen(struct miphy28lp_phy *miphy_phy)
>
> static inline int miphy28lp_wait_compensation(struct miphy28lp_phy *miphy_phy)
> {
> - unsigned long finish = jiffies + 5 * HZ;
> u8 val;
>
> /* Waiting for Compensation to complete */
> - do {
> - val = readb_relaxed(miphy_phy->base + MIPHY_COMP_FSM_6);
> -
> - if (time_after_eq(jiffies, finish))
> - return -EBUSY;
> - cpu_relax();
> - } while (!(val & COMP_DONE));
> -
> - return 0;
> + return readb_relaxed_poll_timeout(miphy_phy->base + MIPHY_COMP_FSM_6,
> + val, val & COMP_DONE, 1, 5 * USEC_PER_SEC);
> }
>
>
> @@ -805,7 +798,6 @@ static inline void miphy28lp_configure_usb3(struct miphy28lp_phy *miphy_phy)
>
> static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy)
> {
> - unsigned long finish = jiffies + 5 * HZ;
> u8 mask = HFC_PLL | HFC_RDY;
> u8 val;
>
> @@ -816,21 +808,14 @@ static inline int miphy_is_ready(struct miphy28lp_phy *miphy_phy)
> if (miphy_phy->type == PHY_TYPE_SATA)
> mask |= PHY_RDY;
>
> - do {
> - val = readb_relaxed(miphy_phy->base + MIPHY_STATUS_1);
> - if ((val & mask) != mask)
> - cpu_relax();
> - else
> - return 0;
> - } while (!time_after_eq(jiffies, finish));
> -
> - return -EBUSY;
> + return readb_relaxed_poll_timeout(miphy_phy->base + MIPHY_STATUS_1,
> + val, (val & mask) == mask, 1,
> + 5 * USEC_PER_SEC);
> }
>
> static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
> {
> struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
> - unsigned long finish = jiffies + 5 * HZ;
> u32 val;
>
> if (!miphy_phy->osc_rdy)
> @@ -839,17 +824,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
> if (!miphy_phy->syscfg_reg[SYSCFG_STATUS])
> return -EINVAL;
>
> - do {
> - regmap_read(miphy_dev->regmap,
> - miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
> -
> - if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
> - cpu_relax();
> - else
> - return 0;
> - } while (!time_after_eq(jiffies, finish));
> -
> - return -EBUSY;
> + return regmap_read_poll_timeout(miphy_dev->regmap,
> + miphy_phy->syscfg_reg[SYSCFG_STATUS],
> + val, val & MIPHY_OSC_RDY, 1,
> + 5 * USEC_PER_SEC);
> }
>
> static int miphy28lp_get_resource_byname(struct device_node *child,
Reviewed-by: Patrice Chotard <patrice.chotard@...s.st.com>
Thanks
Patrice
Powered by blists - more mailing lists