diff options
| -rw-r--r-- | drivers/net/phy/phy.c | 11 | ||||
| -rw-r--r-- | include/linux/phy.h | 15 |
2 files changed, 6 insertions, 20 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index ca5e0c0f018c..602816d70281 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c | |||
| @@ -553,7 +553,7 @@ int phy_start_aneg(struct phy_device *phydev) | |||
| 553 | if (err < 0) | 553 | if (err < 0) |
| 554 | goto out_unlock; | 554 | goto out_unlock; |
| 555 | 555 | ||
| 556 | if (__phy_is_started(phydev)) { | 556 | if (phy_is_started(phydev)) { |
| 557 | if (phydev->autoneg == AUTONEG_ENABLE) { | 557 | if (phydev->autoneg == AUTONEG_ENABLE) { |
| 558 | err = phy_check_link_status(phydev); | 558 | err = phy_check_link_status(phydev); |
| 559 | } else { | 559 | } else { |
| @@ -709,7 +709,7 @@ void phy_stop_machine(struct phy_device *phydev) | |||
| 709 | cancel_delayed_work_sync(&phydev->state_queue); | 709 | cancel_delayed_work_sync(&phydev->state_queue); |
| 710 | 710 | ||
| 711 | mutex_lock(&phydev->lock); | 711 | mutex_lock(&phydev->lock); |
| 712 | if (__phy_is_started(phydev)) | 712 | if (phy_is_started(phydev)) |
| 713 | phydev->state = PHY_UP; | 713 | phydev->state = PHY_UP; |
| 714 | mutex_unlock(&phydev->lock); | 714 | mutex_unlock(&phydev->lock); |
| 715 | } | 715 | } |
| @@ -839,15 +839,14 @@ EXPORT_SYMBOL(phy_stop_interrupts); | |||
| 839 | */ | 839 | */ |
| 840 | void phy_stop(struct phy_device *phydev) | 840 | void phy_stop(struct phy_device *phydev) |
| 841 | { | 841 | { |
| 842 | mutex_lock(&phydev->lock); | 842 | if (!phy_is_started(phydev)) { |
| 843 | |||
| 844 | if (!__phy_is_started(phydev)) { | ||
| 845 | WARN(1, "called from state %s\n", | 843 | WARN(1, "called from state %s\n", |
| 846 | phy_state_to_str(phydev->state)); | 844 | phy_state_to_str(phydev->state)); |
| 847 | mutex_unlock(&phydev->lock); | ||
| 848 | return; | 845 | return; |
| 849 | } | 846 | } |
| 850 | 847 | ||
| 848 | mutex_lock(&phydev->lock); | ||
| 849 | |||
| 851 | if (phy_interrupt_is_valid(phydev)) | 850 | if (phy_interrupt_is_valid(phydev)) |
| 852 | phy_disable_interrupts(phydev); | 851 | phy_disable_interrupts(phydev); |
| 853 | 852 | ||
diff --git a/include/linux/phy.h b/include/linux/phy.h index ef20aeea10cc..127fcc9c3778 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h | |||
| @@ -674,26 +674,13 @@ phy_lookup_setting(int speed, int duplex, const unsigned long *mask, | |||
| 674 | size_t phy_speeds(unsigned int *speeds, size_t size, | 674 | size_t phy_speeds(unsigned int *speeds, size_t size, |
| 675 | unsigned long *mask); | 675 | unsigned long *mask); |
| 676 | 676 | ||
| 677 | static inline bool __phy_is_started(struct phy_device *phydev) | ||
| 678 | { | ||
| 679 | WARN_ON(!mutex_is_locked(&phydev->lock)); | ||
| 680 | |||
| 681 | return phydev->state >= PHY_UP; | ||
| 682 | } | ||
| 683 | |||
| 684 | /** | 677 | /** |
| 685 | * phy_is_started - Convenience function to check whether PHY is started | 678 | * phy_is_started - Convenience function to check whether PHY is started |
| 686 | * @phydev: The phy_device struct | 679 | * @phydev: The phy_device struct |
| 687 | */ | 680 | */ |
| 688 | static inline bool phy_is_started(struct phy_device *phydev) | 681 | static inline bool phy_is_started(struct phy_device *phydev) |
| 689 | { | 682 | { |
| 690 | bool started; | 683 | return phydev->state >= PHY_UP; |
| 691 | |||
| 692 | mutex_lock(&phydev->lock); | ||
| 693 | started = __phy_is_started(phydev); | ||
| 694 | mutex_unlock(&phydev->lock); | ||
| 695 | |||
| 696 | return started; | ||
| 697 | } | 684 | } |
| 698 | 685 | ||
| 699 | void phy_resolve_aneg_linkmode(struct phy_device *phydev); | 686 | void phy_resolve_aneg_linkmode(struct phy_device *phydev); |
