diff options
Diffstat (limited to 'net/ieee80211/ieee80211_geo.c')
-rw-r--r-- | net/ieee80211/ieee80211_geo.c | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/net/ieee80211/ieee80211_geo.c b/net/ieee80211/ieee80211_geo.c index 610cc5cbc252..192243ab35ed 100644 --- a/net/ieee80211/ieee80211_geo.c +++ b/net/ieee80211/ieee80211_geo.c | |||
@@ -50,7 +50,8 @@ int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel) | |||
50 | 50 | ||
51 | /* Driver needs to initialize the geography map before using | 51 | /* Driver needs to initialize the geography map before using |
52 | * these helper functions */ | 52 | * these helper functions */ |
53 | BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0); | 53 | if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0) |
54 | return 0; | ||
54 | 55 | ||
55 | if (ieee->freq_band & IEEE80211_24GHZ_BAND) | 56 | if (ieee->freq_band & IEEE80211_24GHZ_BAND) |
56 | for (i = 0; i < ieee->geo.bg_channels; i++) | 57 | for (i = 0; i < ieee->geo.bg_channels; i++) |
@@ -58,13 +59,15 @@ int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel) | |||
58 | * this is a B only channel, we don't see it | 59 | * this is a B only channel, we don't see it |
59 | * as valid. */ | 60 | * as valid. */ |
60 | if ((ieee->geo.bg[i].channel == channel) && | 61 | if ((ieee->geo.bg[i].channel == channel) && |
62 | !(ieee->geo.bg[i].flags & IEEE80211_CH_INVALID) && | ||
61 | (!(ieee->mode & IEEE_G) || | 63 | (!(ieee->mode & IEEE_G) || |
62 | !(ieee->geo.bg[i].flags & IEEE80211_CH_B_ONLY))) | 64 | !(ieee->geo.bg[i].flags & IEEE80211_CH_B_ONLY))) |
63 | return IEEE80211_24GHZ_BAND; | 65 | return IEEE80211_24GHZ_BAND; |
64 | 66 | ||
65 | if (ieee->freq_band & IEEE80211_52GHZ_BAND) | 67 | if (ieee->freq_band & IEEE80211_52GHZ_BAND) |
66 | for (i = 0; i < ieee->geo.a_channels; i++) | 68 | for (i = 0; i < ieee->geo.a_channels; i++) |
67 | if (ieee->geo.a[i].channel == channel) | 69 | if ((ieee->geo.a[i].channel == channel) && |
70 | !(ieee->geo.a[i].flags & IEEE80211_CH_INVALID)) | ||
68 | return IEEE80211_52GHZ_BAND; | 71 | return IEEE80211_52GHZ_BAND; |
69 | 72 | ||
70 | return 0; | 73 | return 0; |
@@ -76,7 +79,8 @@ int ieee80211_channel_to_index(struct ieee80211_device *ieee, u8 channel) | |||
76 | 79 | ||
77 | /* Driver needs to initialize the geography map before using | 80 | /* Driver needs to initialize the geography map before using |
78 | * these helper functions */ | 81 | * these helper functions */ |
79 | BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0); | 82 | if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0) |
83 | return -1; | ||
80 | 84 | ||
81 | if (ieee->freq_band & IEEE80211_24GHZ_BAND) | 85 | if (ieee->freq_band & IEEE80211_24GHZ_BAND) |
82 | for (i = 0; i < ieee->geo.bg_channels; i++) | 86 | for (i = 0; i < ieee->geo.bg_channels; i++) |
@@ -97,7 +101,8 @@ u8 ieee80211_freq_to_channel(struct ieee80211_device * ieee, u32 freq) | |||
97 | 101 | ||
98 | /* Driver needs to initialize the geography map before using | 102 | /* Driver needs to initialize the geography map before using |
99 | * these helper functions */ | 103 | * these helper functions */ |
100 | BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0); | 104 | if (ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0) |
105 | return 0; | ||
101 | 106 | ||
102 | freq /= 100000; | 107 | freq /= 100000; |
103 | 108 | ||
@@ -133,6 +138,41 @@ const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device *ieee) | |||
133 | return &ieee->geo; | 138 | return &ieee->geo; |
134 | } | 139 | } |
135 | 140 | ||
141 | u8 ieee80211_get_channel_flags(struct ieee80211_device * ieee, u8 channel) | ||
142 | { | ||
143 | int index = ieee80211_channel_to_index(ieee, channel); | ||
144 | |||
145 | if (index == -1) | ||
146 | return IEEE80211_CH_INVALID; | ||
147 | |||
148 | if (channel <= IEEE80211_24GHZ_CHANNELS) | ||
149 | return ieee->geo.bg[index].flags; | ||
150 | |||
151 | return ieee->geo.a[index].flags; | ||
152 | } | ||
153 | |||
154 | static const struct ieee80211_channel bad_channel = { | ||
155 | .channel = 0, | ||
156 | .flags = IEEE80211_CH_INVALID, | ||
157 | .max_power = 0, | ||
158 | }; | ||
159 | |||
160 | const struct ieee80211_channel *ieee80211_get_channel(struct ieee80211_device | ||
161 | *ieee, u8 channel) | ||
162 | { | ||
163 | int index = ieee80211_channel_to_index(ieee, channel); | ||
164 | |||
165 | if (index == -1) | ||
166 | return &bad_channel; | ||
167 | |||
168 | if (channel <= IEEE80211_24GHZ_CHANNELS) | ||
169 | return &ieee->geo.bg[index]; | ||
170 | |||
171 | return &ieee->geo.a[index]; | ||
172 | } | ||
173 | |||
174 | EXPORT_SYMBOL(ieee80211_get_channel); | ||
175 | EXPORT_SYMBOL(ieee80211_get_channel_flags); | ||
136 | EXPORT_SYMBOL(ieee80211_is_valid_channel); | 176 | EXPORT_SYMBOL(ieee80211_is_valid_channel); |
137 | EXPORT_SYMBOL(ieee80211_freq_to_channel); | 177 | EXPORT_SYMBOL(ieee80211_freq_to_channel); |
138 | EXPORT_SYMBOL(ieee80211_channel_to_index); | 178 | EXPORT_SYMBOL(ieee80211_channel_to_index); |