History

net: phy: fix autoneg mismatch case in genphy_read_status

The original patch didn't consider the case that autoneg process finishes successfully but both link partners have no mode in common. In this case there's no link, nevertheless we may be interested in what the link partner advertised. Like phydev->link we set phydev->autoneg_complete in genphy_update_link() and use the stored value in genphy_read_status(). This way we don't have to read register BMSR again.

Heiner Kallweit committed 7 years ago

Commit 4950c2b1 parent 49ffba32 files · +4 −5Browse files

Unified · Split

2 files
  1. drivers/net/phy/phy_device.c +3 −5
  2. include/linux/phy.h +1 −0
drivers/net/phy/phy_device.c+3−5
@@ -1723,10 +1723,8 @@ int genphy_update_link(struct phy_device *phydev) · 1722 unmodified lines
17231723 if (status < 0)
17241724 return status;
17251725
1726− if ((status & BMSR_LSTATUS) == 0)
1727− phydev->link = 0;
1728− else
1729− phydev->link = 1;
1726+ phydev->link = status & BMSR_LSTATUS ? 1 : 0;
1727+ phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0;
17301728
17311729 return 0;
17321730 }
@@ -1757,7 +1755,7 @@ int genphy_read_status(struct phy_device *phydev) · 24 unmodified lines
17571755
17581756 linkmode_zero(phydev->lp_advertising);
17591757
1760− if (phydev->autoneg == AUTONEG_ENABLE && phydev->link) {
1758+ if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) {
17611759 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
17621760 phydev->supported) ||
17631761 linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
include/linux/phy.h+1−0
@@ -390,6 +390,7 @@ struct phy_device { · 389 unmodified lines
390390 unsigned autoneg:1;
391391 /* The most recently read link state */
392392 unsigned link:1;
393+ unsigned autoneg_complete:1;
393394
394395 /* Interrupts are enabled */
395396 unsigned interrupts:1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t