diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-10-29 15:00:45 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-11-10 15:17:35 -0500 |
commit | bd815252720e4b667d9946d050d003ec89bda099 (patch) | |
tree | d7bb98f512c8b48031f9df01745820b7d6dfb3ac | |
parent | 743b97caf98036ec8ee4bfc6fc6f85ad94e04783 (diff) |
wireless: implement basic rate helper function
This adds a helper function that, given a bitmap of basic
rates and a bitrate returns the response rate for this rate.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | include/net/wireless.h | 16 | ||||
-rw-r--r-- | net/wireless/util.c | 19 |
2 files changed, 35 insertions, 0 deletions
diff --git a/include/net/wireless.h b/include/net/wireless.h index 41294c5f6f8f..17d4b582cf34 100644 --- a/include/net/wireless.h +++ b/include/net/wireless.h | |||
@@ -341,6 +341,22 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq) | |||
341 | } | 341 | } |
342 | 342 | ||
343 | /** | 343 | /** |
344 | * ieee80211_get_response_rate - get basic rate for a given rate | ||
345 | * | ||
346 | * @sband: the band to look for rates in | ||
347 | * @basic_rates: bitmap of basic rates | ||
348 | * @bitrate: the bitrate for which to find the basic rate | ||
349 | * | ||
350 | * This function returns the basic rate corresponding to a given | ||
351 | * bitrate, that is the next lower bitrate contained in the basic | ||
352 | * rate map, which is, for this function, given as a bitmap of | ||
353 | * indices of rates in the band's bitrate table. | ||
354 | */ | ||
355 | struct ieee80211_rate * | ||
356 | ieee80211_get_response_rate(struct ieee80211_supported_band *sband, | ||
357 | u64 basic_rates, int bitrate); | ||
358 | |||
359 | /** | ||
344 | * regulatory_hint - driver hint to the wireless core a regulatory domain | 360 | * regulatory_hint - driver hint to the wireless core a regulatory domain |
345 | * @wiphy: the wireless device giving the hint (used only for reporting | 361 | * @wiphy: the wireless device giving the hint (used only for reporting |
346 | * conflicts) | 362 | * conflicts) |
diff --git a/net/wireless/util.c b/net/wireless/util.c index f54424693a38..e76cc28b0345 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c | |||
@@ -7,6 +7,25 @@ | |||
7 | #include <asm/bitops.h> | 7 | #include <asm/bitops.h> |
8 | #include "core.h" | 8 | #include "core.h" |
9 | 9 | ||
10 | struct ieee80211_rate * | ||
11 | ieee80211_get_response_rate(struct ieee80211_supported_band *sband, | ||
12 | u64 basic_rates, int bitrate) | ||
13 | { | ||
14 | struct ieee80211_rate *result = &sband->bitrates[0]; | ||
15 | int i; | ||
16 | |||
17 | for (i = 0; i < sband->n_bitrates; i++) { | ||
18 | if (!(basic_rates & BIT(i))) | ||
19 | continue; | ||
20 | if (sband->bitrates[i].bitrate > bitrate) | ||
21 | continue; | ||
22 | result = &sband->bitrates[i]; | ||
23 | } | ||
24 | |||
25 | return result; | ||
26 | } | ||
27 | EXPORT_SYMBOL(ieee80211_get_response_rate); | ||
28 | |||
10 | int ieee80211_channel_to_frequency(int chan) | 29 | int ieee80211_channel_to_frequency(int chan) |
11 | { | 30 | { |
12 | if (chan < 14) | 31 | if (chan < 14) |