ath9k: move ath9k_process_rssi to common.c
authorOleksij Rempel <linux@rempel-privat.de>
Tue, 4 Feb 2014 09:27:39 +0000 (10:27 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 12 Feb 2014 20:35:56 +0000 (15:35 -0500)
we can reuse this fucntion on ath9k_htc.
Now we will need to use common version last_rssi, so switch
it too.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/common.c
drivers/net/wireless/ath/ath9k/common.h
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/recv.c

index 7fde8ecb6ea19894e3fb6f17ace23084bfc4b291..ff3747c2fc0830db2f726964e961750c7db8c1de 100644 (file)
@@ -758,7 +758,6 @@ struct ath_softc {
 #endif
 
        struct ath9k_hw_cal_data caldata;
-       int last_rssi;
 
 #ifdef CONFIG_ATH9K_DEBUGFS
        struct ath9k_debug debug;
index 768c733cad31d4ef7ae1c45bd17c2e207f2ca82f..7028c52fe32e1537b48e2f4ed2000fb7b90da4f6 100644 (file)
@@ -27,6 +27,68 @@ MODULE_AUTHOR("Atheros Communications");
 MODULE_DESCRIPTION("Shared library for Atheros wireless 802.11n LAN cards.");
 MODULE_LICENSE("Dual BSD/GPL");
 
+void ath9k_cmn_process_rssi(struct ath_common *common,
+                           struct ieee80211_hw *hw,
+                           struct ath_rx_status *rx_stats,
+                           struct ieee80211_rx_status *rxs)
+{
+       struct ath_hw *ah = common->ah;
+       int last_rssi;
+       int rssi = rx_stats->rs_rssi;
+       int i, j;
+
+       /*
+        * RSSI is not available for subframes in an A-MPDU.
+        */
+       if (rx_stats->rs_moreaggr) {
+               rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
+               return;
+       }
+
+       /*
+        * Check if the RSSI for the last subframe in an A-MPDU
+        * or an unaggregated frame is valid.
+        */
+       if (rx_stats->rs_rssi == ATH9K_RSSI_BAD) {
+               rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
+               return;
+       }
+
+       for (i = 0, j = 0; i < ARRAY_SIZE(rx_stats->rs_rssi_ctl); i++) {
+               s8 rssi;
+
+               if (!(ah->rxchainmask & BIT(i)))
+                       continue;
+
+               rssi = rx_stats->rs_rssi_ctl[i];
+               if (rssi != ATH9K_RSSI_BAD) {
+                   rxs->chains |= BIT(j);
+                   rxs->chain_signal[j] = ah->noise + rssi;
+               }
+               j++;
+       }
+
+       /*
+        * Update Beacon RSSI, this is used by ANI.
+        */
+       if (rx_stats->is_mybeacon &&
+           ((ah->opmode == NL80211_IFTYPE_STATION) ||
+            (ah->opmode == NL80211_IFTYPE_ADHOC))) {
+               ATH_RSSI_LPF(common->last_rssi, rx_stats->rs_rssi);
+               last_rssi = common->last_rssi;
+
+               if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
+                       rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
+               if (rssi < 0)
+                       rssi = 0;
+
+               ah->stats.avgbrssi = rssi;
+       }
+
+       rxs->signal = ah->noise + rx_stats->rs_rssi;
+}
+EXPORT_SYMBOL(ath9k_cmn_process_rssi);
+
 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb)
 {
        struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
index eb85e1bdca889a4e43b46261be31e691ff403363..aaf4a9b5ad99fe7990c297ec6befe053c2a2bfd1 100644 (file)
 #define ATH_EP_RND(x, mul)                                             \
        (((x) + ((mul)/2)) / (mul))
 
+void ath9k_cmn_process_rssi(struct ath_common *common,
+                           struct ieee80211_hw *hw,
+                           struct ath_rx_status *rx_stats,
+                           struct ieee80211_rx_status *rxs);
 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
 struct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw,
                                            struct ath_hw *ah,
index c36de303c8f38d9545ecdb74b575e176ec1b1d25..00e0f606a0d30ecb431c77d9653ec0ac9a402e01 100644 (file)
@@ -534,7 +534,7 @@ static void ath9k_init_misc(struct ath_softc *sc)
 
        setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc);
 
-       sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
+       common->last_rssi = ATH_RSSI_DUMMY_MARKER;
        sc->config.txpowlimit = ATH_TXPOWER_MAX;
        memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN);
        sc->beacon.slottime = ATH9K_SLOT_TIME_9;
