From 90347b8c1fcfd474cd04986116d1682dead9aaf3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 29 Oct 2008 20:00:45 +0100 Subject: [PATCH] --- yaml --- r: 121798 b: refs/heads/master c: bd815252720e4b667d9946d050d003ec89bda099 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/net/wireless.h | 16 ++++++++++++++++ trunk/net/wireless/util.c | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 19feccf850ae..0ec7f8bfd915 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 743b97caf98036ec8ee4bfc6fc6f85ad94e04783 +refs/heads/master: bd815252720e4b667d9946d050d003ec89bda099 diff --git a/trunk/include/net/wireless.h b/trunk/include/net/wireless.h index 41294c5f6f8f..17d4b582cf34 100644 --- a/trunk/include/net/wireless.h +++ b/trunk/include/net/wireless.h @@ -340,6 +340,22 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq) return __ieee80211_get_channel(wiphy, freq); } +/** + * ieee80211_get_response_rate - get basic rate for a given rate + * + * @sband: the band to look for rates in + * @basic_rates: bitmap of basic rates + * @bitrate: the bitrate for which to find the basic rate + * + * This function returns the basic rate corresponding to a given + * bitrate, that is the next lower bitrate contained in the basic + * rate map, which is, for this function, given as a bitmap of + * indices of rates in the band's bitrate table. + */ +struct ieee80211_rate * +ieee80211_get_response_rate(struct ieee80211_supported_band *sband, + u64 basic_rates, int bitrate); + /** * regulatory_hint - driver hint to the wireless core a regulatory domain * @wiphy: the wireless device giving the hint (used only for reporting diff --git a/trunk/net/wireless/util.c b/trunk/net/wireless/util.c index f54424693a38..e76cc28b0345 100644 --- a/trunk/net/wireless/util.c +++ b/trunk/net/wireless/util.c @@ -7,6 +7,25 @@ #include #include "core.h" +struct ieee80211_rate * +ieee80211_get_response_rate(struct ieee80211_supported_band *sband, + u64 basic_rates, int bitrate) +{ + struct ieee80211_rate *result = &sband->bitrates[0]; + int i; + + for (i = 0; i < sband->n_bitrates; i++) { + if (!(basic_rates & BIT(i))) + continue; + if (sband->bitrates[i].bitrate > bitrate) + continue; + result = &sband->bitrates[i]; + } + + return result; +} +EXPORT_SYMBOL(ieee80211_get_response_rate); + int ieee80211_channel_to_frequency(int chan) { if (chan < 14)