ath9k: Fix channel context events
authorSujith Manoharan <c_manoha@qca.qualcomm.com>
Sat, 23 Aug 2014 07:59:16 +0000 (13:29 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 28 Aug 2014 18:49:37 +0000 (14:49 -0400)
Check if channel context usage is enabled before
calling ath_chanctx_event() from various parts of the
driver. Also, make sure that ath_chanctx_event() is
compiled only when CONFIG_ATH9K_CHANNEL_CONTEXT is
enabled.

Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/beacon.c
drivers/net/wireless/ath/ath9k/channel.c
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/recv.c
drivers/net/wireless/ath/ath9k/xmit.c

index 2afe790..5220f2f 100644 (file)
@@ -418,8 +418,6 @@ void ath_chanctx_init(struct ath_softc *sc);
 void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx,
                             struct cfg80211_chan_def *chandef);
 void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx);
-void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
-                      enum ath_chanctx_event ev);
 void ath_offchannel_next(struct ath_softc *sc);
 void ath_scan_complete(struct ath_softc *sc, bool abort);
 void ath_roc_complete(struct ath_softc *sc, bool abort);
@@ -438,6 +436,8 @@ void ath9k_p2p_bss_info_changed(struct ath_softc *sc,
                                struct ieee80211_vif *vif);
 void ath9k_p2p_ps_timer(void *priv);
 
+void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
+                      enum ath_chanctx_event ev);
 void ath_chanctx_set_next(struct ath_softc *sc, bool force);
 #else
 static inline bool ath9k_is_chanctx_enabled(void)
@@ -453,6 +453,11 @@ static inline void ath9k_init_channel_context(struct ath_softc *sc)
 static inline void ath9k_deinit_channel_context(struct ath_softc *sc)
 {
 }
+static inline void ath_chanctx_event(struct ath_softc *sc,
+                                    struct ieee80211_vif *vif,
+                                    enum ath_chanctx_event ev)
+{
+}
 static inline int ath9k_init_p2p(struct ath_softc *sc)
 {
        return 0;
index eaf8f05..68c95d4 100644 (file)
@@ -427,9 +427,11 @@ void ath9k_beacon_tasklet(unsigned long data)
 
        /* EDMA devices check that in the tx completion function. */
        if (!edma) {
-               if (sc->sched.beacon_pending)
-                       ath_chanctx_event(sc, NULL,
-                                         ATH_CHANCTX_EVENT_BEACON_SENT);
+               if (ath9k_is_chanctx_enabled()) {
+                       if (sc->sched.beacon_pending)
+                               ath_chanctx_event(sc, NULL,
+                                                 ATH_CHANCTX_EVENT_BEACON_SENT);
+               }
 
                if (ath9k_csa_is_finished(sc, vif))
                        return;
@@ -438,7 +440,10 @@ void ath9k_beacon_tasklet(unsigned long data)
        if (!vif || !vif->bss_conf.enable_beacon)
                return;
 
-       ath_chanctx_event(sc, vif, ATH_CHANCTX_EVENT_BEACON_PREPARE);
+       if (ath9k_is_chanctx_enabled()) {
+               ath_chanctx_event(sc, vif, ATH_CHANCTX_EVENT_BEACON_PREPARE);
+       }
+
        bf = ath9k_beacon_generate(sc->hw, vif);
 
        if (sc->beacon.bmisscnt != 0) {
index ceb3ce8..ae0b3f9 100644 (file)
@@ -139,7 +139,11 @@ void ath_chanctx_check_active(struct ath_softc *sc, struct ath_chanctx *ctx)
        }
        if (test_and_set_bit(ATH_OP_MULTI_CHANNEL, &common->op_flags))
                return;
-       ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL);
+
+       if (ath9k_is_chanctx_enabled()) {
+               ath_chanctx_event(sc, NULL,
+                                 ATH_CHANCTX_EVENT_ENABLE_MULTICHANNEL);
+       }
 }
 
 void ath_chanctx_init(struct ath_softc *sc)
@@ -190,6 +194,25 @@ void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx,
        ath_set_channel(sc);
 }
 
