cfg80211: clean up includes
[safe/jmp/linux-2.6] / net / wireless / util.c
index 0dcccbf..5f7e997 100644 (file)
@@ -1,12 +1,31 @@
 /*
  * Wireless utility functions
  *
- * Copyright 2007      Johannes Berg <johannes@sipsolutions.net>
+ * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net>
  */
-#include <net/wireless.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
+#include <net/cfg80211.h>
 #include "core.h"
 
+struct ieee80211_rate *
+ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
+                           u32 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)
@@ -33,6 +52,29 @@ int ieee80211_frequency_to_channel(int freq)
 }
 EXPORT_SYMBOL(ieee80211_frequency_to_channel);
 
+struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
+                                                 int freq)
+{
+       enum ieee80211_band band;
+       struct ieee80211_supported_band *sband;
+       int i;
+
+       for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+               sband = wiphy->bands[band];
+
+               if (!sband)
+                       continue;
+
+               for (i = 0; i < sband->n_channels; i++) {
+                       if (sband->channels[i].center_freq == freq)
+                               return &sband->channels[i];
+               }
+       }
+
+       return NULL;
+}
+EXPORT_SYMBOL(__ieee80211_get_channel);
+
 static void set_mandatory_flags_band(struct ieee80211_supported_band *sband,
                                     enum ieee80211_band band)
 {
@@ -73,14 +115,14 @@ static void set_mandatory_flags_band(struct ieee80211_supported_band *sband,
                                want--;
                        }
 
-                       if (sband->bitrates[i].bitrate == 10 ||
-                           sband->bitrates[i].bitrate == 20 ||
-                           sband->bitrates[i].bitrate == 55 ||
-                           sband->bitrates[i].bitrate == 110)
+                       if (sband->bitrates[i].bitrate != 10 &&
+                           sband->bitrates[i].bitrate != 20 &&
+                           sband->bitrates[i].bitrate != 55 &&
+                           sband->bitrates[i].bitrate != 110)
                                sband->bitrates[i].flags |=
                                        IEEE80211_RATE_ERP_G;
                }
-               WARN_ON(want != 0 && want != 6);
+               WARN_ON(want != 0 && want != 3 && want != 6);
                break;
        case IEEE80211_NUM_BANDS:
                WARN_ON(1);