aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2014-01-14 01:30:32 -0500
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>2014-02-03 15:23:33 -0500
commitf327b04c4240cc6dbce698bea8f8e14db7fc3a8a (patch)
tree40bf61d0c1d6221c92ff732243dfd5fd1690e140 /drivers/net/wireless
parent33b2f6845b0c86ade2146ec9f259b857ecebeffc (diff)
iwlwifi: mvm: provide helper to fetch the iwl_mvm_sta from sta_id
We somtimes need to fetch the iwl_mvm_sta structure from a station index - provide a helper to do that. Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/bt-coex.c14
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/debugfs.c11
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mvm.h18
3 files changed, 25 insertions, 18 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/bt-coex.c b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c
index 76cde6ce6551..b1a572e52f46 100644
--- a/drivers/net/wireless/iwlwifi/mvm/bt-coex.c
+++ b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c
@@ -500,23 +500,13 @@ static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id,
500 .dataflags = { IWL_HCMD_DFL_DUP, }, 500 .dataflags = { IWL_HCMD_DFL_DUP, },
501 .flags = CMD_ASYNC, 501 .flags = CMD_ASYNC,
502 }; 502 };
503
504 struct ieee80211_sta *sta;
505 struct iwl_mvm_sta *mvmsta; 503 struct iwl_mvm_sta *mvmsta;
506 int ret; 504 int ret;
507 505
508 if (sta_id == IWL_MVM_STATION_COUNT) 506 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
509 return 0; 507 if (!mvmsta)
510
511 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
512 lockdep_is_held(&mvm->mutex));
513
514 /* This can happen if the station has been removed right now */
515 if (IS_ERR_OR_NULL(sta))
516 return 0; 508 return 0;
517 509
518 mvmsta = iwl_mvm_sta_from_mac80211(sta);
519
520 /* nothing to do */ 510 /* nothing to do */
521 if (mvmsta->bt_reduced_txpower == enable) 511 if (mvmsta->bt_reduced_txpower == enable)
522 return 0; 512 return 0;
diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
index 369d4c90e669..8d3bf25f00d6 100644
--- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
@@ -90,7 +90,7 @@ static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
90static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf, 90static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
91 size_t count, loff_t *ppos) 91 size_t count, loff_t *ppos)
92{ 92{
93 struct ieee80211_sta *sta; 93 struct iwl_mvm_sta *mvmsta;
94 int sta_id, drain, ret; 94 int sta_id, drain, ret;
95 95
96 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) 96 if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
@@ -105,13 +105,12 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
105 105
106 mutex_lock(&mvm->mutex); 106 mutex_lock(&mvm->mutex);
107 107
108 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], 108 mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
109 lockdep_is_held(&mvm->mutex)); 109
110 if (IS_ERR_OR_NULL(sta)) 110 if (!mvmsta)
111 ret = -ENOENT; 111 ret = -ENOENT;
112 else 112 else
113 ret = iwl_mvm_drain_sta(mvm, (void *)sta->drv_priv, drain) ? : 113 ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
114 count;
115 114
116 mutex_unlock(&mvm->mutex); 115 mutex_unlock(&mvm->mutex);
117 116
diff --git a/drivers/net/wireless/iwlwifi/mvm/mvm.h b/drivers/net/wireless/iwlwifi/mvm/mvm.h
index bf13c462a1f4..02e4bdc80de2 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mvm.h
+++ b/drivers/net/wireless/iwlwifi/mvm/mvm.h
@@ -595,6 +595,24 @@ static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
595 test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); 595 test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
596} 596}
597 597
598static inline struct iwl_mvm_sta *
599iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
600{
601 struct ieee80211_sta *sta;
602
603 if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
604 return NULL;
605
606 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
607 lockdep_is_held(&mvm->mutex));
608
609 /* This can happen if the station has been removed right now */
610 if (IS_ERR_OR_NULL(sta))
611 return NULL;
612
613 return iwl_mvm_sta_from_mac80211(sta);
614}
615
598extern const u8 iwl_mvm_ac_to_tx_fifo[]; 616extern const u8 iwl_mvm_ac_to_tx_fifo[];
599 617
600struct iwl_rate_info { 618struct iwl_rate_info {