diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index f2e896982851..7322471ea223 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -731,6 +731,22 @@ void phy_stop_machine(struct phy_device *phydev) mutex_unlock(&phydev->lock); } +static void phy_process_error(struct phy_device *phydev) +{ + mutex_lock(&phydev->lock); + phydev->state = PHY_HALTED; + mutex_unlock(&phydev->lock); + + phy_trigger_machine(phydev); +} + +static void phy_error_precise(struct phy_device *phydev, + const void *func, int err) +{ + WARN(1, "%pS: returned: %d\n", func, err); + phy_process_error(phydev); +} + /** * phy_error - enter HALTED state for this PHY device * @phydev: target phy_device struct @@ -743,12 +759,7 @@ void phy_stop_machine(struct phy_device *phydev) static void phy_error(struct phy_device *phydev) { WARN_ON(1); - - mutex_lock(&phydev->lock); - phydev->state = PHY_HALTED; - mutex_unlock(&phydev->lock); - - phy_trigger_machine(phydev); + phy_process_error(phydev); } /** @@ -957,6 +968,7 @@ void phy_state_machine(struct work_struct *work) container_of(dwork, struct phy_device, state_queue); bool needs_aneg = false, do_suspend = false; enum phy_state old_state; + const void *func = NULL; int err = 0; mutex_lock(&phydev->lock); @@ -974,6 +986,7 @@ void phy_state_machine(struct work_struct *work) case PHY_NOLINK: case PHY_RUNNING: err = phy_check_link_status(phydev); + func = &phy_check_link_status; break; case PHY_HALTED: if (phydev->link) { @@ -986,13 +999,15 @@ void phy_state_machine(struct work_struct *work) mutex_unlock(&phydev->lock); - if (needs_aneg) + if (needs_aneg) { err = phy_start_aneg(phydev); - else if (do_suspend) + func = &phy_start_aneg; + } else if (do_suspend) { phy_suspend(phydev); + } if (err < 0) - phy_error(phydev); + phy_error_precise(phydev, func, err); if (old_state != phydev->state) { phydev_dbg(phydev, "PHY state change %s -> %s\n",