aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-09-14 15:24:24 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-09-16 16:45:41 -0400
commitc6c539f023423a7a730f5759be1b3b45c2d1d1ca (patch)
treeac2d4e4963b0b975e8881d2c22ed397fadeb488c
parent66ac69c8c3bd176b49c19e52c37449dec24c9588 (diff)
ath9k: optimize ath9k_ps_restore
ath_hw_cycle_counters_update only needs to be called if the power state changes. Most of the time this does not happen, even when ps_usecount goes down to 0. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 8149511e8f7e..7910165cf0e6 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -111,24 +111,29 @@ void ath9k_ps_wakeup(struct ath_softc *sc)
111void ath9k_ps_restore(struct ath_softc *sc) 111void ath9k_ps_restore(struct ath_softc *sc)
112{ 112{
113 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 113 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
114 enum ath9k_power_mode mode;
114 unsigned long flags; 115 unsigned long flags;
115 116
116 spin_lock_irqsave(&sc->sc_pm_lock, flags); 117 spin_lock_irqsave(&sc->sc_pm_lock, flags);
117 if (--sc->ps_usecount != 0) 118 if (--sc->ps_usecount != 0)
118 goto unlock; 119 goto unlock;
119 120
120 spin_lock(&common->cc_lock);
121 ath_hw_cycle_counters_update(common);
122 spin_unlock(&common->cc_lock);
123
124 if (sc->ps_idle) 121 if (sc->ps_idle)
125 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP); 122 mode = ATH9K_PM_FULL_SLEEP;
126 else if (sc->ps_enabled && 123 else if (sc->ps_enabled &&
127 !(sc->ps_flags & (PS_WAIT_FOR_BEACON | 124 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
128 PS_WAIT_FOR_CAB | 125 PS_WAIT_FOR_CAB |
129 PS_WAIT_FOR_PSPOLL_DATA | 126 PS_WAIT_FOR_PSPOLL_DATA |
130 PS_WAIT_FOR_TX_ACK))) 127 PS_WAIT_FOR_TX_ACK)))
131 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP); 128 mode = ATH9K_PM_NETWORK_SLEEP;
129 else
130 goto unlock;
131
132 spin_lock(&common->cc_lock);
133 ath_hw_cycle_counters_update(common);
134 spin_unlock(&common->cc_lock);
135
136 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_NETWORK_SLEEP);
132 137
133 unlock: 138 unlock:
134 spin_unlock_irqrestore(&sc->sc_pm_lock, flags); 139 spin_unlock_irqrestore(&sc->sc_pm_lock, flags);