wireless: set correct mandatory rate flags
authorRichard Schütz <rschuetz@uni-koblenz.de>
Thu, 7 Sep 2017 15:47:43 +0000 (17:47 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 21 Sep 2017 13:47:12 +0000 (15:47 +0200)
According to IEEE Std 802.11-2016 (16.2.3.4 Long PHY SIGNAL field) all of
the following rates are mandatory for a HR/DSSS PHY: 1 Mb/s, 2 Mb/s,
5.5 Mb/s and 11 Mb/s. Set IEEE80211_RATE_MANDATORY_B flag for all of these
instead of just 1 Mb/s to correctly reflect this.

Signed-off-by: Richard Schütz <rschuetz@uni-koblenz.de>
[johannes: use switch statement]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/util.c

index 7dcdf67cba29a6d97ff5b36f99a81927167cbd6d..7a1fcc6ee0606843063cb2c4952d68e091d9de09 100644 (file)
@@ -157,32 +157,30 @@ static void set_mandatory_flags_band(struct ieee80211_supported_band *sband)
        case NL80211_BAND_2GHZ:
                want = 7;
                for (i = 0; i < sband->n_bitrates; i++) {
-                       if (sband->bitrates[i].bitrate == 10) {
+                       switch (sband->bitrates[i].bitrate) {
+                       case 10:
+                       case 20:
+                       case 55:
+                       case 110:
                                sband->bitrates[i].flags |=
                                        IEEE80211_RATE_MANDATORY_B |
                                        IEEE80211_RATE_MANDATORY_G;
                                want--;
-                       }
-
-                       if (sband->bitrates[i].bitrate == 20 ||
-                           sband->bitrates[i].bitrate == 55 ||
-                           sband->bitrates[i].bitrate == 110 ||
-                           sband->bitrates[i].bitrate == 60 ||
-                           sband->bitrates[i].bitrate == 120 ||
-                           sband->bitrates[i].bitrate == 240) {
+                               break;
+                       case 60:
+                       case 120:
+                       case 240:
                                sband->bitrates[i].flags |=
                                        IEEE80211_RATE_MANDATORY_G;
                                want--;
-                       }
-
-                       if (sband->bitrates[i].bitrate != 10 &&
-                           sband->bitrates[i].bitrate != 20 &&
-                           sband->bitrates[i].bitrate != 55 &&
-                           sband->bitrates[i].bitrate != 110)
+                               /* fall through */
+                       default:
                                sband->bitrates[i].flags |=
                                        IEEE80211_RATE_ERP_G;
+                               break;
+                       }
                }
-               WARN_ON(want != 0 && want != 3 && want != 6);
+               WARN_ON(want != 0 && want != 3);
                break;
        case NL80211_BAND_60GHZ:
                /* check for mandatory HT MCS 1..4 */