aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c25
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c14
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c25
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h25
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c51
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c32
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c23
8 files changed, 137 insertions, 59 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 31bbb44611e5..2284cb308971 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -397,7 +397,7 @@ static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower)
397} 397}
398 398
399static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev, 399static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
400 int antenna_tx, int antenna_rx) 400 struct antenna_setup *ant)
401{ 401{
402 u8 r1; 402 u8 r1;
403 u8 r4; 403 u8 r4;
@@ -408,7 +408,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
408 /* 408 /*
409 * Configure the TX antenna. 409 * Configure the TX antenna.
410 */ 410 */
411 switch (antenna_tx) { 411 switch (ant->tx) {
412 case ANTENNA_SW_DIVERSITY: 412 case ANTENNA_SW_DIVERSITY:
413 case ANTENNA_HW_DIVERSITY: 413 case ANTENNA_HW_DIVERSITY:
414 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 1); 414 rt2x00_set_field8(&r1, BBP_R1_TX_ANTENNA, 1);
@@ -424,7 +424,7 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
424 /* 424 /*
425 * Configure the RX antenna. 425 * Configure the RX antenna.
426 */ 426 */
427 switch (antenna_rx) { 427 switch (ant->rx) {
428 case ANTENNA_SW_DIVERSITY: 428 case ANTENNA_SW_DIVERSITY:
429 case ANTENNA_HW_DIVERSITY: 429 case ANTENNA_HW_DIVERSITY:
430 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1); 430 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 1);
@@ -485,9 +485,7 @@ static void rt2400pci_config(struct rt2x00_dev *rt2x00dev,
485 rt2400pci_config_txpower(rt2x00dev, 485 rt2400pci_config_txpower(rt2x00dev,
486 libconf->conf->power_level); 486 libconf->conf->power_level);
487 if (flags & CONFIG_UPDATE_ANTENNA) 487 if (flags & CONFIG_UPDATE_ANTENNA)
488 rt2400pci_config_antenna(rt2x00dev, 488 rt2400pci_config_antenna(rt2x00dev, &libconf->ant);
489 libconf->conf->antenna_sel_tx,
490 libconf->conf->antenna_sel_rx);
491 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 489 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
492 rt2400pci_config_duration(rt2x00dev, libconf); 490 rt2400pci_config_duration(rt2x00dev, libconf);
493} 491}
@@ -1316,12 +1314,23 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1316 /* 1314 /*
1317 * Identify default antenna configuration. 1315 * Identify default antenna configuration.
1318 */ 1316 */
1319 rt2x00dev->hw->conf.antenna_sel_tx = 1317 rt2x00dev->default_ant.tx =
1320 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT); 1318 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
1321 rt2x00dev->hw->conf.antenna_sel_rx = 1319 rt2x00dev->default_ant.rx =
1322 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT); 1320 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
1323 1321
1324 /* 1322 /*
1323 * When the eeprom indicates SW_DIVERSITY use HW_DIVERSITY instead.
1324 * I am not 100% sure about this, but the legacy drivers do not
1325 * indicate antenna swapping in software is required when
1326 * diversity is enabled.
1327 */
1328 if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
1329 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY;
1330 if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
1331 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY;
1332
1333 /*
1325 * Store led mode, for correct led behaviour. 1334 * Store led mode, for correct led behaviour.
1326 */ 1335 */
1327 rt2x00dev->led_mode = 1336 rt2x00dev->led_mode =
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 4386823f49d1..a9872f95361b 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -424,7 +424,7 @@ static void rt2500pci_config_txpower(struct rt2x00_dev *rt2x00dev,
424} 424}
425 425
426static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev, 426static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev,
427 const int antenna_tx, const int antenna_rx) 427 struct antenna_setup *ant)
428{ 428{
429 u32 reg; 429 u32 reg;
430 u8 r14; 430 u8 r14;
@@ -437,7 +437,7 @@ static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev,
437 /* 437 /*
438 * Configure the TX antenna. 438 * Configure the TX antenna.
439 */ 439 */
440 switch (antenna_tx) { 440 switch (ant->tx) {
441 case ANTENNA_SW_DIVERSITY: 441 case ANTENNA_SW_DIVERSITY:
442 case ANTENNA_HW_DIVERSITY: 442 case ANTENNA_HW_DIVERSITY:
443 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2); 443 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 2);
@@ -459,7 +459,7 @@ static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev,
459 /* 459 /*
460 * Configure the RX antenna. 460 * Configure the RX antenna.
461 */ 461 */
462 switch (antenna_rx) { 462 switch (ant->rx) {
463 case ANTENNA_SW_DIVERSITY: 463 case ANTENNA_SW_DIVERSITY:
464 case ANTENNA_HW_DIVERSITY: 464 case ANTENNA_HW_DIVERSITY:
465 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2); 465 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 2);
@@ -541,9 +541,7 @@ static void rt2500pci_config(struct rt2x00_dev *rt2x00dev,
541 rt2500pci_config_txpower(rt2x00dev, 541 rt2500pci_config_txpower(rt2x00dev,
542 libconf->conf->power_level); 542 libconf->conf->power_level);
543 if (flags & CONFIG_UPDATE_ANTENNA) 543 if (flags & CONFIG_UPDATE_ANTENNA)
544 rt2500pci_config_antenna(rt2x00dev, 544 rt2500pci_config_antenna(rt2x00dev, &libconf->ant);
545 libconf->conf->antenna_sel_tx,
546 libconf->conf->antenna_sel_rx);
547 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 545 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
548 rt2500pci_config_duration(rt2x00dev, libconf); 546 rt2500pci_config_duration(rt2x00dev, libconf);
549} 547}
@@ -1485,9 +1483,9 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1485 /* 1483 /*
1486 * Identify default antenna configuration. 1484 * Identify default antenna configuration.
1487 */ 1485 */
1488 rt2x00dev->hw->conf.antenna_sel_tx = 1486 rt2x00dev->default_ant.tx =
1489 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT); 1487 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
1490 rt2x00dev->hw->conf.antenna_sel_rx = 1488 rt2x00dev->default_ant.rx =
1491 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT); 1489 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
1492 1490
1493 /* 1491 /*
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 98edd621c13b..31531f7cc125 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -385,7 +385,7 @@ static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
385} 385}
386 386
387static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev, 387static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev,
388 const int antenna_tx, const int antenna_rx) 388 struct antenna_setup *ant)
389{ 389{
390 u8 r2; 390 u8 r2;
391 u8 r14; 391 u8 r14;
@@ -400,7 +400,7 @@ static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev,
400 /* 400 /*
401 * Configure the TX antenna. 401 * Configure the TX antenna.
402 */ 402 */
403 switch (antenna_tx) { 403 switch (ant->tx) {
404 case ANTENNA_SW_DIVERSITY: 404 case ANTENNA_SW_DIVERSITY:
405 case ANTENNA_HW_DIVERSITY: 405 case ANTENNA_HW_DIVERSITY:
406 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 1); 406 rt2x00_set_field8(&r2, BBP_R2_TX_ANTENNA, 1);
@@ -422,7 +422,7 @@ static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev,
422 /* 422 /*
423 * Configure the RX antenna. 423 * Configure the RX antenna.
424 */ 424 */
425 switch (antenna_rx) { 425 switch (ant->rx) {
426 case ANTENNA_SW_DIVERSITY: 426 case ANTENNA_SW_DIVERSITY:
427 case ANTENNA_HW_DIVERSITY: 427 case ANTENNA_HW_DIVERSITY:
428 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 1); 428 rt2x00_set_field8(&r14, BBP_R14_RX_ANTENNA, 1);
@@ -487,9 +487,7 @@ static void rt2500usb_config(struct rt2x00_dev *rt2x00dev,
487 rt2500usb_config_txpower(rt2x00dev, 487 rt2500usb_config_txpower(rt2x00dev,
488 libconf->conf->power_level); 488 libconf->conf->power_level);
489 if (flags & CONFIG_UPDATE_ANTENNA) 489 if (flags & CONFIG_UPDATE_ANTENNA)
490 rt2500usb_config_antenna(rt2x00dev, 490 rt2500usb_config_antenna(rt2x00dev, &libconf->ant);
491 libconf->conf->antenna_sel_tx,
492 libconf->conf->antenna_sel_rx);
493 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 491 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
494 rt2500usb_config_duration(rt2x00dev, libconf); 492 rt2500usb_config_duration(rt2x00dev, libconf);
495} 493}
@@ -1278,12 +1276,23 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1278 /* 1276 /*
1279 * Identify default antenna configuration. 1277 * Identify default antenna configuration.
1280 */ 1278 */
1281 rt2x00dev->hw->conf.antenna_sel_tx = 1279 rt2x00dev->default_ant.tx =
1282 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT); 1280 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
1283 rt2x00dev->hw->conf.antenna_sel_rx = 1281 rt2x00dev->default_ant.rx =
1284 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT); 1282 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
1285 1283
1286 /* 1284 /*
1285 * When the eeprom indicates SW_DIVERSITY use HW_DIVERSITY instead.
1286 * I am not 100% sure about this, but the legacy drivers do not
1287 * indicate antenna swapping in software is required when
1288 * diversity is enabled.
1289 */
1290 if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY)
1291 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY;
1292 if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY)
1293 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY;
1294
1295 /*
1287 * Store led mode, for correct led behaviour. 1296 * Store led mode, for correct led behaviour.
1288 */ 1297 */
1289 rt2x00dev->led_mode = 1298 rt2x00dev->led_mode =
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index cec604b1b093..c47a1e6333cc 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -180,6 +180,14 @@ struct rf_channel {
180}; 180};
181 181
182/* 182/*
183 * Antenna setup values.
184 */
185struct antenna_setup {
186 enum antenna rx;
187 enum antenna tx;
188};
189
190/*
183 * Quality statistics about the currently active link. 191 * Quality statistics about the currently active link.
184 */ 192 */
185struct link_qual { 193struct link_qual {
@@ -251,6 +259,13 @@ struct link {
251 struct link_qual qual; 259 struct link_qual qual;
252 260
253 /* 261 /*
262 * Currently active TX/RX antenna setup.
263 * When software diversity is used, this will indicate
264 * which antenna is actually used at this time.
265 */
266 struct antenna_setup active_ant;
267
268 /*
254 * Active VGC level 269 * Active VGC level
255 */ 270 */
256 int vgc_level; 271 int vgc_level;
@@ -272,7 +287,6 @@ static inline void rt2x00_clear_link(struct link *link)
272 link->qual.tx_percentage = 50; 287 link->qual.tx_percentage = 50;
273} 288}
274 289
275
276/* 290/*
277 * Update the rssi using the walking average approach. 291 * Update the rssi using the walking average approach.
278 */ 292 */
@@ -378,6 +392,8 @@ struct rt2x00lib_conf {
378 struct ieee80211_conf *conf; 392 struct ieee80211_conf *conf;
379 struct rf_channel rf; 393 struct rf_channel rf;
380 394
395 struct antenna_setup ant;
396
381 int phymode; 397 int phymode;
382 398
383 int basic_rates; 399 int basic_rates;
@@ -583,6 +599,13 @@ struct rt2x00_dev {
583 struct hw_mode_spec spec; 599 struct hw_mode_spec spec;
584 600
585 /* 601 /*
602 * This is the default TX/RX antenna setup as indicated
603 * by the device's EEPROM. When mac80211 sets its
604 * antenna value to 0 we should be using these values.
605 */
606 struct antenna_setup default_ant;
607
608 /*
586 * Register pointers 609 * Register pointers
587 * csr_addr: Base register address. (PCI) 610 * csr_addr: Base register address. (PCI)
588 * csr_cache: CSR cache for usb_control_msg. (USB) 611 * csr_cache: CSR cache for usb_control_msg. (USB)
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 12914cf7156c..04518b089bdb 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -100,6 +100,8 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
100 struct rt2x00lib_conf libconf; 100 struct rt2x00lib_conf libconf;
101 struct ieee80211_hw_mode *mode; 101 struct ieee80211_hw_mode *mode;
102 struct ieee80211_rate *rate; 102 struct ieee80211_rate *rate;
103 struct antenna_setup *default_ant = &rt2x00dev->default_ant;
104 struct antenna_setup *active_ant = &rt2x00dev->link.active_ant;
103 int flags = 0; 105 int flags = 0;
104 int short_slot_time; 106 int short_slot_time;
105 107
@@ -122,7 +124,35 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
122 flags |= CONFIG_UPDATE_CHANNEL; 124 flags |= CONFIG_UPDATE_CHANNEL;
123 if (rt2x00dev->tx_power != conf->power_level) 125 if (rt2x00dev->tx_power != conf->power_level)
124 flags |= CONFIG_UPDATE_TXPOWER; 126 flags |= CONFIG_UPDATE_TXPOWER;
125 if (rt2x00dev->rx_status.antenna == conf->antenna_sel_rx) 127
128 /*
129 * Determining changes in the antenna setups request several checks:
130 * antenna_sel_{r,t}x = 0
131 * -> Does active_{r,t}x match default_{r,t}x
132 * -> Is default_{r,t}x SW_DIVERSITY
133 * antenna_sel_{r,t}x = 1/2
134 * -> Does active_{r,t}x match antenna_sel_{r,t}x
135 * The reason for not updating the antenna while SW diversity
136 * should be used is simple: Software diversity means that
137 * we should switch between the antenna's based on the
138 * quality. This means that the current antenna is good enough
139 * to work with untill the link tuner decides that an antenna
140 * switch should be performed.
141 */
142 if (!conf->antenna_sel_rx &&
143 default_ant->rx != ANTENNA_SW_DIVERSITY &&
144 default_ant->rx != active_ant->rx)
145 flags |= CONFIG_UPDATE_ANTENNA;
146 else if (conf->antenna_sel_rx &&
147 conf->antenna_sel_rx != active_ant->rx)
148 flags |= CONFIG_UPDATE_ANTENNA;
149
150 if (!conf->antenna_sel_tx &&
151 default_ant->tx != ANTENNA_SW_DIVERSITY &&
152 default_ant->tx != active_ant->tx)
153 flags |= CONFIG_UPDATE_ANTENNA;
154 else if (conf->antenna_sel_tx &&
155 conf->antenna_sel_tx != active_ant->tx)
126 flags |= CONFIG_UPDATE_ANTENNA; 156 flags |= CONFIG_UPDATE_ANTENNA;
127 157
128 /* 158 /*
@@ -171,6 +201,22 @@ config:
171 sizeof(libconf.rf)); 201 sizeof(libconf.rf));
172 } 202 }
173 203
204 if (flags & CONFIG_UPDATE_ANTENNA) {
205 if (conf->antenna_sel_rx)
206 libconf.ant.rx = conf->antenna_sel_rx;
207 else if (default_ant->rx != ANTENNA_SW_DIVERSITY)
208 libconf.ant.rx = default_ant->rx;
209 else if (active_ant->rx == ANTENNA_SW_DIVERSITY)
210 libconf.ant.rx = ANTENNA_B;
211
212 if (conf->antenna_sel_tx)
213 libconf.ant.tx = conf->antenna_sel_tx;
214 else if (default_ant->tx != ANTENNA_SW_DIVERSITY)
215 libconf.ant.tx = default_ant->tx;
216 else if (active_ant->tx == ANTENNA_SW_DIVERSITY)
217 libconf.ant.tx = ANTENNA_B;
218 }
219
174 if (flags & CONFIG_UPDATE_SLOT_TIME) { 220 if (flags & CONFIG_UPDATE_SLOT_TIME) {
175 short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME; 221 short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME;
176 222
@@ -201,5 +247,6 @@ config:
201 rt2x00dev->rx_status.freq = conf->freq; 247 rt2x00dev->rx_status.freq = conf->freq;
202 rt2x00dev->rx_status.channel = conf->channel; 248 rt2x00dev->rx_status.channel = conf->channel;
203 rt2x00dev->tx_power = conf->power_level; 249 rt2x00dev->tx_power = conf->power_level;
204 rt2x00dev->rx_status.antenna = conf->antenna_sel_rx; 250 rt2x00dev->link.active_ant.rx = libconf.ant.rx;
251 rt2x00dev->link.active_ant.tx = libconf.ant.tx;
205} 252}
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 5d32e098696e..b2016f459d3b 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -419,6 +419,7 @@ void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb,
419 rt2x00lib_calculate_link_signal(rt2x00dev, desc->rssi); 419 rt2x00lib_calculate_link_signal(rt2x00dev, desc->rssi);
420 rx_status->ssi = desc->rssi; 420 rx_status->ssi = desc->rssi;
421 rx_status->flag = desc->flags; 421 rx_status->flag = desc->flags;
422 rx_status->antenna = rt2x00dev->link.active_ant.rx;
422 423
423 /* 424 /*
424 * Send frame to mac80211 425 * Send frame to mac80211
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 83b95a675f08..b644a66dcb50 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -411,8 +411,7 @@ static void rt61pci_config_txpower(struct rt2x00_dev *rt2x00dev,
411} 411}
412 412
413static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev, 413static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
414 const int antenna_tx, 414 struct antenna_setup *ant)
415 const int antenna_rx)
416{ 415{
417 u8 r3; 416 u8 r3;
418 u8 r4; 417 u8 r4;
@@ -425,7 +424,7 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
425 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 424 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE,
426 !rt2x00_rf(&rt2x00dev->chip, RF5225)); 425 !rt2x00_rf(&rt2x00dev->chip, RF5225));
427 426
428 switch (antenna_rx) { 427 switch (ant->rx) {
429 case ANTENNA_SW_DIVERSITY: 428 case ANTENNA_SW_DIVERSITY:
430 case ANTENNA_HW_DIVERSITY: 429 case ANTENNA_HW_DIVERSITY:
431 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); 430 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
@@ -458,8 +457,7 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
458} 457}
459 458
460static void rt61pci_config_antenna_2x(struct rt2x00_dev *rt2x00dev, 459static void rt61pci_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
461 const int antenna_tx, 460 struct antenna_setup *ant)
462 const int antenna_rx)
463{ 461{
464 u8 r3; 462 u8 r3;
465 u8 r4; 463 u8 r4;
@@ -474,7 +472,7 @@ static void rt61pci_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
474 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 472 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
475 !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags)); 473 !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags));
476 474
477 switch (antenna_rx) { 475 switch (ant->rx) {
478 case ANTENNA_SW_DIVERSITY: 476 case ANTENNA_SW_DIVERSITY:
479 case ANTENNA_HW_DIVERSITY: 477 case ANTENNA_HW_DIVERSITY:
480 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); 478 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
@@ -514,8 +512,7 @@ static void rt61pci_config_antenna_2529_rx(struct rt2x00_dev *rt2x00dev,
514} 512}
515 513
516static void rt61pci_config_antenna_2529(struct rt2x00_dev *rt2x00dev, 514static void rt61pci_config_antenna_2529(struct rt2x00_dev *rt2x00dev,
517 const int antenna_tx, 515 struct antenna_setup *ant)
518 const int antenna_rx)
519{ 516{
520 u16 eeprom; 517 u16 eeprom;
521 u8 r3; 518 u8 r3;
@@ -625,7 +622,7 @@ static const struct antenna_sel antenna_sel_bg[] = {
625}; 622};
626 623
627static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev, 624static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev,
628 const int antenna_tx, const int antenna_rx) 625 struct antenna_setup *ant)
629{ 626{
630 const struct antenna_sel *sel; 627 const struct antenna_sel *sel;
631 unsigned int lna; 628 unsigned int lna;
@@ -655,16 +652,14 @@ static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev,
655 652
656 if (rt2x00_rf(&rt2x00dev->chip, RF5225) || 653 if (rt2x00_rf(&rt2x00dev->chip, RF5225) ||
657 rt2x00_rf(&rt2x00dev->chip, RF5325)) 654 rt2x00_rf(&rt2x00dev->chip, RF5325))
658 rt61pci_config_antenna_5x(rt2x00dev, antenna_tx, antenna_rx); 655 rt61pci_config_antenna_5x(rt2x00dev, ant);
659 else if (rt2x00_rf(&rt2x00dev->chip, RF2527)) 656 else if (rt2x00_rf(&rt2x00dev->chip, RF2527))
660 rt61pci_config_antenna_2x(rt2x00dev, antenna_tx, antenna_rx); 657 rt61pci_config_antenna_2x(rt2x00dev, ant);
661 else if (rt2x00_rf(&rt2x00dev->chip, RF2529)) { 658 else if (rt2x00_rf(&rt2x00dev->chip, RF2529)) {
662 if (test_bit(CONFIG_DOUBLE_ANTENNA, &rt2x00dev->flags)) 659 if (test_bit(CONFIG_DOUBLE_ANTENNA, &rt2x00dev->flags))
663 rt61pci_config_antenna_2x(rt2x00dev, antenna_tx, 660 rt61pci_config_antenna_2x(rt2x00dev, ant);
664 antenna_rx);
665 else 661 else
666 rt61pci_config_antenna_2529(rt2x00dev, antenna_tx, 662 rt61pci_config_antenna_2529(rt2x00dev, ant);
667 antenna_rx);
668 } 663 }
669} 664}
670 665
@@ -709,8 +704,7 @@ static void rt61pci_config(struct rt2x00_dev *rt2x00dev,
709 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 704 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL))
710 rt61pci_config_txpower(rt2x00dev, libconf->conf->power_level); 705 rt61pci_config_txpower(rt2x00dev, libconf->conf->power_level);
711 if (flags & CONFIG_UPDATE_ANTENNA) 706 if (flags & CONFIG_UPDATE_ANTENNA)
712 rt61pci_config_antenna(rt2x00dev, libconf->conf->antenna_sel_tx, 707 rt61pci_config_antenna(rt2x00dev, &libconf->ant);
713 libconf->conf->antenna_sel_rx);
714 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 708 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
715 rt61pci_config_duration(rt2x00dev, libconf); 709 rt61pci_config_duration(rt2x00dev, libconf);
716} 710}
@@ -2029,9 +2023,9 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
2029 /* 2023 /*
2030 * Identify default antenna configuration. 2024 * Identify default antenna configuration.
2031 */ 2025 */
2032 rt2x00dev->hw->conf.antenna_sel_tx = 2026 rt2x00dev->default_ant.tx =
2033 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT); 2027 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
2034 rt2x00dev->hw->conf.antenna_sel_rx = 2028 rt2x00dev->default_ant.rx =
2035 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT); 2029 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
2036 2030
2037 /* 2031 /*
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 96d85aaf4250..92c78968a0b9 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -396,8 +396,7 @@ static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev,
396} 396}
397 397
398static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, 398static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
399 const int antenna_tx, 399 struct antenna_setup *ant)
400 const int antenna_rx)
401{ 400{
402 u8 r3; 401 u8 r3;
403 u8 r4; 402 u8 r4;
@@ -409,7 +408,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
409 408
410 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 0); 409 rt2x00_set_field8(&r3, BBP_R3_SMART_MODE, 0);
411 410
412 switch (antenna_rx) { 411 switch (ant->rx) {
413 case ANTENNA_SW_DIVERSITY: 412 case ANTENNA_SW_DIVERSITY:
414 case ANTENNA_HW_DIVERSITY: 413 case ANTENNA_HW_DIVERSITY:
415 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); 414 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
@@ -442,8 +441,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
442} 441}
443 442
444static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev, 443static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
445 const int antenna_tx, 444 struct antenna_setup *ant)
446 const int antenna_rx)
447{ 445{
448 u8 r3; 446 u8 r3;
449 u8 r4; 447 u8 r4;
@@ -457,7 +455,7 @@ static void rt73usb_config_antenna_2x(struct rt2x00_dev *rt2x00dev,
457 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 455 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
458 !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags)); 456 !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags));
459 457
460 switch (antenna_rx) { 458 switch (ant->rx) {
461 case ANTENNA_SW_DIVERSITY: 459 case ANTENNA_SW_DIVERSITY:
462 case ANTENNA_HW_DIVERSITY: 460 case ANTENNA_HW_DIVERSITY:
463 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2); 461 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA, 2);
@@ -509,7 +507,7 @@ static const struct antenna_sel antenna_sel_bg[] = {
509}; 507};
510 508
511static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev, 509static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
512 const int antenna_tx, const int antenna_rx) 510 struct antenna_setup *ant)
513{ 511{
514 const struct antenna_sel *sel; 512 const struct antenna_sel *sel;
515 unsigned int lna; 513 unsigned int lna;
@@ -539,10 +537,10 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
539 537
540 if (rt2x00_rf(&rt2x00dev->chip, RF5226) || 538 if (rt2x00_rf(&rt2x00dev->chip, RF5226) ||
541 rt2x00_rf(&rt2x00dev->chip, RF5225)) 539 rt2x00_rf(&rt2x00dev->chip, RF5225))
542 rt73usb_config_antenna_5x(rt2x00dev, antenna_tx, antenna_rx); 540 rt73usb_config_antenna_5x(rt2x00dev, ant);
543 else if (rt2x00_rf(&rt2x00dev->chip, RF2528) || 541 else if (rt2x00_rf(&rt2x00dev->chip, RF2528) ||
544 rt2x00_rf(&rt2x00dev->chip, RF2527)) 542 rt2x00_rf(&rt2x00dev->chip, RF2527))
545 rt73usb_config_antenna_2x(rt2x00dev, antenna_tx, antenna_rx); 543 rt73usb_config_antenna_2x(rt2x00dev, ant);
546} 544}
547 545
548static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev, 546static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev,
@@ -586,8 +584,7 @@ static void rt73usb_config(struct rt2x00_dev *rt2x00dev,
586 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 584 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL))
587 rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level); 585 rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level);
588 if (flags & CONFIG_UPDATE_ANTENNA) 586 if (flags & CONFIG_UPDATE_ANTENNA)
589 rt73usb_config_antenna(rt2x00dev, libconf->conf->antenna_sel_tx, 587 rt73usb_config_antenna(rt2x00dev, &libconf->ant);
590 libconf->conf->antenna_sel_rx);
591 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 588 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
592 rt73usb_config_duration(rt2x00dev, libconf); 589 rt73usb_config_duration(rt2x00dev, libconf);
593} 590}
@@ -1503,9 +1500,9 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1503 /* 1500 /*
1504 * Identify default antenna configuration. 1501 * Identify default antenna configuration.
1505 */ 1502 */
1506 rt2x00dev->hw->conf.antenna_sel_tx = 1503 rt2x00dev->default_ant.tx =
1507 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT); 1504 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TX_DEFAULT);
1508 rt2x00dev->hw->conf.antenna_sel_rx = 1505 rt2x00dev->default_ant.rx =
1509 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT); 1506 rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RX_DEFAULT);
1510 1507
1511 /* 1508 /*