]> git.karo-electronics.de Git - linux-beck.git/commitdiff
iwlwifi: mvm: change the iwl_mvm_d3_iface_iterator into a generic function
authorLuciano Coelho <luciano.coelho@intel.com>
Thu, 2 Oct 2014 12:38:04 +0000 (15:38 +0300)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Wed, 29 Oct 2014 10:49:13 +0000 (12:49 +0200)
Getting the BSS station vif is something that may be needed by other
parts of the code.  So, instead of having an iterator specifically for
d3, change it into a generic one in utils.c.  Additionally, add a
iwl_mvm_get_bss_vif() function to make it easier to retrieving it.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/iwlwifi/mvm/d3.c
drivers/net/wireless/iwlwifi/mvm/mvm.h
drivers/net/wireless/iwlwifi/mvm/utils.c

index 0b3295e3f6a60958709f790cfb06c912f7632ce6..3bbb511b0b3883ddc2f5c08808d0cabc5d15515b 100644 (file)
@@ -601,29 +601,6 @@ static int iwl_mvm_send_remote_wake_cfg(struct iwl_mvm *mvm,
        return ret;
 }
 
-struct iwl_d3_iter_data {
-       struct iwl_mvm *mvm;
-       struct ieee80211_vif *vif;
-       bool error;
-};
-
-static void iwl_mvm_d3_iface_iterator(void *_data, u8 *mac,
-                                     struct ieee80211_vif *vif)
-{
-       struct iwl_d3_iter_data *data = _data;
-
-       if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
-               return;
-
-       if (data->vif) {
-               IWL_ERR(data->mvm, "More than one managed interface active!\n");
-               data->error = true;
-               return;
-       }
-
-       data->vif = vif;
-}
-
 static int iwl_mvm_d3_reprogram(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
                                struct ieee80211_sta *ap_sta)
 {
@@ -990,9 +967,6 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
                             bool test)
 {
        struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
-       struct iwl_d3_iter_data suspend_iter_data = {
-               .mvm = mvm,
-       };
        struct ieee80211_vif *vif = NULL;
        struct iwl_mvm_vif *mvmvif = NULL;
        struct ieee80211_sta *ap_sta = NULL;
@@ -1025,17 +999,12 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
 
        mutex_lock(&mvm->mutex);
 
-       /* see if there's only a single BSS vif */
-       ieee80211_iterate_active_interfaces_atomic(
-               mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
-               iwl_mvm_d3_iface_iterator, &suspend_iter_data);
-
-       if (suspend_iter_data.error || !suspend_iter_data.vif) {
+       vif = iwl_mvm_get_bss_vif(mvm);
+       if (IS_ERR_OR_NULL(vif)) {
                ret = 1;
                goto out_noreset;
        }
 
-       vif = suspend_iter_data.vif;
        mvmvif = iwl_mvm_vif_from_mac80211(vif);
 
        /* if we're associated, this is wowlan */
@@ -1639,9 +1608,6 @@ static void iwl_mvm_d3_disconnect_iter(void *data, u8 *mac,
 
 static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
 {
-       struct iwl_d3_iter_data resume_iter_data = {
-               .mvm = mvm,
-       };
        struct ieee80211_vif *vif = NULL;
        int ret;
        enum iwl_d3_status d3_status;
@@ -1650,15 +1616,10 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
        mutex_lock(&mvm->mutex);
 
        /* get the BSS vif pointer again */
-       ieee80211_iterate_active_interfaces_atomic(
-               mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
-               iwl_mvm_d3_iface_iterator, &resume_iter_data);
-
-       if (WARN_ON(resume_iter_data.error || !resume_iter_data.vif))
+       vif = iwl_mvm_get_bss_vif(mvm);
+       if (IS_ERR_OR_NULL(vif))
                goto out_unlock;
 
-       vif = resume_iter_data.vif;
-
        ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test);
        if (ret)
                goto out_unlock;
index 60aee625b966b4de168805cacd5ce7079ad49126..aec9f579f5a98d90b6e6e32e3a44ba081ad0810e 100644 (file)
@@ -1214,6 +1214,8 @@ void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
                                           struct ieee80211_vif *vif);
 
+struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
+
 void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
 #ifdef CONFIG_IWLWIFI_DEBUGFS
 void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm);
index 8021f6eec27f7d8a918b41404383d85cc317b7ca..e56e77ef5d2e3d28d9a30185ef257aa43912ed23 100644 (file)
@@ -734,3 +734,40 @@ bool iwl_mvm_is_idle(struct iwl_mvm *mvm)
 
        return idle;
 }
+
+struct iwl_bss_iter_data {
+       struct ieee80211_vif *vif;
+       bool error;
+};
+
+static void iwl_mvm_bss_iface_iterator(void *_data, u8 *mac,
+                                      struct ieee80211_vif *vif)
+{
+       struct iwl_bss_iter_data *data = _data;
+
+       if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
+               return;
+
+       if (data->vif) {
+               data->error = true;
+               return;
+       }
+
+       data->vif = vif;
+}
+
+struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm)
+{
+       struct iwl_bss_iter_data bss_iter_data = {};
+
+       ieee80211_iterate_active_interfaces_atomic(
+               mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
+               iwl_mvm_bss_iface_iterator, &bss_iter_data);
+
+       if (bss_iter_data.error) {
+               IWL_ERR(mvm, "More than one managed interface active!\n");
+               return ERR_PTR(-EINVAL);
+       }
+
+       return bss_iter_data.vif;
+}