mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
net: phy: improve handling of PHY_RUNNING in state machine
Handling of state PHY_RUNNING seems to be more complex than it needs to be. If not polling, then we don't have to do anything, we'll receive an interrupt and go to state PHY_CHANGELINK once the link goes down. If polling and link is down, we don't have to go the extra mile over PHY_CHANGELINK and call phy_read_status() again but can set status PHY_NOLINK directly. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0813e95760
commit
74fb5e25a3
1 changed files with 9 additions and 20 deletions
|
@ -941,7 +941,6 @@ void phy_state_machine(struct work_struct *work)
|
||||||
bool needs_aneg = false, do_suspend = false;
|
bool needs_aneg = false, do_suspend = false;
|
||||||
enum phy_state old_state;
|
enum phy_state old_state;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int old_link;
|
|
||||||
|
|
||||||
mutex_lock(&phydev->lock);
|
mutex_lock(&phydev->lock);
|
||||||
|
|
||||||
|
@ -1025,26 +1024,16 @@ void phy_state_machine(struct work_struct *work)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHY_RUNNING:
|
case PHY_RUNNING:
|
||||||
/* Only register a CHANGE if we are polling and link changed
|
if (!phy_polling_mode(phydev))
|
||||||
* since latest checking.
|
break;
|
||||||
*/
|
|
||||||
if (phy_polling_mode(phydev)) {
|
|
||||||
old_link = phydev->link;
|
|
||||||
err = phy_read_status(phydev);
|
|
||||||
if (err)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (old_link != phydev->link)
|
err = phy_read_status(phydev);
|
||||||
phydev->state = PHY_CHANGELINK;
|
if (err)
|
||||||
}
|
break;
|
||||||
/*
|
|
||||||
* Failsafe: check that nobody set phydev->link=0 between two
|
if (!phydev->link) {
|
||||||
* poll cycles, otherwise we won't leave RUNNING state as long
|
phydev->state = PHY_NOLINK;
|
||||||
* as link remains down.
|
phy_link_down(phydev, true);
|
||||||
*/
|
|
||||||
if (!phydev->link && phydev->state == PHY_RUNNING) {
|
|
||||||
phydev->state = PHY_CHANGELINK;
|
|
||||||
phydev_err(phydev, "no link in PHY_RUNNING\n");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHY_CHANGELINK:
|
case PHY_CHANGELINK:
|
||||||
|
|
Loading…
Reference in a new issue