1 --- a/drivers/net/wireless/ath/ath9k/main.c
2 +++ b/drivers/net/wireless/ath/ath9k/main.c
3 @@ -880,82 +880,6 @@ chip_reset:
7 -static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
9 - struct ath_hw *ah = sc->sc_ah;
10 - struct ath_common *common = ath9k_hw_common(ah);
11 - struct ieee80211_channel *channel = hw->conf.channel;
14 - ath9k_ps_wakeup(sc);
15 - spin_lock_bh(&sc->sc_pcu_lock);
16 - atomic_set(&ah->intr_ref_cnt, -1);
18 - ath9k_hw_configpcipowersave(ah, false);
21 - ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah);
23 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
26 - "Unable to reset channel (%u MHz), reset status %d\n",
27 - channel->center_freq, r);
30 - ath_complete_reset(sc, true);
33 - ath9k_hw_cfg_output(ah, ah->led_pin,
34 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
35 - ath9k_hw_set_gpio(ah, ah->led_pin, 0);
37 - spin_unlock_bh(&sc->sc_pcu_lock);
39 - ath9k_ps_restore(sc);
42 -void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
44 - struct ath_hw *ah = sc->sc_ah;
45 - struct ieee80211_channel *channel = hw->conf.channel;
48 - ath9k_ps_wakeup(sc);
50 - ath_cancel_work(sc);
52 - spin_lock_bh(&sc->sc_pcu_lock);
55 - * Keep the LED on when the radio is disabled
56 - * during idle unassociated state.
59 - ath9k_hw_set_gpio(ah, ah->led_pin, 1);
60 - ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
63 - ath_prepare_reset(sc, false, true);
66 - ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
68 - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
70 - ath_err(ath9k_hw_common(sc->sc_ah),
71 - "Unable to reset channel (%u MHz), reset status %d\n",
72 - channel->center_freq, r);
75 - ath9k_hw_phy_disable(ah);
77 - ath9k_hw_configpcipowersave(ah, true);
79 - spin_unlock_bh(&sc->sc_pcu_lock);
80 - ath9k_ps_restore(sc);
83 static int ath_reset(struct ath_softc *sc, bool retry_tx)
86 @@ -1091,6 +1015,9 @@ static int ath9k_start(struct ieee80211_
87 * and then setup of the interrupt mask.
89 spin_lock_bh(&sc->sc_pcu_lock);
91 + atomic_set(&ah->intr_ref_cnt, -1);
93 r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
96 @@ -1129,6 +1056,16 @@ static int ath9k_start(struct ieee80211_
100 + ath9k_hw_cfg_output(ah, ah->led_pin,
101 + AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
102 + ath9k_hw_set_gpio(ah, ah->led_pin, 0);
105 + * Reset key cache to sane defaults (all entries cleared) instead of
106 + * semi-random values after suspend/resume.
108 + ath9k_cmn_init_crypto(sc->sc_ah);
110 spin_unlock_bh(&sc->sc_pcu_lock);
112 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
113 @@ -1248,33 +1185,39 @@ static void ath9k_stop(struct ieee80211_
114 * before setting the invalid flag. */
115 ath9k_hw_disable_interrupts(ah);
117 - if (!(sc->sc_flags & SC_OP_INVALID)) {
118 - ath_drain_all_txq(sc, false);
120 - ath9k_hw_phy_disable(ah);
122 - sc->rx.rxlink = NULL;
123 + spin_unlock_bh(&sc->sc_pcu_lock);
125 + /* we can now sync irq and kill any running tasklets, since we already
126 + * disabled interrupts and not holding a spin lock */
127 + synchronize_irq(sc->irq);
128 + tasklet_kill(&sc->intr_tq);
129 + tasklet_kill(&sc->bcon_tasklet);
131 + sc->ps_idle = true;
133 + spin_lock_bh(&sc->sc_pcu_lock);
135 + ath9k_hw_set_gpio(ah, ah->led_pin, 1);
136 + ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
138 + ath_prepare_reset(sc, false, true);
141 dev_kfree_skb_any(sc->rx.frag);
145 - /* disable HAL and put h/w to sleep */
146 - ath9k_hw_disable(ah);
148 + ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
150 - spin_unlock_bh(&sc->sc_pcu_lock);
151 + ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
152 + ath9k_hw_phy_disable(ah);
154 - /* we can now sync irq and kill any running tasklets, since we already
155 - * disabled interrupts and not holding a spin lock */
156 - synchronize_irq(sc->irq);
157 - tasklet_kill(&sc->intr_tq);
158 - tasklet_kill(&sc->bcon_tasklet);
159 + ath9k_hw_configpcipowersave(ah, true);
161 - ath9k_ps_restore(sc);
162 + spin_unlock_bh(&sc->sc_pcu_lock);
164 - sc->ps_idle = true;
165 - ath_radio_disable(sc, hw);
166 + ath9k_ps_restore(sc);
168 sc->sc_flags |= SC_OP_INVALID;
170 @@ -1598,8 +1541,8 @@ static int ath9k_config(struct ieee80211
171 struct ath_hw *ah = sc->sc_ah;
172 struct ath_common *common = ath9k_hw_common(ah);
173 struct ieee80211_conf *conf = &hw->conf;
174 - bool disable_radio = false;
176 + ath9k_ps_wakeup(sc);
177 mutex_lock(&sc->mutex);
180 @@ -1608,16 +1551,8 @@ static int ath9k_config(struct ieee80211
181 * of the changes. Likewise we must only disable the radio towards
184 - if (changed & IEEE80211_CONF_CHANGE_IDLE) {
185 + if (changed & IEEE80211_CONF_CHANGE_IDLE)
186 sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
187 - if (!sc->ps_idle) {
188 - ath_radio_enable(sc, hw);
189 - ath_dbg(common, ATH_DBG_CONFIG,
190 - "not-idle: enabling radio\n");
192 - disable_radio = true;
197 * We just prepare to enable PS. We have to wait until our AP has
198 @@ -1742,19 +1677,13 @@ static int ath9k_config(struct ieee80211
199 ath_dbg(common, ATH_DBG_CONFIG,
200 "Set power: %d\n", conf->power_level);
201 sc->config.txpowlimit = 2 * conf->power_level;
202 - ath9k_ps_wakeup(sc);
203 ath9k_cmn_update_txpow(ah, sc->curtxpow,
204 sc->config.txpowlimit, &sc->curtxpow);
205 - ath9k_ps_restore(sc);
206 conf->cur_power_level = sc->curtxpow / 2;
209 - if (disable_radio) {
210 - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n");
211 - ath_radio_disable(sc, hw);
214 mutex_unlock(&sc->mutex);
215 + ath9k_ps_restore(sc);
219 --- a/drivers/net/wireless/ath/ath9k/pci.c
220 +++ b/drivers/net/wireless/ath/ath9k/pci.c
221 @@ -306,12 +306,11 @@ static int ath_pci_suspend(struct device
222 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
223 struct ath_softc *sc = hw->priv;
225 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1);
227 /* The device has to be moved to FULLSLEEP forcibly.
228 * Otherwise the chip never moved to full sleep,
229 * when no interface is up.
231 + ath9k_hw_disable(sc->sc_ah);
232 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
235 @@ -333,22 +332,6 @@ static int ath_pci_resume(struct device
236 if ((val & 0x0000ff00) != 0)
237 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
239 - ath9k_ps_wakeup(sc);
241 - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin,
242 - AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
243 - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0);
246 - * Reset key cache to sane defaults (all entries cleared) instead of
247 - * semi-random values after suspend/resume.
249 - ath9k_cmn_init_crypto(sc->sc_ah);
250 - ath9k_ps_restore(sc);
252 - sc->ps_idle = true;
253 - ath_radio_disable(sc, hw);