iwlwifi: mvm: use helpers to get iwl_mvm_sta
authorSara Sharon <sara.sharon@intel.com>
Sun, 10 Apr 2016 12:51:54 +0000 (15:51 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Tue, 10 May 2016 19:34:04 +0000 (22:34 +0300)
Getting the mvm station out of station id requires dereferencing
the station id to get ieee80211_sta, then checking for pointer
validity and only then extract mvm station out.
Given that there are helpers to do it - use them instead of
duplicating the code whenever we need only mvm station.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/mvm/sta.c
drivers/net/wireless/intel/iwlwifi/mvm/tt.c
drivers/net/wireless/intel/iwlwifi/mvm/tx.c

index e3561bbc2468c71e6fa4c891bc36de367b419f0a..4fdc3dad3e85437492efc25df76b8ce8a02ad0ec 100644 (file)
@@ -1804,7 +1804,6 @@ static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
        struct iwl_wowlan_status *fw_status;
        int i;
        bool keep;
-       struct ieee80211_sta *ap_sta;
        struct iwl_mvm_sta *mvm_ap_sta;
 
        fw_status = iwl_mvm_get_wakeup_status(mvm, vif);
@@ -1823,13 +1822,10 @@ static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
        status.wake_packet = fw_status->wake_packet;
 
        /* still at hard-coded place 0 for D3 image */
-       ap_sta = rcu_dereference_protected(
-                       mvm->fw_id_to_mac_id[0],
-                       lockdep_is_held(&mvm->mutex));
-       if (IS_ERR_OR_NULL(ap_sta))
+       mvm_ap_sta = iwl_mvm_sta_from_staid_protected(mvm, 0);
+       if (!mvm_ap_sta)
                goto out_free;
 
-       mvm_ap_sta = iwl_mvm_sta_from_mac80211(ap_sta);
        for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
                u16 seq = status.qos_seq_ctr[i];
                /* firmware stores last-used value, we store next value */
index fb96bc00f022586f5198e2519fe0e7e16a938ef4..b23271755daf3bc2d2f9781701e85694b3d5b47c 100644 (file)
@@ -281,13 +281,10 @@ static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
 
        if (vif->type == NL80211_IFTYPE_STATION &&
            ap_sta_id != IWL_MVM_STATION_COUNT) {
-               struct ieee80211_sta *sta;
-
-               sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[ap_sta_id],
-                                               lockdep_is_held(&mvm->mutex));
-               if (!IS_ERR_OR_NULL(sta)) {
-                       struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta);
+               struct iwl_mvm_sta *mvm_sta;
 
+               mvm_sta = iwl_mvm_sta_from_staid_protected(mvm, ap_sta_id);
+               if (mvm_sta) {
                        pos += scnprintf(buf+pos, bufsz-pos,
                                         "ap_sta_id %d - reduced Tx power %d\n",
                                         ap_sta_id,
index 2ba13691b481db0219760b700d3e0d5f2a376e2d..6f91c5bdfd62ec7f03a557f36b8666db30dc4ba9 100644 (file)
@@ -1210,7 +1210,6 @@ static bool iwl_mvm_disallow_offloading(struct iwl_mvm *mvm,
                                        struct iwl_d0i3_iter_data *iter_data)
 {
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
-       struct ieee80211_sta *ap_sta;
        struct iwl_mvm_sta *mvmsta;
        u32 available_tids = 0;
        u8 tid;
@@ -1219,11 +1218,10 @@ static bool iwl_mvm_disallow_offloading(struct iwl_mvm *mvm,
                    mvmvif->ap_sta_id == IWL_MVM_STATION_COUNT))
                return false;
 
-       ap_sta = rcu_dereference(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id]);
-       if (IS_ERR_OR_NULL(ap_sta))
+       mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, mvmvif->ap_sta_id);
+       if (!mvmsta)
                return false;
 
-       mvmsta = iwl_mvm_sta_from_mac80211(ap_sta);
        spin_lock_bh(&mvmsta->lock);
        for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) {
                struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];
index e7f1da56d82dfd76e60f11c769977f61950ba459..855684ace0306246ffd85fca2f34e06ade00506f 100644 (file)
@@ -1756,17 +1756,12 @@ static struct iwl_mvm_sta *iwl_mvm_get_key_sta(struct iwl_mvm *mvm,
            mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {
                u8 sta_id = mvmvif->ap_sta_id;
 
-               sta = rcu_dereference_check(mvm->fw_id_to_mac_id[sta_id],
-                                           lockdep_is_held(&mvm->mutex));
                /*
                 * It is possible that the 'sta' parameter is NULL,
                 * for example when a GTK is removed - the sta_id will then
                 * be the AP ID, and no station was passed by mac80211.
                 */
-               if (IS_ERR_OR_NULL(sta))
-                       return NULL;
-
-               return iwl_mvm_sta_from_mac80211(sta);
+               return iwl_mvm_sta_from_staid_protected(mvm, sta_id);
        }
 
        return NULL;
index eb3f460ce1b6b6bdc80a1b9f540c2bdbb7e3bf8f..58fc7b3c711c735c04fedddb94691a70c9aeef70 100644 (file)
@@ -359,16 +359,14 @@ static void iwl_mvm_tt_smps_iterator(void *_data, u8 *mac,
 
 static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable)
 {
-       struct ieee80211_sta *sta;
        struct iwl_mvm_sta *mvmsta;
        int i, err;
 
        for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
-               sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
-                                               lockdep_is_held(&mvm->mutex));
-               if (IS_ERR_OR_NULL(sta))
+               mvmsta = iwl_mvm_sta_from_staid_protected(mvm, i);
+               if (!mvmsta)
                        continue;
-               mvmsta = iwl_mvm_sta_from_mac80211(sta);
+
                if (enable == mvmsta->tt_tx_protection)
                        continue;
                err = iwl_mvm_tx_protection(mvm, mvmsta, enable);
index 3b645683d233e85dc5e7e7a695f1b0063cdb84e6..ff615b92e4ef81b782b8f6be53fd89b462886fd0 100644 (file)
@@ -1464,7 +1464,7 @@ static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm,
        int sta_id = IWL_MVM_TX_RES_GET_RA(tx_resp->ra_tid);
        int tid = IWL_MVM_TX_RES_GET_TID(tx_resp->ra_tid);
        u16 sequence = le16_to_cpu(pkt->hdr.sequence);
-       struct ieee80211_sta *sta;
+       struct iwl_mvm_sta *mvmsta;
 
        if (WARN_ON_ONCE(SEQ_TO_QUEUE(sequence) < mvm->first_agg_queue))
                return;
@@ -1476,10 +1476,9 @@ static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm,
 
        rcu_read_lock();
 
-       sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
+       mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, sta_id);
 
-       if (!WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
-               struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
+       if (!WARN_ON_ONCE(!mvmsta)) {
                mvmsta->tid_data[tid].rate_n_flags =
                        le32_to_cpu(tx_resp->initial_rate);
                mvmsta->tid_data[tid].tx_time =