aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/phy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/phy/phy.c')
-rw-r--r--drivers/net/phy/phy.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index d33e7b3caf03..c5675df5fc6f 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -543,13 +543,6 @@ int phy_start_aneg(struct phy_device *phydev)
543 543
544 mutex_lock(&phydev->lock); 544 mutex_lock(&phydev->lock);
545 545
546 if (!__phy_is_started(phydev)) {
547 WARN(1, "called from state %s\n",
548 phy_state_to_str(phydev->state));
549 err = -EBUSY;
550 goto out_unlock;
551 }
552
553 if (AUTONEG_DISABLE == phydev->autoneg) 546 if (AUTONEG_DISABLE == phydev->autoneg)
554 phy_sanitize_settings(phydev); 547 phy_sanitize_settings(phydev);
555 548
@@ -560,11 +553,13 @@ int phy_start_aneg(struct phy_device *phydev)
560 if (err < 0) 553 if (err < 0)
561 goto out_unlock; 554 goto out_unlock;
562 555
563 if (phydev->autoneg == AUTONEG_ENABLE) { 556 if (phy_is_started(phydev)) {
564 err = phy_check_link_status(phydev); 557 if (phydev->autoneg == AUTONEG_ENABLE) {
565 } else { 558 err = phy_check_link_status(phydev);
566 phydev->state = PHY_FORCING; 559 } else {
567 phydev->link_timeout = PHY_FORCE_TIMEOUT; 560 phydev->state = PHY_FORCING;
561 phydev->link_timeout = PHY_FORCE_TIMEOUT;
562 }
568 } 563 }
569 564
570out_unlock: 565out_unlock:
@@ -714,7 +709,7 @@ void phy_stop_machine(struct phy_device *phydev)
714 cancel_delayed_work_sync(&phydev->state_queue); 709 cancel_delayed_work_sync(&phydev->state_queue);
715 710
716 mutex_lock(&phydev->lock); 711 mutex_lock(&phydev->lock);
717 if (__phy_is_started(phydev)) 712 if (phy_is_started(phydev))
718 phydev->state = PHY_UP; 713 phydev->state = PHY_UP;
719 mutex_unlock(&phydev->lock); 714 mutex_unlock(&phydev->lock);
720} 715}
@@ -767,9 +762,6 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat)
767{ 762{
768 struct phy_device *phydev = phy_dat; 763 struct phy_device *phydev = phy_dat;
769 764
770 if (!phy_is_started(phydev))
771 return IRQ_NONE; /* It can't be ours. */
772
773 if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev)) 765 if (phydev->drv->did_interrupt && !phydev->drv->did_interrupt(phydev))
774 return IRQ_NONE; 766 return IRQ_NONE;
775 767
@@ -847,15 +839,14 @@ EXPORT_SYMBOL(phy_stop_interrupts);
847 */ 839 */
848void phy_stop(struct phy_device *phydev) 840void phy_stop(struct phy_device *phydev)
849{ 841{
850 mutex_lock(&phydev->lock); 842 if (!phy_is_started(phydev)) {
851
852 if (!__phy_is_started(phydev)) {
853 WARN(1, "called from state %s\n", 843 WARN(1, "called from state %s\n",
854 phy_state_to_str(phydev->state)); 844 phy_state_to_str(phydev->state));
855 mutex_unlock(&phydev->lock);
856 return; 845 return;
857 } 846 }
858 847
848 mutex_lock(&phydev->lock);
849
859 if (phy_interrupt_is_valid(phydev)) 850 if (phy_interrupt_is_valid(phydev))
860 phy_disable_interrupts(phydev); 851 phy_disable_interrupts(phydev);
861 852
@@ -994,8 +985,10 @@ void phy_state_machine(struct work_struct *work)
994 * state machine would be pointless and possibly error prone when 985 * state machine would be pointless and possibly error prone when
995 * called from phy_disconnect() synchronously. 986 * called from phy_disconnect() synchronously.
996 */ 987 */
988 mutex_lock(&phydev->lock);
997 if (phy_polling_mode(phydev) && phy_is_started(phydev)) 989 if (phy_polling_mode(phydev) && phy_is_started(phydev))
998 phy_queue_state_machine(phydev, PHY_STATE_TIME); 990 phy_queue_state_machine(phydev, PHY_STATE_TIME);
991 mutex_unlock(&phydev->lock);
999} 992}
1000 993
1001/** 994/**