net: phy: don't double-read link status register if link is up
Subsystems (3)
Heiner Kallweit
maintainerPATCH 1/1 net: phy: don't double-read link status register if link is up
The link status register latches link-down events. Therefore, if link is reported as being up, there's no need for a second read.
Signed-off-by Heiner Kallweit <[email protected]>
--- drivers/net/phy/phy-c45.c | 2 ++ drivers/net/phy/phy_device.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/phy/phy-c45.c +2 -0
@@ -147,6 +147,8 @@ int genphy_c45_read_link(struct phy_device *phydev) val =phy_read_mmd (phydev, devad,MDIO_STAT1 );if (val <0 )return val; +else if (val &MDIO_STAT1_LSTATUS ) +continue ; } val =phy_read_mmd (phydev, devad,MDIO_STAT1 );
drivers/net/phy/phy_device.c +5 -1
@@ -1735,8 +1735,12 @@ int genphy_update_link(struct phy_device *phydev)*/ if (!phy_polling_mode (phydev)) { status =phy_read (phydev,MII_BMSR ); -if (status <0 ) +if (status <0 ) {return status; + }else if (status &BMSR_LSTATUS ) { + phydev->link =1 ; +return 0 ; + } }/* Read link and autonegotiation status */
Signature · 1 line
2.20.1
From: Heiner Kallweit <[email protected]>
Date: Thu, 7 Feb 2019 20:22:20 +0100
Quoted 4 lines
The link status register latches link-down events. Therefore, if link is reported as being up, there's no need for a second read.
Signed-off-by Heiner Kallweit <[email protected]>
Looks good.
Applied, thanks.