Message ID | 20171025232124.14120-4-f.fainelli@gmail.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
Series | [RFC,net-next,1/4] net: phy: Export phy_stop_machine() | expand |
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 67f25ac29025..69eb985c26fe 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -797,6 +797,11 @@ void phy_disconnect(struct phy_device *phydev) if (phydev->irq > 0) phy_stop_interrupts(phydev); + mutex_lock(&phydev->lock); + WARN_ON(phydev->state != PHY_HALTED); + phydev->state = PHY_HALTED; + mutex_unlock(&phydev->lock); + phy_stop_machine(phydev); phydev->adjust_link = NULL;
While debugging a crash reported by David Daney, we discovered that the offending driver was calling phy_disconnect() without a prior call to phy_stop() although it should have. Add a WARN_ON() to catch such drivers, in order to invite their maintainers to fix them, and also force the PHY state machine to PHY_HALTED since we are about to disconnect anyway, there is nothing we will be doing. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> --- drivers/net/phy/phy_device.c | 5 +++++ 1 file changed, 5 insertions(+)