Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 771046d7 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller
Browse files

mdio: Check MDIO_STAT1_FAULT in mdio45_links_ok()



Some PHYs will report that the link is up even though there is a fault
condition.  Therefore, check the fault flag too.  We must also read
STAT2 to reset this flag.

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d4ec09ac
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -109,13 +109,20 @@ int mdio45_links_ok(const struct mdio_if_info *mdio, u32 mmd_mask)
		if (mmd_mask & (1 << devad)) {
			mmd_mask &= ~(1 << devad);

			/* Read twice because link state is latched and a
			 * read moves the current state into the register */
			/* Reset the latched status and fault flags */
			mdio->mdio_read(mdio->dev, mdio->prtad,
					devad, MDIO_STAT1);
			if (devad == MDIO_MMD_PMAPMD || devad == MDIO_MMD_PCS ||
			    devad == MDIO_MMD_PHYXS || devad == MDIO_MMD_DTEXS)
				mdio->mdio_read(mdio->dev, mdio->prtad,
						devad, MDIO_STAT2);

			/* Check the current status and fault flags */
			reg = mdio->mdio_read(mdio->dev, mdio->prtad,
					      devad, MDIO_STAT1);
			if (reg < 0 || !(reg & MDIO_STAT1_LSTATUS))
			if (reg < 0 ||
			    (reg & (MDIO_STAT1_FAULT | MDIO_STAT1_LSTATUS)) !=
			    MDIO_STAT1_LSTATUS)
				return false;
		}
	}