diff options
Diffstat (limited to 'net/wireless/util.c')
-rw-r--r-- | net/wireless/util.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c index 4d7b83fbc32f..a329429bfdd8 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -1006,3 +1006,38 @@ int cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, | |||
1006 | 1006 | ||
1007 | return -EBUSY; | 1007 | return -EBUSY; |
1008 | } | 1008 | } |
1009 | |||
1010 | int ieee80211_get_ratemask(struct ieee80211_supported_band *sband, | ||
1011 | const u8 *rates, unsigned int n_rates, | ||
1012 | u32 *mask) | ||
1013 | { | ||
1014 | int i, j; | ||
1015 | |||
1016 | if (n_rates == 0 || n_rates > NL80211_MAX_SUPP_RATES) | ||
1017 | return -EINVAL; | ||
1018 | |||
1019 | *mask = 0; | ||
1020 | |||
1021 | for (i = 0; i < n_rates; i++) { | ||
1022 | int rate = (rates[i] & 0x7f) * 5; | ||
1023 | bool found = false; | ||
1024 | |||
1025 | for (j = 0; j < sband->n_bitrates; j++) { | ||
1026 | if (sband->bitrates[j].bitrate == rate) { | ||
1027 | found = true; | ||
1028 | *mask |= BIT(j); | ||
1029 | break; | ||
1030 | } | ||
1031 | } | ||
1032 | if (!found) | ||
1033 | return -EINVAL; | ||
1034 | } | ||
1035 | |||
1036 | /* | ||
1037 | * mask must have at least one bit set here since we | ||
1038 | * didn't accept a 0-length rates array nor allowed | ||
1039 | * entries in the array that didn't exist | ||
1040 | */ | ||
1041 | |||
1042 | return 0; | ||
1043 | } | ||