From: Luca Coelho <luciano.coe...@intel.com>

Instead of having a boolean for each modifier we need to handle in the
channel maps, create a bitmask with flags that denote each
modification.

Signed-off-by: Luca Coelho <luciano.coe...@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/nvm.c        | 10 +++++----
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 25 ++++++++++++++--------
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h | 14 ++++++++++--
 3 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/nvm.c 
b/drivers/net/wireless/intel/iwlwifi/fw/nvm.c
index ff44d9031e1a..beefb89194a9 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/nvm.c
@@ -87,6 +87,7 @@ struct iwl_nvm_data *iwl_fw_get_nvm(struct iwl_fw_runtime 
*fwrt)
                                fw_has_capa(&fwrt->fw->ucode_capa,
                                            IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
        u32 mac_flags;
+       u32 sbands_flags = 0;
 
        ret = iwl_trans_send_cmd(trans, &hcmd);
        if (ret)
@@ -144,15 +145,16 @@ struct iwl_nvm_data *iwl_fw_get_nvm(struct iwl_fw_runtime 
*fwrt)
        nvm->valid_tx_ant = (u8)le32_to_cpu(rsp->phy_sku.tx_chains);
        nvm->valid_rx_ant = (u8)le32_to_cpu(rsp->phy_sku.rx_chains);
 
-       /* Initialize regulatory data */
-       nvm->lar_enabled =
-               le32_to_cpu(rsp->regulatory.lar_enabled) && lar_fw_supported;
+       if (le32_to_cpu(rsp->regulatory.lar_enabled) && lar_fw_supported) {
+               nvm->lar_enabled = true;
+               sbands_flags |= IWL_NVM_SBANDS_FLAGS_LAR;
+       }
 
        iwl_init_sbands(trans->dev, trans->cfg, nvm,
                        rsp->regulatory.channel_profile,
                        nvm->valid_tx_ant & fwrt->fw->valid_tx_ant,
                        nvm->valid_rx_ant & fwrt->fw->valid_rx_ant,
-                       nvm->lar_enabled, false);
+                       sbands_flags);
 
        iwl_free_resp(&hcmd);
        return nvm;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c 
b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 3437ed480e31..735b211364d2 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -295,7 +295,7 @@ static u32 iwl_get_channel_flags(u8 ch_num, int ch_idx, 
bool is_5ghz,
 static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg,
                                struct iwl_nvm_data *data,
                                const __le16 * const nvm_ch_flags,
-                               bool lar_supported, bool no_wide_in_5ghz)
+                               u32 sbands_flags)
 {
        int ch_idx;
        int n_channels = 0;
@@ -323,7 +323,8 @@ static int iwl_init_channel_map(struct device *dev, const 
struct iwl_cfg *cfg,
                        continue;
 
                /* workaround to disable wide channels in 5GHz */
-               if (no_wide_in_5ghz && is_5ghz) {
+               if ((sbands_flags & IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ) &&
+                   is_5ghz) {
                        ch_flags &= ~(NVM_CHANNEL_40MHZ |
                                     NVM_CHANNEL_80MHZ |
                                     NVM_CHANNEL_160MHZ);
@@ -332,7 +333,8 @@ static int iwl_init_channel_map(struct device *dev, const 
struct iwl_cfg *cfg,
                if (ch_flags & NVM_CHANNEL_160MHZ)
                        data->vht160_supported = true;
 
-               if (!lar_supported && !(ch_flags & NVM_CHANNEL_VALID)) {
+               if (!(sbands_flags & IWL_NVM_SBANDS_FLAGS_LAR) &&
+                   !(ch_flags & NVM_CHANNEL_VALID)) {
                        /*
                         * Channels might become valid later if lar is
                         * supported, hence we still want to add them to
@@ -362,7 +364,7 @@ static int iwl_init_channel_map(struct device *dev, const 
struct iwl_cfg *cfg,
                channel->max_power = IWL_DEFAULT_MAX_TX_POWER;
 
                /* don't put limitations in case we're using LAR */
-               if (!lar_supported)
+               if (!(sbands_flags & IWL_NVM_SBANDS_FLAGS_LAR))
                        channel->flags = iwl_get_channel_flags(nvm_chan[ch_idx],
                                                               ch_idx, is_5ghz,
                                                               ch_flags, cfg);
@@ -460,15 +462,14 @@ static void iwl_init_vht_hw_capab(const struct iwl_cfg 
*cfg,
 
 void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
                     struct iwl_nvm_data *data, const __le16 *nvm_ch_flags,
-                    u8 tx_chains, u8 rx_chains, bool lar_supported,
-                    bool no_wide_in_5ghz)
+                    u8 tx_chains, u8 rx_chains, u32 sbands_flags)
 {
        int n_channels;
        int n_used = 0;
        struct ieee80211_supported_band *sband;
 
        n_channels = iwl_init_channel_map(dev, cfg, data, nvm_ch_flags,
-                                         lar_supported, no_wide_in_5ghz);
+                                         sbands_flags);
        sband = &data->bands[NL80211_BAND_2GHZ];
        sband->band = NL80211_BAND_2GHZ;
        sband->bitrates = &iwl_cfg80211_rates[RATES_24_OFFS];
@@ -716,8 +717,8 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct 
iwl_cfg *cfg,
        struct device *dev = trans->dev;
        struct iwl_nvm_data *data;
        bool lar_enabled;
-       bool no_wide_in_5ghz = iwl_nvm_no_wide_in_5ghz(dev, cfg, nvm_hw);
        u32 sku, radio_cfg;
+       u32 sbands_flags = 0;
        u16 lar_config;
        const __le16 *ch_section;
 
@@ -790,8 +791,14 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct 
iwl_cfg *cfg,
                return NULL;
        }
 
+       if (lar_fw_supported && lar_enabled)
+               sbands_flags |= IWL_NVM_SBANDS_FLAGS_LAR;
+
+       if (iwl_nvm_no_wide_in_5ghz(dev, cfg, nvm_hw))
+               sbands_flags |= IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ;
+
        iwl_init_sbands(dev, cfg, data, ch_section, tx_chains, rx_chains,
-                       lar_fw_supported && lar_enabled, no_wide_in_5ghz);
+                       sbands_flags);
        data->calib_version = 255;
 
        return data;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h 
b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
index 6b108cae61b8..868baa508a16 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
@@ -69,6 +69,17 @@
 #include <net/cfg80211.h>
 #include "iwl-eeprom-parse.h"
 
+/**
+ * enum iwl_nvm_sbands_flags - modification flags for the channel profiles
+ *
+ * @IWL_NVM_SBANDS_FLAGS_LAR: LAR is enabled
+ * @IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ: disallow 40, 80 and 160MHz on 5GHz
+ */
+enum iwl_nvm_sbands_flags {
+       IWL_NVM_SBANDS_FLAGS_LAR                = BIT(0),
+       IWL_NVM_SBANDS_FLAGS_NO_WIDE_IN_5GHZ    = BIT(1),
+};
+
 /**
  * iwl_parse_nvm_data - parse NVM data and return values
  *
@@ -95,8 +106,7 @@ void iwl_set_hw_address_from_csr(struct iwl_trans *trans,
  */
 void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
                     struct iwl_nvm_data *data, const __le16 *nvm_ch_flags,
-                    u8 tx_chains, u8 rx_chains, bool lar_supported,
-                    bool no_wide_in_5ghz);
+                    u8 tx_chains, u8 rx_chains, u32 sbands_flags);
 
 /**
  * iwl_parse_mcc_info - parse MCC (mobile country code) info coming from FW
-- 
2.16.3

Reply via email to