iwlwifi: mvm: look for the first supported channel when add/remove phy ctxt
authorTova Mussai <tova.mussai@intel.com>
Thu, 4 Jul 2019 11:34:54 +0000 (14:34 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 6 Sep 2019 12:31:22 +0000 (15:31 +0300)
Can't rely that band 2.4 is always supported by the NIC and use the
first channel in this band for the phy ctxt.
Instead, look for the first channel in the first band that is supported

Signed-off-by: Tova Mussai <tova.mussai@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c

index d2baea22cba25f8ccd840004e385752a14c7da4c..a6e360194e00cd0c6c474d3f333aad776b81918c 100644 (file)
@@ -1282,6 +1282,7 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
        int ret, i;
        struct ieee80211_channel *chan;
        struct cfg80211_chan_def chandef;
+       struct ieee80211_supported_band *sband = NULL;
 
        lockdep_assert_held(&mvm->mutex);
 
@@ -1371,7 +1372,15 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
                goto error;
 
        /* Add all the PHY contexts */
-       chan = &mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[0];
+       i = 0;
+       while (!sband && i < NUM_NL80211_BANDS)
+               sband = mvm->hw->wiphy->bands[i++];
+
+       if (WARN_ON_ONCE(!sband))
+               goto error;
+
+       chan = &sband->channels[0];
+
        cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
        for (i = 0; i < NUM_PHY_CTX; i++) {
                /*
index 86e40bae57e3c7678edeecf238a4315d0c104ae6..0243dbe8ac49067b6168ccf947b51a6def418a44 100644 (file)
@@ -289,8 +289,17 @@ void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt)
        if (ctxt->ref == 0) {
                struct ieee80211_channel *chan;
                struct cfg80211_chan_def chandef;
+               struct ieee80211_supported_band *sband = NULL;
+               enum nl80211_band band = NL80211_BAND_2GHZ;
+
+               while (!sband && band < NUM_NL80211_BANDS)
+                       sband = mvm->hw->wiphy->bands[band++];
+
+               if (WARN_ON(!sband))
+                       return;
+
+               chan = &sband->channels[0];
 
-               chan = &mvm->hw->wiphy->bands[NL80211_BAND_2GHZ]->channels[0];
                cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
                iwl_mvm_phy_ctxt_changed(mvm, ctxt, &chandef, 1, 1);
        }