SM501: Fix sm501_init_reg() mask/set order
[sfrench/cifs-2.6.git] / net / ieee80211 / ieee80211_geo.c
index 3027153940fcb48e99ed3fc0311bc9632165969f..960ad13f5e9f41fc724aff31ee842dcaaf4a5e23 100644 (file)
@@ -24,7 +24,6 @@
 
 ******************************************************************************/
 #include <linux/compiler.h>
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/if_arp.h>
 #include <linux/in6.h>
@@ -50,7 +49,8 @@ int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel)
 
        /* Driver needs to initialize the geography map before using
         * these helper functions */
-       BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
+       if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0)
+               return 0;
 
        if (ieee->freq_band & IEEE80211_24GHZ_BAND)
                for (i = 0; i < ieee->geo.bg_channels; i++)
@@ -78,7 +78,8 @@ int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel)
 
        /* Driver needs to initialize the geography map before using
         * these helper functions */
-       BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
+       if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0)
+               return -1;
 
        if (ieee->freq_band & IEEE80211_24GHZ_BAND)
                for (i = 0; i < ieee->geo.bg_channels; i++)
@@ -93,13 +94,29 @@ int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel)
        return -1;
 }
 
+u32 ieee80211_channel_to_freq(struct ieee80211_device * ieee, u8 channel)
+{
+       const struct ieee80211_channel * ch;
+
+       /* Driver needs to initialize the geography map before using
+        * these helper functions */
+       if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0)
+               return 0;
+
+       ch = ieee80211_get_channel(ieee, channel);
+       if (!ch->channel)
+               return 0;
+       return ch->freq;
+}
+
 u8 ieee80211_freq_to_channel(struct ieee80211_device * ieee, u32 freq)
 {
        int i;
 
        /* Driver needs to initialize the geography map before using
         * these helper functions */
-       BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
+       if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0)
+               return 0;
 
        freq /= 100000;
 
@@ -172,6 +189,7 @@ EXPORT_SYMBOL(ieee80211_get_channel);
 EXPORT_SYMBOL(ieee80211_get_channel_flags);
 EXPORT_SYMBOL(ieee80211_is_valid_channel);
 EXPORT_SYMBOL(ieee80211_freq_to_channel);
+EXPORT_SYMBOL(ieee80211_channel_to_freq);
 EXPORT_SYMBOL(ieee80211_channel_to_index);
 EXPORT_SYMBOL(ieee80211_set_geo);
 EXPORT_SYMBOL(ieee80211_get_geo);