From 0dcfb0fcb80d6c6615ce1a78ae78c858a9b1f236 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Wed, 28 Sep 2011 21:02:43 +0200 Subject: Revert "phylib: remove a couple of redundant code lines" This reverts commit 041c542219af7f31c372d89b4c7c6f4c8064a8ce. The lines removed by this commit weren't redundant. The logic is (and probably should be better commented): Find the intersection of the advertised capabilities of both sides of the link (lpa). From that intersection, find the highest capability we can run at (that will be the negotiated link). Now imagine that the intersection (lpa) is (LPA_100HALF | LPA_10FULL). The code will now set phydev->speed to 100, and phydev->duplex to 1, but this link does not support 100FULL. Kudos to Andy Fleming for binging this to attention and for the explanation. Signed-off-by: Wolfgang Denk --- drivers/net/phy/phy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 833a051..8da7688 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -318,10 +318,13 @@ static int genphy_parse_link(struct phy_device *phydev) lpa = phy_read(phydev, MDIO_DEVAD_NONE, MII_ADVERTISE); lpa &= phy_read(phydev, MDIO_DEVAD_NONE, MII_LPA); - if (lpa & (LPA_100FULL | LPA_100HALF)) + if (lpa & (LPA_100FULL | LPA_100HALF)) { phydev->speed = SPEED_100; - if (lpa & (LPA_100FULL | LPA_10FULL)) + if (lpa & LPA_100FULL) + phydev->duplex = DUPLEX_FULL; + + } else if (lpa & LPA_10FULL) phydev->duplex = DUPLEX_FULL; } else { u32 bmcr = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR); -- cgit v1.1