+#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
+
+static const char *offchannel_state_string(enum ath_offchannel_state state)
+{
+#define case_rtn_string(val) case val: return #val
+
+       switch (state) {
+               case_rtn_string(ATH_OFFCHANNEL_IDLE);
+               case_rtn_string(ATH_OFFCHANNEL_PROBE_SEND);
+               case_rtn_string(ATH_OFFCHANNEL_PROBE_WAIT);
+               case_rtn_string(ATH_OFFCHANNEL_SUSPEND);
+               case_rtn_string(ATH_OFFCHANNEL_ROC_START);
+               case_rtn_string(ATH_OFFCHANNEL_ROC_WAIT);
+               case_rtn_string(ATH_OFFCHANNEL_ROC_DONE);
+       default:
+               return "unknown";
+       }
+}
+
 static struct ath_chanctx *
 ath_chanctx_get_next(struct ath_softc *sc, struct ath_chanctx *ctx)
 {
@@ -440,25 +463,6 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
        spin_unlock_bh(&sc->chan_lock);
 }
 
-#ifdef CONFIG_ATH9K_CHANNEL_CONTEXT
-
-static const char *offchannel_state_string(enum ath_offchannel_state state)
-{
-#define case_rtn_string(val) case val: return #val
-
-       switch (state) {
-               case_rtn_string(ATH_OFFCHANNEL_IDLE);
-               case_rtn_string(ATH_OFFCHANNEL_PROBE_SEND);
-               case_rtn_string(ATH_OFFCHANNEL_PROBE_WAIT);
-               case_rtn_string(ATH_OFFCHANNEL_SUSPEND);
-               case_rtn_string(ATH_OFFCHANNEL_ROC_START);
-               case_rtn_string(ATH_OFFCHANNEL_ROC_WAIT);
-               case_rtn_string(ATH_OFFCHANNEL_ROC_DONE);
-       default:
-               return "unknown";
-       }
-}
-
 static int ath_scan_channel_duration(struct ath_softc *sc,
                                     struct ieee80211_channel *chan)
 {
index 4659168..30e0db2 100644 (file)
@@ -1684,8 +1684,12 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
                        bss_conf->bssid, bss_conf->assoc);
 
                ath9k_calculate_summary_state(sc, avp->chanctx);
-               if (bss_conf->assoc)
-                       ath_chanctx_event(sc, vif, ATH_CHANCTX_EVENT_ASSOC);
+
+               if (ath9k_is_chanctx_enabled()) {
+                       if (bss_conf->assoc)
+                               ath_chanctx_event(sc, vif,
+                                                 ATH_CHANCTX_EVENT_ASSOC);
+               }
        }
 
        if (changed & BSS_CHANGED_IBSS) {
index ae0d1e9..cc91749 100644 (file)
@@ -892,9 +892,12 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
                return -EINVAL;
        }
 
-       if (rx_stats->is_mybeacon) {
-               sc->sched.next_tbtt = rx_stats->rs_tstamp;
-               ath_chanctx_event(sc, NULL, ATH_CHANCTX_EVENT_BEACON_RECEIVED);
+       if (ath9k_is_chanctx_enabled()) {
+               if (rx_stats->is_mybeacon) {
+                       sc->sched.next_tbtt = rx_stats->rs_tstamp;
+                       ath_chanctx_event(sc, NULL,
+                                         ATH_CHANCTX_EVENT_BEACON_RECEIVED);
+               }
        }
 
        ath9k_cmn_process_rssi(common, hw, rx_stats, rx_status);
index 704fcbc..2819866 100644 (file)
@@ -2632,8 +2632,11 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
                        sc->beacon.tx_processed = true;
                        sc->beacon.tx_last = !(ts.ts_status & ATH9K_TXERR_MASK);
 
-                       ath_chanctx_event(sc, NULL,
-                                         ATH_CHANCTX_EVENT_BEACON_SENT);
+                       if (ath9k_is_chanctx_enabled()) {
+                               ath_chanctx_event(sc, NULL,
+                                                 ATH_CHANCTX_EVENT_BEACON_SENT);
+                       }
+
                        ath9k_csa_update(sc);
                        continue;
                }