]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: pcs: altera-tse: use read_poll_timeout to wait for reset
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Fri, 25 Nov 2022 13:17:59 +0000 (14:17 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 30 Nov 2022 04:29:55 +0000 (20:29 -0800)
Software resets on the TSE PCS don't clear registers, but rather reset
all internal state machines regarding AN, comma detection and
encoding/decoding. Use read_poll_timeout to wait for the reset to clear
instead of manually polling the register.

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/pcs/pcs-altera-tse.c

index 97a7cabff962a4db891c148a20ed77e5589a7775..e86cadc391e80069ded8c02ea4c54beb7f78e72f 100644 (file)
@@ -60,7 +60,6 @@ static void tse_pcs_write(struct altera_tse_pcs *tse_pcs, int regnum,
 
 static int tse_pcs_reset(struct altera_tse_pcs *tse_pcs)
 {
-       int i = 0;
        u16 bmcr;
 
        /* Reset PCS block */
@@ -68,13 +67,9 @@ static int tse_pcs_reset(struct altera_tse_pcs *tse_pcs)
        bmcr |= BMCR_RESET;
        tse_pcs_write(tse_pcs, MII_BMCR, bmcr);
 
-       for (i = 0; i < SGMII_PCS_SW_RESET_TIMEOUT; i++) {
-               if (!(tse_pcs_read(tse_pcs, MII_BMCR) & BMCR_RESET))
-                       return 0;
-               udelay(1);
-       }
-
-       return -ETIMEDOUT;
+       return read_poll_timeout(tse_pcs_read, bmcr, (bmcr & BMCR_RESET),
+                                10, SGMII_PCS_SW_RESET_TIMEOUT, 1,
+                                tse_pcs, MII_BMCR);
 }
 
 static int alt_tse_pcs_validate(struct phylink_pcs *pcs,