Commit 54a600ed authored by Justin Chen's avatar Justin Chen Committed by Jakub Kicinski

net: mdio: mdio-bcm-unimac: Use read_poll_timeout

Simplify the code by using read_poll_timeout().
Signed-off-by: default avatarJustin Chen <justin.chen@broadcom.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20231213222744.2891184-3-justin.chen@broadcom.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 268531be
...@@ -73,15 +73,10 @@ static inline void unimac_mdio_start(struct unimac_mdio_priv *priv) ...@@ -73,15 +73,10 @@ static inline void unimac_mdio_start(struct unimac_mdio_priv *priv)
unimac_mdio_writel(priv, reg, MDIO_CMD); unimac_mdio_writel(priv, reg, MDIO_CMD);
} }
static inline unsigned int unimac_mdio_busy(struct unimac_mdio_priv *priv)
{
return unimac_mdio_readl(priv, MDIO_CMD) & MDIO_START_BUSY;
}
static int unimac_mdio_poll(void *wait_func_data) static int unimac_mdio_poll(void *wait_func_data)
{ {
struct unimac_mdio_priv *priv = wait_func_data; struct unimac_mdio_priv *priv = wait_func_data;
unsigned int timeout = 100; u32 val;
/* /*
* C22 transactions should take ~25 usec, will need to adjust * C22 transactions should take ~25 usec, will need to adjust
...@@ -89,14 +84,8 @@ static int unimac_mdio_poll(void *wait_func_data) ...@@ -89,14 +84,8 @@ static int unimac_mdio_poll(void *wait_func_data)
*/ */
udelay(30); udelay(30);
do { return read_poll_timeout(unimac_mdio_readl, val, !(val & MDIO_START_BUSY),
if (!unimac_mdio_busy(priv)) 2000, 100000, false, priv, MDIO_CMD);
return 0;
usleep_range(1000, 2000);
} while (--timeout);
return -ETIMEDOUT;
} }
static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg) static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment