1 --- a/drivers/net/wireless/ath/ath9k/main.c
2 +++ b/drivers/net/wireless/ath/ath9k/main.c
3 @@ -124,14 +124,14 @@ void ath9k_ps_restore(struct ath_softc *
4 !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
6 PS_WAIT_FOR_PSPOLL_DATA |
7 - PS_WAIT_FOR_TX_ACK)))
8 + PS_WAIT_FOR_TX_ACK))) {
9 mode = ATH9K_PM_NETWORK_SLEEP;
13 - spin_lock(&common->cc_lock);
14 - ath_hw_cycle_counters_update(common);
15 - spin_unlock(&common->cc_lock);
16 + spin_lock(&common->cc_lock);
17 + ath_hw_cycle_counters_update(common);
18 + spin_unlock(&common->cc_lock);
22 ath9k_hw_setpower(sc->sc_ah, mode);
24 @@ -880,82 +880,6 @@ chip_reset:
28 -static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
30 - struct ath_hw *ah = sc->sc_ah;
31 - struct ath_common *common = ath9k_hw_common(ah);
32 - struct ieee80211_channel *channel = hw->conf.channel;
35 - ath9k_ps_wakeup(sc);
36 - spin_lock_bh(&sc->sc_pcu_lock);
37 - atomic_set(&ah->intr_ref_cnt, -1);
39 - ath9k_hw_configpcipowersave(ah, false);
42 - ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah);
44 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
47 - "Unable to reset channel (%u MHz), reset status %d\n",
48 - channel->center_freq, r);
51 - ath_complete_reset(sc, true);
54 - ath9k_hw_cfg_output(ah, ah->led_pin,
55 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
56 - ath9k_hw_set_gpio(ah, ah->led_pin, 0);
58 - spin_unlock_bh(&sc->sc_pcu_lock);
60 - ath9k_ps_restore(sc);
63 -void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
65 - struct ath_hw *ah = sc->sc_ah;
66 - struct ieee80211_channel *channel = hw->conf.channel;
69 - ath9k_ps_wakeup(sc);
71 - ath_cancel_work(sc);
73 - spin_lock_bh(&sc->sc_pcu_lock);
76 - * Keep the LED on when the radio is disabled
77 - * during idle unassociated state.
80 - ath9k_hw_set_gpio(ah, ah->led_pin, 1);
81 - ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
84 - ath_prepare_reset(sc, false, true);
87 - ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
89 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
91 - ath_err(ath9k_hw_common(sc->sc_ah),
92 - "Unable to reset channel (%u MHz), reset status %d\n",
93 - channel->center_freq, r);
96 - ath9k_hw_phy_disable(ah);
98 - ath9k_hw_configpcipowersave(ah, true);
100 - spin_unlock_bh(&sc->sc_pcu_lock);
101 - ath9k_ps_restore(sc);
104 static int ath_reset(struct ath_softc *sc, bool retry_tx)
107 @@ -1091,6 +1015,9 @@ static int ath9k_start(struct ieee80211_
108 * and then setup of the interrupt mask.
110 spin_lock_bh(&sc->sc_pcu_lock);
112 + atomic_set(&ah->intr_ref_cnt, -1);
114 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
117 @@ -1129,6 +1056,16 @@ static int ath9k_start(struct ieee80211_
121 + ath9k_hw_cfg_output(ah, ah->led_pin,
122 + AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
123 + ath9k_hw_set_gpio(ah, ah->led_pin, 0);
126 + * Reset key cache to sane defaults (all entries cleared) instead of
127 + * semi-random values after suspend/resume.
129 + ath9k_cmn_init_crypto(sc->sc_ah);
131 spin_unlock_bh(&sc->sc_pcu_lock);
133 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
134 @@ -1260,9 +1197,6 @@ static void ath9k_stop(struct ieee80211_
138 - /* disable HAL and put h/w to sleep */
139 - ath9k_hw_disable(ah);
141 spin_unlock_bh(&sc->sc_pcu_lock);
143 /* we can now sync irq and kill any running tasklets, since we already
144 @@ -1271,10 +1205,27 @@ static void ath9k_stop(struct ieee80211_
145 tasklet_kill(&sc->intr_tq);
146 tasklet_kill(&sc->bcon_tasklet);
148 - ath9k_ps_restore(sc);
151 - ath_radio_disable(sc, hw);
153 + spin_lock_bh(&sc->sc_pcu_lock);
155 + ath9k_hw_set_gpio(ah, ah->led_pin, 1);
156 + ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
158 + ath_prepare_reset(sc, false, true);
161 + ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
163 + ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
164 + ath9k_hw_phy_disable(ah);
165 + ath9k_hw_disable(ah);
167 + ath9k_hw_configpcipowersave(ah, true);
169 + spin_unlock_bh(&sc->sc_pcu_lock);
171 + ath9k_ps_restore(sc);
173 sc->sc_flags |= SC_OP_INVALID;
175 @@ -1598,8 +1549,8 @@ static int ath9k_config(struct ieee80211
176 struct ath_hw *ah = sc->sc_ah;
177 struct ath_common *common = ath9k_hw_common(ah);
178 struct ieee80211_conf *conf = &hw->conf;
179 - bool disable_radio = false;
181 + ath9k_ps_wakeup(sc);
182 mutex_lock(&sc->mutex);
185 @@ -1608,16 +1559,8 @@ static int ath9k_config(struct ieee80211
186 * of the changes. Likewise we must only disable the radio towards
189 - if (changed & IEEE80211_CONF_CHANGE_IDLE) {
190 + if (changed & IEEE80211_CONF_CHANGE_IDLE)
191 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
192 - if (!sc->ps_idle) {
193 - ath_radio_enable(sc, hw);
194 - ath_dbg(common, ATH_DBG_CONFIG,
195 - "not-idle: enabling radio\n");
197 - disable_radio = true;
202 * We just prepare to enable PS. We have to wait until our AP has
203 @@ -1742,19 +1685,13 @@ static int ath9k_config(struct ieee80211
204 ath_dbg(common, ATH_DBG_CONFIG,
205 "Set power: %d\n", conf->power_level);
206 sc->config.txpowlimit = 2 * conf->power_level;
207 - ath9k_ps_wakeup(sc);
208 ath9k_cmn_update_txpow(ah, sc->curtxpow,
209 sc->config.txpowlimit, &sc->curtxpow);
210 - ath9k_ps_restore(sc);
211 conf->cur_power_level = sc->curtxpow / 2;
214 - if (disable_radio) {
215 - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
216 - ath_radio_disable(sc, hw);
219 mutex_unlock(&sc->mutex);
220 + ath9k_ps_restore(sc);
224 --- a/drivers/net/wireless/ath/ath9k/pci.c
225 +++ b/drivers/net/wireless/ath/ath9k/pci.c
226 @@ -302,26 +302,12 @@ static void ath_pci_remove(struct pci_de
228 static int ath_pci_suspend(struct device *device)
230 - struct pci_dev *pdev = to_pci_dev(device);
231 - struct ieee80211_hw *hw = pci_get_drvdata(pdev);
232 - struct ath_softc *sc = hw->priv;
234 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
236 - /* The device has to be moved to FULLSLEEP forcibly.
237 - * Otherwise the chip never moved to full sleep,
238 - * when no interface is up.
240 - ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
245 static int ath_pci_resume(struct device *device)
247 struct pci_dev *pdev = to_pci_dev(device);
248 - struct ieee80211_hw *hw = pci_get_drvdata(pdev);
249 - struct ath_softc *sc = hw->priv;
253 @@ -333,22 +319,6 @@ static int ath_pci_resume(struct device
254 if ((val & 0x0000ff00) != 0)
255 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
257 - ath9k_ps_wakeup(sc);
259 - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
260 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
261 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
264 - * Reset key cache to sane defaults (all entries cleared) instead of
265 - * semi-random values after suspend/resume.
267 - ath9k_cmn_init_crypto(sc->sc_ah);
268 - ath9k_ps_restore(sc);
270 - sc->ps_idle = true;
271 - ath_radio_disable(sc, hw);