From: Russell King (Oracle) Date: Fri, 4 Oct 2024 10:21:27 +0000 (+0100) Subject: net: pcs: xpcs: convert to use read_poll_timeout() X-Git-Tag: v6.13-rc1~135^2~381^2~3 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=d69908faf1326fa019f7b44819e8ec459d285e48;p=linux-block.git 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) Signed-off-by: David S. Miller --- 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,