diff options
author | Russell King (Oracle) <rmk+kernel@armlinux.org.uk> | 2024-10-04 12:21:27 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2024-10-09 13:13:11 +0200 |
commit | d69908faf1326fa019f7b44819e8ec459d285e48 (patch) | |
tree | 7ade1645b433839ec65f5b32fcd06d509fc29072 /drivers/net/pcs/pcs-xpcs.c | |
parent | net: pcs: xpcs: add _modify() accessors (diff) | |
download | linux-d69908faf1326fa019f7b44819e8ec459d285e48.tar.xz linux-d69908faf1326fa019f7b44819e8ec459d285e48.zip |
net: pcs: xpcs: convert to use read_poll_timeout()
Convert the xpcs driver to use read_poll_timeout() when waiting for
reset to complete, rather than open-coding this.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pcs/pcs-xpcs.c')
-rw-r--r-- | drivers/net/pcs/pcs-xpcs.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 5ac8262ac264..06a495135418 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -220,18 +220,15 @@ static int xpcs_modify_vpcs(struct dw_xpcs *xpcs, int reg, u16 mask, u16 val) static int xpcs_poll_reset(struct dw_xpcs *xpcs, int dev) { - /* Poll until the reset bit clears (50ms per retry == 0.6 sec) */ - unsigned int retries = 12; - int ret; + int ret, val; - do { - msleep(50); - ret = xpcs_read(xpcs, dev, MDIO_CTRL1); - if (ret < 0) - return ret; - } while (ret & MDIO_CTRL1_RESET && --retries); + ret = read_poll_timeout(xpcs_read, val, + val < 0 || !(val & MDIO_CTRL1_RESET), + 50000, 600000, true, xpcs, dev, MDIO_CTRL1); + if (val < 0) + ret = val; - return (ret & MDIO_CTRL1_RESET) ? -ETIMEDOUT : 0; + return ret; } static int xpcs_soft_reset(struct dw_xpcs *xpcs, |