Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless
[deliverable/linux.git] / drivers / net / wireless / ath / ath9k / main.c
index 34d6f26c6bc74d474c682a3521af78068a5f5606..52561b341d68798e55bbe8237e589da274b539b7 100644 (file)
@@ -150,6 +150,9 @@ static void __ath_cancel_work(struct ath_softc *sc)
        cancel_work_sync(&sc->hw_check_work);
        cancel_delayed_work_sync(&sc->tx_complete_work);
        cancel_delayed_work_sync(&sc->hw_pll_work);
+#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
+       cancel_work_sync(&sc->mci_work);
+#endif
 }
 
 static void ath_cancel_work(struct ath_softc *sc)
@@ -210,6 +213,7 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
 {
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
+       unsigned long flags;
 
        if (ath_startrecv(sc) != 0) {
                ath_err(common, "Unable to restart recv logic\n");
@@ -224,9 +228,18 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start)
        ath9k_hw_enable_interrupts(ah);
 
        if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) && start) {
-               if (test_bit(SC_OP_BEACONS, &sc->sc_flags))
-                       ath_set_beacon(sc);
+               if (!test_bit(SC_OP_BEACONS, &sc->sc_flags))
+                       goto work;
+
+               ath_set_beacon(sc);
 
+               if (ah->opmode == NL80211_IFTYPE_STATION &&
+                   test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
+                       spin_lock_irqsave(&sc->sc_pm_lock, flags);
+                       sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
+                       spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
+               }
+       work:
                ath_restart_work(sc);
        }
 
@@ -345,7 +358,7 @@ void ath9k_tasklet(unsigned long data)
        struct ath_softc *sc = (struct ath_softc *)data;
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
-
+       unsigned long flags;
        u32 status = sc->intrstatus;
        u32 rxmask;
 
@@ -369,6 +382,7 @@ void ath9k_tasklet(unsigned long data)
                goto out;
        }
 
+       spin_lock_irqsave(&sc->sc_pm_lock, flags);
        if ((status & ATH9K_INT_TSFOOR) && sc->ps_enabled) {
                /*
                 * TSF sync does not look correct; remain awake to sync with
@@ -377,6 +391,7 @@ void ath9k_tasklet(unsigned long data)
                ath_dbg(common, PS, "TSFOOR - Sync with next Beacon\n");
                sc->ps_flags |= PS_WAIT_FOR_BEACON | PS_BEACON_SYNC;
        }
+       spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
 
        if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
                rxmask = (ATH9K_INT_RXHP | ATH9K_INT_RXLP | ATH9K_INT_RXEOL |
@@ -526,8 +541,10 @@ irqreturn_t ath_isr(int irq, void *dev)
                        /* Clear RxAbort bit so that we can
                         * receive frames */
                        ath9k_setpower(sc, ATH9K_PM_AWAKE);
+                       spin_lock(&sc->sc_pm_lock);
                        ath9k_hw_setrxabort(sc->sc_ah, 0);
                        sc->ps_flags |= PS_WAIT_FOR_BEACON;
+                       spin_unlock(&sc->sc_pm_lock);
                }
 
 chip_reset:
@@ -682,6 +699,7 @@ static void ath9k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        struct ath_tx_control txctl;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
+       unsigned long flags;
 
        if (sc->ps_enabled) {
                /*
@@ -704,6 +722,7 @@ static void ath9k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
                 * completed and if needed, also for RX of buffered frames.
                 */
                ath9k_ps_wakeup(sc);
+               spin_lock_irqsave(&sc->sc_pm_lock, flags);
                if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
                        ath9k_hw_setrxabort(sc->sc_ah, 0);
                if (ieee80211_is_pspoll(hdr->frame_control)) {
@@ -719,6 +738,7 @@ static void ath9k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
                 * the ps_flags bit is cleared. We are just dropping
                 * the ps_usecount here.
                 */
+               spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
                ath9k_ps_restore(sc);
        }
 
@@ -1016,15 +1036,6 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
                }
        }
 
-       if ((ah->opmode == NL80211_IFTYPE_ADHOC) ||
-           ((vif->type == NL80211_IFTYPE_ADHOC) &&
-            sc->nvifs > 0)) {
-               ath_err(common, "Cannot create ADHOC interface when other"
-                       " interfaces already exist.\n");
-               ret = -EINVAL;
-               goto out;
-       }
-
        ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
 
        sc->nvifs++;
@@ -1049,15 +1060,6 @@ static int ath9k_change_interface(struct ieee80211_hw *hw,
        mutex_lock(&sc->mutex);
        ath9k_ps_wakeup(sc);
 
-       /* See if new interface type is valid. */
-       if ((new_type == NL80211_IFTYPE_ADHOC) &&
-           (sc->nvifs > 1)) {
-               ath_err(common, "When using ADHOC, it must be the only"
-                       " interface.\n");
-               ret = -EINVAL;
-               goto out;
-       }
-
        if (ath9k_uses_beacons(new_type) &&
            !ath9k_uses_beacons(vif->type)) {
                if (sc->nbcnvifs >= ATH_BCBUF) {
@@ -1241,6 +1243,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
                if (ath_set_channel(sc, hw, &sc->sc_ah->channels[pos]) < 0) {
                        ath_err(common, "Unable to set channel\n");
                        mutex_unlock(&sc->mutex);
+                       ath9k_ps_restore(sc);
                        return -EINVAL;
                }
 
@@ -1479,7 +1482,7 @@ static void ath9k_bss_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
        struct ath_common *common = ath9k_hw_common(sc->sc_ah);
        struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
        struct ath_vif *avp = (void *)vif->drv_priv;
-
+       unsigned long flags;
        /*
         * Skip iteration if primary station vif's bss info
         * was not changed
@@ -1501,7 +1504,10 @@ static void ath9k_bss_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
                 * on the receipt of the first Beacon frame (i.e.,
                 * after time sync with the AP).
                 */
+               spin_lock_irqsave(&sc->sc_pm_lock, flags);
                sc->ps_flags |= PS_BEACON_SYNC | PS_WAIT_FOR_BEACON;
+               spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
+
                /* Reset rssi stats */
                sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
                sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
This page took 0.033345 seconds and 5 git commands to generate.