aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/hw.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2009-07-14 20:17:15 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-24 15:05:19 -0400
commit709ade9eb8ef06e03526115408e2fc93a9feabbd (patch)
tree66c9d0b622483ee22e6bdd89435e644e742aa550 /drivers/net/wireless/ath/ath9k/hw.c
parent0bc0798b7605664c3ab8d577b398dc7ae0b2e58c (diff)
ath9k: serialize ath9k_ps_{wakeup,restore} calls
These functions are changing the power mode of the chip, but this may have unpredictable effects, if another code are trying to set the power mode via 'ath9k_hw_setpower' in the same time from another context. Changes-licensed-under: ISC Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hw.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index df278fd807b8..b9d1a13ba164 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -2777,23 +2777,39 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
2777 2777
2778void ath9k_ps_wakeup(struct ath_softc *sc) 2778void ath9k_ps_wakeup(struct ath_softc *sc)
2779{ 2779{
2780 if (atomic_inc_return(&sc->ps_usecount) == 1) 2780 unsigned long flags;
2781 if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE) { 2781
2782 sc->sc_ah->restore_mode = sc->sc_ah->power_mode; 2782 spin_lock_irqsave(&sc->sc_pm_lock, flags);
2783 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE); 2783 if (++sc->ps_usecount != 1)
2784 } 2784 goto unlock;
2785
2786 if (sc->sc_ah->power_mode != ATH9K_PM_AWAKE) {
2787 sc->sc_ah->restore_mode = sc->sc_ah->power_mode;
2788 ath9k_hw_setpower_nolock(sc->sc_ah, ATH9K_PM_AWAKE);
2789 }
2790
2791 unlock:
2792 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
2785} 2793}
2786 2794
2787void ath9k_ps_restore(struct ath_softc *sc) 2795void ath9k_ps_restore(struct ath_softc *sc)
2788{ 2796{
2789 if (atomic_dec_and_test(&sc->ps_usecount)) 2797 unsigned long flags;
2790 if ((sc->hw->conf.flags & IEEE80211_CONF_PS) && 2798
2791 !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON | 2799 spin_lock_irqsave(&sc->sc_pm_lock, flags);
2792 SC_OP_WAIT_FOR_CAB | 2800 if (--sc->ps_usecount != 0)
2793 SC_OP_WAIT_FOR_PSPOLL_DATA | 2801 goto unlock;
2794 SC_OP_WAIT_FOR_TX_ACK))) 2802
2795 ath9k_hw_setpower(sc->sc_ah, 2803 if ((sc->hw->conf.flags & IEEE80211_CONF_PS) &&
2796 sc->sc_ah->restore_mode); 2804 !(sc->sc_flags & (SC_OP_WAIT_FOR_BEACON |
2805 SC_OP_WAIT_FOR_CAB |
2806 SC_OP_WAIT_FOR_PSPOLL_DATA |
2807 SC_OP_WAIT_FOR_TX_ACK)))
2808 ath9k_hw_setpower_nolock(sc->sc_ah,
2809 sc->sc_ah->restore_mode);
2810
2811 unlock:
2812 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
2797} 2813}
2798 2814
2799/* 2815/*