wifi: iwlwifi: mvm: refactor iwl_mvm_set_sta_rate() a bit
authorJohannes Berg <johannes.berg@intel.com>
Tue, 6 Sep 2022 13:42:09 +0000 (16:42 +0300)
committerGregory Greenman <gregory.greenman@intel.com>
Sun, 18 Sep 2022 11:40:13 +0000 (14:40 +0300)
Use a switch statement over the rate type instead of the
if chain, to simplify.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20220906161827.623e32931b67.Id743a7879e84ae37a849179e536c58b1bf55380f@changeid
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

index df0793882f1df54e71fdd94dcd226d57724582d4..8fc51e536eaf09e511faefdd0516c652c0b65762 100644 (file)
@@ -4949,6 +4949,7 @@ static int iwl_mvm_mac_get_survey(struct ieee80211_hw *hw, int idx,
 static void iwl_mvm_set_sta_rate(u32 rate_n_flags, struct rate_info *rinfo)
 {
        u32 format = rate_n_flags & RATE_MCS_MOD_TYPE_MSK;
+       u32 gi_ltf;
 
        switch (rate_n_flags & RATE_MCS_CHAN_WIDTH_MSK) {
        case RATE_MCS_CHAN_WIDTH_20:
@@ -5019,9 +5020,12 @@ static void iwl_mvm_set_sta_rate(u32 rate_n_flags, struct rate_info *rinfo)
                RATE_HT_MCS_INDEX(rate_n_flags) :
                u32_get_bits(rate_n_flags, RATE_MCS_CODE_MSK);
 
-       if (format == RATE_MCS_HE_MSK) {
-               u32 gi_ltf = u32_get_bits(rate_n_flags,
-                                         RATE_MCS_HE_GI_LTF_MSK);
+       if (rate_n_flags & RATE_MCS_SGI_MSK)
+               rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
+
+       switch (format) {
+       case RATE_MCS_HE_MSK:
+               gi_ltf = u32_get_bits(rate_n_flags, RATE_MCS_HE_GI_LTF_MSK);
 
                rinfo->flags |= RATE_INFO_FLAGS_HE_MCS;
 
@@ -5060,19 +5064,14 @@ static void iwl_mvm_set_sta_rate(u32 rate_n_flags, struct rate_info *rinfo)
 
                if (rate_n_flags & RATE_HE_DUAL_CARRIER_MODE_MSK)
                        rinfo->he_dcm = 1;
-               return;
-       }
-
-       if (rate_n_flags & RATE_MCS_SGI_MSK)
-               rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
-
-       if (format == RATE_MCS_HT_MSK) {
+               break;
+       case RATE_MCS_HT_MSK:
                rinfo->flags |= RATE_INFO_FLAGS_MCS;
-
-       } else if (format == RATE_MCS_VHT_MSK) {
+               break;
+       case RATE_MCS_VHT_MSK:
                rinfo->flags |= RATE_INFO_FLAGS_VHT_MCS;
+               break;
        }
-
 }
 
 static void iwl_mvm_mac_sta_statistics(struct ieee80211_hw *hw,