diff options
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_main.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_main.h | 80 | ||||
-rw-r--r-- | drivers/net/wireless/bcm43xx/bcm43xx_wx.c | 12 |
3 files changed, 59 insertions, 37 deletions
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c index b4767e42e8f4..6195c2a1516d 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c | |||
@@ -1169,7 +1169,7 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm) | |||
1169 | if (have_a) { | 1169 | if (have_a) { |
1170 | for (i = 0, channel = 0; channel < 201; channel++) { | 1170 | for (i = 0, channel = 0; channel < 201; channel++) { |
1171 | chan = &geo.a[i++]; | 1171 | chan = &geo.a[i++]; |
1172 | chan->freq = bcm43xx_channel_to_freq(bcm, channel); | 1172 | chan->freq = bcm43xx_channel_to_freq_a(channel); |
1173 | chan->channel = channel; | 1173 | chan->channel = channel; |
1174 | } | 1174 | } |
1175 | geo.a_channels = i; | 1175 | geo.a_channels = i; |
@@ -1177,7 +1177,7 @@ static void bcm43xx_geo_init(struct bcm43xx_private *bcm) | |||
1177 | if (have_bg) { | 1177 | if (have_bg) { |
1178 | for (i = 0, channel = 1; channel < 15; channel++) { | 1178 | for (i = 0, channel = 1; channel < 15; channel++) { |
1179 | chan = &geo.bg[i++]; | 1179 | chan = &geo.bg[i++]; |
1180 | chan->freq = bcm43xx_channel_to_freq(bcm, channel); | 1180 | chan->freq = bcm43xx_channel_to_freq_bg(channel); |
1181 | chan->channel = channel; | 1181 | chan->channel = channel; |
1182 | } | 1182 | } |
1183 | geo.bg_channels = i; | 1183 | geo.bg_channels = i; |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.h b/drivers/net/wireless/bcm43xx/bcm43xx_main.h index 0a22e833915d..7d696d257f7a 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.h | |||
@@ -187,58 +187,78 @@ struct bcm43xx_xmitstatus_queue { | |||
187 | 187 | ||
188 | /* Lightweight function to convert a frequency (in Mhz) to a channel number. */ | 188 | /* Lightweight function to convert a frequency (in Mhz) to a channel number. */ |
189 | static inline | 189 | static inline |
190 | u8 bcm43xx_freq_to_channel(struct bcm43xx_private *bcm, | 190 | u8 bcm43xx_freq_to_channel_a(int freq) |
191 | int freq) | 191 | { |
192 | return ((freq - 5000) / 5); | ||
193 | } | ||
194 | static inline | ||
195 | u8 bcm43xx_freq_to_channel_bg(int freq) | ||
192 | { | 196 | { |
193 | u8 channel; | 197 | u8 channel; |
194 | 198 | ||
195 | if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) { | 199 | if (freq == 2484) |
196 | channel = (freq - 5000) / 5; | 200 | channel = 14; |
197 | } else { | 201 | else |
198 | if (freq == 2484) | 202 | channel = (freq - 2407) / 5; |
199 | channel = 14; | ||
200 | else | ||
201 | channel = (freq - 2407) / 5; | ||
202 | } | ||
203 | 203 | ||
204 | return channel; | 204 | return channel; |
205 | } | 205 | } |
206 | static inline | ||
207 | u8 bcm43xx_freq_to_channel(struct bcm43xx_private *bcm, | ||
208 | int freq) | ||
209 | { | ||
210 | if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) | ||
211 | return bcm43xx_freq_to_channel_a(freq); | ||
212 | return bcm43xx_freq_to_channel_bg(freq); | ||
213 | } | ||
206 | 214 | ||
207 | /* Lightweight function to convert a channel number to a frequency (in Mhz). */ | 215 | /* Lightweight function to convert a channel number to a frequency (in Mhz). */ |
208 | static inline | 216 | static inline |
209 | int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm, | 217 | int bcm43xx_channel_to_freq_a(u8 channel) |
210 | u8 channel) | 218 | { |
219 | return (5000 + (5 * channel)); | ||
220 | } | ||
221 | static inline | ||
222 | int bcm43xx_channel_to_freq_bg(u8 channel) | ||
211 | { | 223 | { |
212 | int freq; | 224 | int freq; |
213 | 225 | ||
214 | if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) { | 226 | if (channel == 14) |
215 | freq = 5000 + (5 * channel); | 227 | freq = 2484; |
216 | } else { | 228 | else |
217 | if (channel == 14) | 229 | freq = 2407 + (5 * channel); |
218 | freq = 2484; | ||
219 | else | ||
220 | freq = 2407 + (5 * channel); | ||
221 | } | ||
222 | 230 | ||
223 | return freq; | 231 | return freq; |
224 | } | 232 | } |
233 | static inline | ||
234 | int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm, | ||
235 | u8 channel) | ||
236 | { | ||
237 | if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) | ||
238 | return bcm43xx_channel_to_freq_a(channel); | ||
239 | return bcm43xx_channel_to_freq_bg(channel); | ||
240 | } | ||
225 | 241 | ||
226 | /* Lightweight function to check if a channel number is valid. | 242 | /* Lightweight function to check if a channel number is valid. |
227 | * Note that this does _NOT_ check for geographical restrictions! | 243 | * Note that this does _NOT_ check for geographical restrictions! |
228 | */ | 244 | */ |
229 | static inline | 245 | static inline |
246 | int bcm43xx_is_valid_channel_a(u8 channel) | ||
247 | { | ||
248 | return (channel <= 200); | ||
249 | } | ||
250 | static inline | ||
251 | int bcm43xx_is_valid_channel_bg(u8 channel) | ||
252 | { | ||
253 | return (channel >= 1 && channel <= 14); | ||
254 | } | ||
255 | static inline | ||
230 | int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm, | 256 | int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm, |
231 | u8 channel) | 257 | u8 channel) |
232 | { | 258 | { |
233 | if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) { | 259 | if (bcm->current_core->phy->type == BCM43xx_PHYTYPE_A) |
234 | if (channel <= 200) | 260 | return bcm43xx_is_valid_channel_a(channel); |
235 | return 1; | 261 | return bcm43xx_is_valid_channel_bg(channel); |
236 | } else { | ||
237 | if (channel >= 1 && channel <= 14) | ||
238 | return 1; | ||
239 | } | ||
240 | |||
241 | return 0; | ||
242 | } | 262 | } |
243 | 263 | ||
244 | void bcm43xx_tsf_read(struct bcm43xx_private *bcm, u64 *tsf); | 264 | void bcm43xx_tsf_read(struct bcm43xx_private *bcm, u64 *tsf); |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c index df37d28996c9..aa2d9930c436 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c | |||
@@ -111,8 +111,9 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev, | |||
111 | unsigned long flags; | 111 | unsigned long flags; |
112 | u8 channel; | 112 | u8 channel; |
113 | int freq; | 113 | int freq; |
114 | int err = 0; | 114 | int err = -EINVAL; |
115 | 115 | ||
116 | spin_lock_irqsave(&bcm->lock, flags); | ||
116 | if ((data->freq.m >= 0) && (data->freq.m <= 1000)) { | 117 | if ((data->freq.m >= 0) && (data->freq.m <= 1000)) { |
117 | channel = data->freq.m; | 118 | channel = data->freq.m; |
118 | freq = bcm43xx_channel_to_freq(bcm, channel); | 119 | freq = bcm43xx_channel_to_freq(bcm, channel); |
@@ -121,16 +122,17 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev, | |||
121 | freq = data->freq.m; | 122 | freq = data->freq.m; |
122 | } | 123 | } |
123 | if (!bcm43xx_is_valid_channel(bcm, channel)) | 124 | if (!bcm43xx_is_valid_channel(bcm, channel)) |
124 | return -EINVAL; | 125 | goto out_unlock; |
125 | |||
126 | spin_lock_irqsave(&bcm->lock, flags); | ||
127 | if (bcm->initialized) { | 126 | if (bcm->initialized) { |
128 | //ieee80211softmac_disassoc(softmac, $REASON); | 127 | //ieee80211softmac_disassoc(softmac, $REASON); |
129 | bcm43xx_mac_suspend(bcm); | 128 | bcm43xx_mac_suspend(bcm); |
130 | err = bcm43xx_radio_selectchannel(bcm, channel, 0); | 129 | err = bcm43xx_radio_selectchannel(bcm, channel, 0); |
131 | bcm43xx_mac_enable(bcm); | 130 | bcm43xx_mac_enable(bcm); |
132 | } else | 131 | } else { |
133 | bcm->current_core->radio->initial_channel = channel; | 132 | bcm->current_core->radio->initial_channel = channel; |
133 | err = 0; | ||
134 | } | ||
135 | out_unlock: | ||
134 | spin_unlock_irqrestore(&bcm->lock, flags); | 136 | spin_unlock_irqrestore(&bcm->lock, flags); |
135 | 137 | ||
136 | return err; | 138 | return err; |