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
1723 if (status < 0)1723 if (status < 0)
1724 return status;1724 return status;
1725 1725
1726 if ((status & BMSR_LSTATUS) == 0)1726 phydev->link = status & BMSR_LSTATUS ? 1 : 0;
1727 phydev->link = 0;1727 phydev->autoneg_complete = status & BMSR_ANEGCOMPLETE ? 1 : 0;
1728 else
1729 phydev->link = 1;
1730 1728
1731 return 0;1729 return 0;
1732}1730}
@@ -1757,7 +1755,7 @@ int genphy_read_status(struct phy_device *phydev) · 24 unmodified lines
1757 1755
1758 linkmode_zero(phydev->lp_advertising);1756 linkmode_zero(phydev->lp_advertising);
1759 1757
1760 if (phydev->autoneg == AUTONEG_ENABLE && phydev->link) {1758 if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) {
1761 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,1759 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
1762 phydev->supported) ||1760 phydev->supported) ||
1763 linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,1761 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
390 unsigned autoneg:1;390 unsigned autoneg:1;
391 /* The most recently read link state */391 /* The most recently read link state */
392 unsigned link:1;392 unsigned link:1;
393 unsigned autoneg_complete:1;
393 394
394 /* Interrupts are enabled */395 /* Interrupts are enabled */
395 unsigned interrupts:1;396 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