index 4486e37639196ee5834b96fecd7a248b434d481e..afce549a097bc4b7ec3ebd87fecb490e82a85bed 100644 (file)
@@ -1606,7 +1606,7 @@ static void ath9k_set_assoc_state(struct ath_softc *sc,
        common->curaid = bss_conf->aid;
        ath9k_hw_write_associd(sc->sc_ah);
 
-       sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
+       common->last_rssi = ATH_RSSI_DUMMY_MARKER;
        sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
 
        spin_lock_irqsave(&sc->sc_pm_lock, flags);
index a0ebdd000fc20f83dac90401ba017dd1ebf3b570..5229e63ffbbd9615395161421c7fc10d8e219475 100644 (file)
@@ -891,68 +891,6 @@ static int ath9k_process_rate(struct ath_common *common,
        return -EINVAL;
 }
 
-static void ath9k_process_rssi(struct ath_common *common,
-                              struct ieee80211_hw *hw,
-                              struct ath_rx_status *rx_stats,
-                              struct ieee80211_rx_status *rxs)
-{
-       struct ath_softc *sc = hw->priv;
-       struct ath_hw *ah = common->ah;
-       int last_rssi;
-       int rssi = rx_stats->rs_rssi;
-       int i, j;
-
-       /*
-        * RSSI is not available for subframes in an A-MPDU.
-        */
-       if (rx_stats->rs_moreaggr) {
-               rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
-               return;
-       }
-
-       /*
-        * Check if the RSSI for the last subframe in an A-MPDU
-        * or an unaggregated frame is valid.
-        */
-       if (rx_stats->rs_rssi == ATH9K_RSSI_BAD) {
-               rxs->flag |= RX_FLAG_NO_SIGNAL_VAL;
-               return;
-       }
-
-       for (i = 0, j = 0; i < ARRAY_SIZE(rx_stats->rs_rssi_ctl); i++) {
-               s8 rssi;
-
-               if (!(ah->rxchainmask & BIT(i)))
-                       continue;
-
-               rssi = rx_stats->rs_rssi_ctl[i];
-               if (rssi != ATH9K_RSSI_BAD) {
-                   rxs->chains |= BIT(j);
-                   rxs->chain_signal[j] = ah->noise + rssi;
-               }
-               j++;
-       }
-
-       /*
-        * Update Beacon RSSI, this is used by ANI.
-        */
-       if (rx_stats->is_mybeacon &&
-           ((ah->opmode == NL80211_IFTYPE_STATION) ||
-            (ah->opmode == NL80211_IFTYPE_ADHOC))) {
-               ATH_RSSI_LPF(sc->last_rssi, rx_stats->rs_rssi);
-               last_rssi = sc->last_rssi;
-
-               if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
-                       rssi = ATH_EP_RND(last_rssi, ATH_RSSI_EP_MULTIPLIER);
-               if (rssi < 0)
-                       rssi = 0;
-
-               ah->stats.avgbrssi = rssi;
-       }
-
-       rxs->signal = ah->noise + rx_stats->rs_rssi;
-}
-
 static void ath9k_process_tsf(struct ath_rx_status *rs,
                              struct ieee80211_rx_status *rxs,
                              u64 tsf)
@@ -1074,7 +1012,7 @@ static int ath9k_rx_skb_preprocess(struct ath_softc *sc,
                goto exit;
        }
 
-       ath9k_process_rssi(common, hw, rx_stats, rx_status);
+       ath9k_cmn_process_rssi(common, hw, rx_stats, rx_status);
 
        rx_status->band = ah->curchan->chan->band;
        rx_status->freq = ah->curchan->chan->center_freq;