aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-01-24 13:38:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:19:32 -0500
commit8318d78a44d49ac1edf2bdec7299de3617c4232e (patch)
treed434634418edd7399737801615d247be06616fdd /drivers/net/wireless/rt2x00
parent10b6b80145cc93887dd8aab99bfffa375e9add31 (diff)
cfg80211 API for channels/bitrates, mac80211 and driver conversion
This patch creates new cfg80211 wiphy API for channel and bitrate registration and converts mac80211 and drivers to the new API. The old mac80211 API is completely ripped out. All drivers (except ath5k) are updated to the new API, in many cases I expect that optimisations can be done. Along with the regulatory code I've also ripped out the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag, I believe it to be unnecessary if the hardware simply gives us whatever channels it wants to support and we then enable/disable them as required, which is pretty much required for travelling. Additionally, the patch adds proper "basic" rate handling for STA mode interface, AP mode interface will have to have new API added to allow userspace to set the basic rate set, currently it'll be empty... However, the basic rate handling will need to be moved to the BSS conf stuff. I do expect there to be bugs in this, especially wrt. transmit power handling where I'm basically clueless about how it should work. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c33
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c149
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c23
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c23
5 files changed, 104 insertions, 135 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index b0e4ea7c9dca..4fa762bdb734 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -390,6 +390,10 @@ static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
390 return (struct rt2x00_intf *)vif->drv_priv; 390 return (struct rt2x00_intf *)vif->drv_priv;
391} 391}
392 392
393#define HWMODE_B 0
394#define HWMODE_G 1
395#define HWMODE_A 2
396
393/* 397/*
394 * Details about the supported modes, rates and channels 398 * Details about the supported modes, rates and channels
395 * of a particular chipset. This is used by rt2x00lib 399 * of a particular chipset. This is used by rt2x00lib
@@ -644,11 +648,8 @@ struct rt2x00_dev {
644 * IEEE80211 control structure. 648 * IEEE80211 control structure.
645 */ 649 */
646 struct ieee80211_hw *hw; 650 struct ieee80211_hw *hw;
647 struct ieee80211_hw_mode *hwmodes; 651 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
648 unsigned int curr_hwmode; 652 enum ieee80211_band curr_band;
649#define HWMODE_B 0
650#define HWMODE_G 1
651#define HWMODE_A 2
652 653
653 /* 654 /*
654 * rfkill structure for RF state switching support. 655 * rfkill structure for RF state switching support.
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index 20231e0c53fa..9fba485a40ac 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -152,7 +152,7 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
152 struct ieee80211_conf *conf, const int force_config) 152 struct ieee80211_conf *conf, const int force_config)
153{ 153{
154 struct rt2x00lib_conf libconf; 154 struct rt2x00lib_conf libconf;
155 struct ieee80211_hw_mode *mode; 155 struct ieee80211_supported_band *band;
156 struct ieee80211_rate *rate; 156 struct ieee80211_rate *rate;
157 struct antenna_setup *default_ant = &rt2x00dev->default_ant; 157 struct antenna_setup *default_ant = &rt2x00dev->default_ant;
158 struct antenna_setup *active_ant = &rt2x00dev->link.ant.active; 158 struct antenna_setup *active_ant = &rt2x00dev->link.ant.active;
@@ -172,9 +172,9 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
172 * Check which configuration options have been 172 * Check which configuration options have been
173 * updated and should be send to the device. 173 * updated and should be send to the device.
174 */ 174 */
175 if (rt2x00dev->rx_status.phymode != conf->phymode) 175 if (rt2x00dev->rx_status.band != conf->channel->band)
176 flags |= CONFIG_UPDATE_PHYMODE; 176 flags |= CONFIG_UPDATE_PHYMODE;
177 if (rt2x00dev->rx_status.channel != conf->channel) 177 if (rt2x00dev->rx_status.freq != conf->channel->center_freq)
178 flags |= CONFIG_UPDATE_CHANNEL; 178 flags |= CONFIG_UPDATE_CHANNEL;
179 if (rt2x00dev->tx_power != conf->power_level) 179 if (rt2x00dev->tx_power != conf->power_level)
180 flags |= CONFIG_UPDATE_TXPOWER; 180 flags |= CONFIG_UPDATE_TXPOWER;
@@ -229,33 +229,31 @@ config:
229 memset(&libconf, 0, sizeof(libconf)); 229 memset(&libconf, 0, sizeof(libconf));
230 230
231 if (flags & CONFIG_UPDATE_PHYMODE) { 231 if (flags & CONFIG_UPDATE_PHYMODE) {
232 switch (conf->phymode) { 232 switch (conf->channel->band) {
233 case MODE_IEEE80211A: 233 case IEEE80211_BAND_5GHZ:
234 libconf.phymode = HWMODE_A; 234 libconf.phymode = HWMODE_A;
235 break; 235 break;
236 case MODE_IEEE80211B: 236 case IEEE80211_BAND_2GHZ:
237 libconf.phymode = HWMODE_B; 237 /* Uh oh. what about B? */
238 break;
239 case MODE_IEEE80211G:
240 libconf.phymode = HWMODE_G; 238 libconf.phymode = HWMODE_G;
241 break; 239 break;
242 default: 240 default:
243 ERROR(rt2x00dev, 241 ERROR(rt2x00dev,
244 "Attempt to configure unsupported mode (%d)" 242 "Attempt to configure unsupported mode (%d)"
245 "Defaulting to 802.11b", conf->phymode); 243 "Defaulting to 802.11b", conf->channel->band);
246 libconf.phymode = HWMODE_B; 244 libconf.phymode = HWMODE_B;
247 } 245 }
248 246
249 mode = &rt2x00dev->hwmodes[libconf.phymode]; 247 band = &rt2x00dev->bands[conf->channel->band];
250 rate = &mode->rates[mode->num_rates - 1]; 248 rate = &band->bitrates[band->n_bitrates - 1];
251 249
252 libconf.basic_rates = 250 libconf.basic_rates =
253 DEVICE_GET_RATE_FIELD(rate->val, RATEMASK) & DEV_BASIC_RATEMASK; 251 DEVICE_GET_RATE_FIELD(rate->hw_value, RATEMASK) & DEV_BASIC_RATEMASK;
254 } 252 }
255 253
256 if (flags & CONFIG_UPDATE_CHANNEL) { 254 if (flags & CONFIG_UPDATE_CHANNEL) {
257 memcpy(&libconf.rf, 255 memcpy(&libconf.rf,
258 &rt2x00dev->spec.channels[conf->channel_val], 256 &rt2x00dev->spec.channels[conf->channel->hw_value],
259 sizeof(libconf.rf)); 257 sizeof(libconf.rf));
260 } 258 }
261 259
@@ -301,12 +299,11 @@ config:
301 rt2x00lib_reset_link_tuner(rt2x00dev); 299 rt2x00lib_reset_link_tuner(rt2x00dev);
302 300
303 if (flags & CONFIG_UPDATE_PHYMODE) { 301 if (flags & CONFIG_UPDATE_PHYMODE) {
304 rt2x00dev->curr_hwmode = libconf.phymode; 302 rt2x00dev->curr_band = conf->channel->band;
305 rt2x00dev->rx_status.phymode = conf->phymode; 303 rt2x00dev->rx_status.band = conf->channel->band;
306 } 304 }
307 305
308 rt2x00dev->rx_status.freq = conf->freq; 306 rt2x00dev->rx_status.freq = conf->channel->center_freq;
309 rt2x00dev->rx_status.channel = conf->channel;
310 rt2x00dev->tx_power = conf->power_level; 307 rt2x00dev->tx_power = conf->power_level;
311 308
312 if (flags & CONFIG_UPDATE_ANTENNA) { 309 if (flags & CONFIG_UPDATE_ANTENNA) {
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 0df8062b1a8e..83a72ae36638 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -550,19 +550,19 @@ void rt2x00lib_rxdone(struct queue_entry *entry,
550{ 550{
551 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 551 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
552 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status; 552 struct ieee80211_rx_status *rx_status = &rt2x00dev->rx_status;
553 struct ieee80211_hw_mode *mode; 553 struct ieee80211_supported_band *sband;
554 struct ieee80211_rate *rate; 554 struct ieee80211_rate *rate;
555 struct ieee80211_hdr *hdr; 555 struct ieee80211_hdr *hdr;
556 unsigned int i; 556 unsigned int i;
557 int val = 0; 557 int val = 0, idx = -1;
558 u16 fc; 558 u16 fc;
559 559
560 /* 560 /*
561 * Update RX statistics. 561 * Update RX statistics.
562 */ 562 */
563 mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode]; 563 sband = &rt2x00dev->bands[rt2x00dev->curr_band];
564 for (i = 0; i < mode->num_rates; i++) { 564 for (i = 0; i < sband->n_bitrates; i++) {
565 rate = &mode->rates[i]; 565 rate = &sband->bitrates[i];
566 566
567 /* 567 /*
568 * When frame was received with an OFDM bitrate, 568 * When frame was received with an OFDM bitrate,
@@ -570,12 +570,12 @@ void rt2x00lib_rxdone(struct queue_entry *entry,
570 * a CCK bitrate the signal is the rate in 0.5kbit/s. 570 * a CCK bitrate the signal is the rate in 0.5kbit/s.
571 */ 571 */
572 if (!rxdesc->ofdm) 572 if (!rxdesc->ofdm)
573 val = DEVICE_GET_RATE_FIELD(rate->val, RATE); 573 val = DEVICE_GET_RATE_FIELD(rate->hw_value, RATE);
574 else 574 else
575 val = DEVICE_GET_RATE_FIELD(rate->val, PLCP); 575 val = DEVICE_GET_RATE_FIELD(rate->hw_value, PLCP);
576 576
577 if (val == rxdesc->signal) { 577 if (val == rxdesc->signal) {
578 val = rate->val; 578 idx = i;
579 break; 579 break;
580 } 580 }
581 } 581 }
@@ -590,7 +590,7 @@ void rt2x00lib_rxdone(struct queue_entry *entry,
590 590
591 rt2x00dev->link.qual.rx_success++; 591 rt2x00dev->link.qual.rx_success++;
592 592
593 rx_status->rate = val; 593 rx_status->rate_idx = idx;
594 rx_status->signal = 594 rx_status->signal =
595 rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi); 595 rt2x00lib_calculate_link_signal(rt2x00dev, rxdesc->rssi);
596 rx_status->ssi = rxdesc->rssi; 596 rx_status->ssi = rxdesc->rssi;
@@ -639,7 +639,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
639 frame_control = le16_to_cpu(ieee80211hdr->frame_control); 639 frame_control = le16_to_cpu(ieee80211hdr->frame_control);
640 seq_ctrl = le16_to_cpu(ieee80211hdr->seq_ctrl); 640 seq_ctrl = le16_to_cpu(ieee80211hdr->seq_ctrl);
641 641
642 tx_rate = control->tx_rate; 642 tx_rate = control->tx_rate->hw_value;
643 643
644 /* 644 /*
645 * Check whether this frame is to be acked 645 * Check whether this frame is to be acked
@@ -658,7 +658,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
658 } else 658 } else
659 __clear_bit(ENTRY_TXD_ACK, &txdesc.flags); 659 __clear_bit(ENTRY_TXD_ACK, &txdesc.flags);
660 if (control->rts_cts_rate) 660 if (control->rts_cts_rate)
661 tx_rate = control->rts_cts_rate; 661 tx_rate = control->rts_cts_rate->hw_value;
662 } 662 }
663 663
664 /* 664 /*
@@ -760,54 +760,45 @@ static void rt2x00lib_channel(struct ieee80211_channel *entry,
760 const int channel, const int tx_power, 760 const int channel, const int tx_power,
761 const int value) 761 const int value)
762{ 762{
763 entry->chan = channel;
764 if (channel <= 14) 763 if (channel <= 14)
765 entry->freq = 2407 + (5 * channel); 764 entry->center_freq = 2407 + (5 * channel);
766 else 765 else
767 entry->freq = 5000 + (5 * channel); 766 entry->center_freq = 5000 + (5 * channel);
768 entry->val = value; 767 entry->hw_value = value;
769 entry->flag = 768 entry->max_power = tx_power;
770 IEEE80211_CHAN_W_IBSS | 769 entry->max_antenna_gain = 0xff;
771 IEEE80211_CHAN_W_ACTIVE_SCAN |
772 IEEE80211_CHAN_W_SCAN;
773 entry->power_level = tx_power;
774 entry->antenna_max = 0xff;
775} 770}
776 771
777static void rt2x00lib_rate(struct ieee80211_rate *entry, 772static void rt2x00lib_rate(struct ieee80211_rate *entry,
778 const int rate, const int mask, 773 const int rate, const int mask,
779 const int plcp, const int flags) 774 const int plcp, const int flags)
780{ 775{
781 entry->rate = rate; 776 entry->bitrate = rate;
782 entry->val = 777 entry->hw_value =
783 DEVICE_SET_RATE_FIELD(rate, RATE) | 778 DEVICE_SET_RATE_FIELD(rate, RATE) |
784 DEVICE_SET_RATE_FIELD(mask, RATEMASK) | 779 DEVICE_SET_RATE_FIELD(mask, RATEMASK) |
785 DEVICE_SET_RATE_FIELD(plcp, PLCP); 780 DEVICE_SET_RATE_FIELD(plcp, PLCP);
786 entry->flags = flags; 781 entry->flags = flags;
787 entry->val2 = entry->val; 782 entry->hw_value_short = entry->hw_value;
788 if (entry->flags & IEEE80211_RATE_PREAMBLE2) 783 if (entry->flags & IEEE80211_RATE_SHORT_PREAMBLE)
789 entry->val2 |= DEVICE_SET_RATE_FIELD(1, PREAMBLE); 784 entry->hw_value_short |= DEVICE_SET_RATE_FIELD(1, PREAMBLE);
790 entry->min_rssi_ack = 0;
791 entry->min_rssi_ack_delta = 0;
792} 785}
793 786
794static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, 787static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
795 struct hw_mode_spec *spec) 788 struct hw_mode_spec *spec)
796{ 789{
797 struct ieee80211_hw *hw = rt2x00dev->hw; 790 struct ieee80211_hw *hw = rt2x00dev->hw;
798 struct ieee80211_hw_mode *hwmodes; 791 struct ieee80211_supported_band *sbands;
799 struct ieee80211_channel *channels; 792 struct ieee80211_channel *channels;
800 struct ieee80211_rate *rates; 793 struct ieee80211_rate *rates;
801 unsigned int i; 794 unsigned int i;
802 unsigned char tx_power; 795 unsigned char tx_power;
803 796
804 hwmodes = kzalloc(sizeof(*hwmodes) * spec->num_modes, GFP_KERNEL); 797 sbands = &rt2x00dev->bands[0];
805 if (!hwmodes)
806 goto exit;
807 798
808 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); 799 channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL);
809 if (!channels) 800 if (!channels)
810 goto exit_free_modes; 801 return -ENOMEM;
811 802
812 rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL); 803 rates = kzalloc(sizeof(*rates) * spec->num_rates, GFP_KERNEL);
813 if (!rates) 804 if (!rates)
@@ -817,31 +808,31 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
817 * Initialize Rate list. 808 * Initialize Rate list.
818 */ 809 */
819 rt2x00lib_rate(&rates[0], 10, DEV_RATEMASK_1MB, 810 rt2x00lib_rate(&rates[0], 10, DEV_RATEMASK_1MB,
820 0x00, IEEE80211_RATE_CCK); 811 0x00, 0);
821 rt2x00lib_rate(&rates[1], 20, DEV_RATEMASK_2MB, 812 rt2x00lib_rate(&rates[1], 20, DEV_RATEMASK_2MB,
822 0x01, IEEE80211_RATE_CCK_2); 813 0x01, IEEE80211_RATE_SHORT_PREAMBLE);
823 rt2x00lib_rate(&rates[2], 55, DEV_RATEMASK_5_5MB, 814 rt2x00lib_rate(&rates[2], 55, DEV_RATEMASK_5_5MB,
824 0x02, IEEE80211_RATE_CCK_2); 815 0x02, IEEE80211_RATE_SHORT_PREAMBLE);
825 rt2x00lib_rate(&rates[3], 110, DEV_RATEMASK_11MB, 816 rt2x00lib_rate(&rates[3], 110, DEV_RATEMASK_11MB,
826 0x03, IEEE80211_RATE_CCK_2); 817 0x03, IEEE80211_RATE_SHORT_PREAMBLE);
827 818
828 if (spec->num_rates > 4) { 819 if (spec->num_rates > 4) {
829 rt2x00lib_rate(&rates[4], 60, DEV_RATEMASK_6MB, 820 rt2x00lib_rate(&rates[4], 60, DEV_RATEMASK_6MB,
830 0x0b, IEEE80211_RATE_OFDM); 821 0x0b, 0);
831 rt2x00lib_rate(&rates[5], 90, DEV_RATEMASK_9MB, 822 rt2x00lib_rate(&rates[5], 90, DEV_RATEMASK_9MB,
832 0x0f, IEEE80211_RATE_OFDM); 823 0x0f, 0);
833 rt2x00lib_rate(&rates[6], 120, DEV_RATEMASK_12MB, 824 rt2x00lib_rate(&rates[6], 120, DEV_RATEMASK_12MB,
834 0x0a, IEEE80211_RATE_OFDM); 825 0x0a, 0);
835 rt2x00lib_rate(&rates[7], 180, DEV_RATEMASK_18MB, 826 rt2x00lib_rate(&rates[7], 180, DEV_RATEMASK_18MB,
836 0x0e, IEEE80211_RATE_OFDM); 827 0x0e, 0);
837 rt2x00lib_rate(&rates[8], 240, DEV_RATEMASK_24MB, 828 rt2x00lib_rate(&rates[8], 240, DEV_RATEMASK_24MB,
838 0x09, IEEE80211_RATE_OFDM); 829 0x09, 0);
839 rt2x00lib_rate(&rates[9], 360, DEV_RATEMASK_36MB, 830 rt2x00lib_rate(&rates[9], 360, DEV_RATEMASK_36MB,
840 0x0d, IEEE80211_RATE_OFDM); 831 0x0d, 0);
841 rt2x00lib_rate(&rates[10], 480, DEV_RATEMASK_48MB, 832 rt2x00lib_rate(&rates[10], 480, DEV_RATEMASK_48MB,
842 0x08, IEEE80211_RATE_OFDM); 833 0x08, 0);
843 rt2x00lib_rate(&rates[11], 540, DEV_RATEMASK_54MB, 834 rt2x00lib_rate(&rates[11], 540, DEV_RATEMASK_54MB,
844 0x0c, IEEE80211_RATE_OFDM); 835 0x0c, 0);
845 } 836 }
846 837
847 /* 838 /*
@@ -862,27 +853,27 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
862 /* 853 /*
863 * Intitialize 802.11b 854 * Intitialize 802.11b
864 * Rates: CCK. 855 * Rates: CCK.
865 * Channels: OFDM. 856 * Channels: 2.4 GHz
866 */ 857 */
867 if (spec->num_modes > HWMODE_B) { 858 if (spec->num_modes > HWMODE_B) {
868 hwmodes[HWMODE_B].mode = MODE_IEEE80211B; 859 sbands[IEEE80211_BAND_2GHZ].n_channels = 14;
869 hwmodes[HWMODE_B].num_channels = 14; 860 sbands[IEEE80211_BAND_2GHZ].n_bitrates = 4;
870 hwmodes[HWMODE_B].num_rates = 4; 861 sbands[IEEE80211_BAND_2GHZ].channels = channels;
871 hwmodes[HWMODE_B].channels = channels; 862 sbands[IEEE80211_BAND_2GHZ].bitrates = rates;
872 hwmodes[HWMODE_B].rates = rates; 863 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ];
873 } 864 }
874 865
875 /* 866 /*
876 * Intitialize 802.11g 867 * Intitialize 802.11g
877 * Rates: CCK, OFDM. 868 * Rates: CCK, OFDM.
878 * Channels: OFDM. 869 * Channels: 2.4 GHz
879 */ 870 */
880 if (spec->num_modes > HWMODE_G) { 871 if (spec->num_modes > HWMODE_G) {
881 hwmodes[HWMODE_G].mode = MODE_IEEE80211G; 872 sbands[IEEE80211_BAND_2GHZ].n_channels = 14;
882 hwmodes[HWMODE_G].num_channels = 14; 873 sbands[IEEE80211_BAND_2GHZ].n_bitrates = spec->num_rates;
883 hwmodes[HWMODE_G].num_rates = spec->num_rates; 874 sbands[IEEE80211_BAND_2GHZ].channels = channels;
884 hwmodes[HWMODE_G].channels = channels; 875 sbands[IEEE80211_BAND_2GHZ].bitrates = rates;
885 hwmodes[HWMODE_G].rates = rates; 876 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &rt2x00dev->bands[IEEE80211_BAND_2GHZ];
886 } 877 }
887 878
888 /* 879 /*
@@ -891,39 +882,17 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
891 * Channels: OFDM, UNII, HiperLAN2. 882 * Channels: OFDM, UNII, HiperLAN2.
892 */ 883 */
893 if (spec->num_modes > HWMODE_A) { 884 if (spec->num_modes > HWMODE_A) {
894 hwmodes[HWMODE_A].mode = MODE_IEEE80211A; 885 sbands[IEEE80211_BAND_5GHZ].n_channels = spec->num_channels - 14;
895 hwmodes[HWMODE_A].num_channels = spec->num_channels - 14; 886 sbands[IEEE80211_BAND_5GHZ].n_bitrates = spec->num_rates - 4;
896 hwmodes[HWMODE_A].num_rates = spec->num_rates - 4; 887 sbands[IEEE80211_BAND_5GHZ].channels = &channels[14];
897 hwmodes[HWMODE_A].channels = &channels[14]; 888 sbands[IEEE80211_BAND_5GHZ].bitrates = &rates[4];
898 hwmodes[HWMODE_A].rates = &rates[4]; 889 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &rt2x00dev->bands[IEEE80211_BAND_5GHZ];
899 } 890 }
900 891
901 if (spec->num_modes > HWMODE_G &&
902 ieee80211_register_hwmode(hw, &hwmodes[HWMODE_G]))
903 goto exit_free_rates;
904
905 if (spec->num_modes > HWMODE_B &&
906 ieee80211_register_hwmode(hw, &hwmodes[HWMODE_B]))
907 goto exit_free_rates;
908
909 if (spec->num_modes > HWMODE_A &&
910 ieee80211_register_hwmode(hw, &hwmodes[HWMODE_A]))
911 goto exit_free_rates;
912
913 rt2x00dev->hwmodes = hwmodes;
914
915 return 0; 892 return 0;
916 893
917exit_free_rates: 894 exit_free_channels:
918 kfree(rates);
919
920exit_free_channels:
921 kfree(channels); 895 kfree(channels);
922
923exit_free_modes:
924 kfree(hwmodes);
925
926exit:
927 ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n"); 896 ERROR(rt2x00dev, "Allocation ieee80211 modes failed.\n");
928 return -ENOMEM; 897 return -ENOMEM;
929} 898}
@@ -933,11 +902,11 @@ static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev)
933 if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags)) 902 if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags))
934 ieee80211_unregister_hw(rt2x00dev->hw); 903 ieee80211_unregister_hw(rt2x00dev->hw);
935 904
936 if (likely(rt2x00dev->hwmodes)) { 905 if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) {
937 kfree(rt2x00dev->hwmodes->channels); 906 kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->channels);
938 kfree(rt2x00dev->hwmodes->rates); 907 kfree(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ]->bitrates);
939 kfree(rt2x00dev->hwmodes); 908 rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL;
940 rt2x00dev->hwmodes = NULL; 909 rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
941 } 910 }
942} 911}
943 912
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 59e87a1d96a4..1dd30510ed1e 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -426,12 +426,12 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
426 case ANTENNA_HW_DIVERSITY: 426 case ANTENNA_HW_DIVERSITY:
427 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); 427 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2);
428 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 428 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END,
429 (rt2x00dev->curr_hwmode != HWMODE_A)); 429 (rt2x00dev->curr_band != IEEE80211_BAND_5GHZ));
430 break; 430 break;
431 case ANTENNA_A: 431 case ANTENNA_A:
432 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 432 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
433 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); 433 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0);
434 if (rt2x00dev->curr_hwmode == HWMODE_A) 434 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)
435 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); 435 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0);
436 else 436 else
437 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); 437 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3);
@@ -446,7 +446,7 @@ static void rt61pci_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
446 case ANTENNA_B: 446 case ANTENNA_B:
447 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 447 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
448 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); 448 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0);
449 if (rt2x00dev->curr_hwmode == HWMODE_A) 449 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)
450 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); 450 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3);
451 else 451 else
452 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); 452 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0);
@@ -602,7 +602,7 @@ static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev,
602 unsigned int i; 602 unsigned int i;
603 u32 reg; 603 u32 reg;
604 604
605 if (rt2x00dev->curr_hwmode == HWMODE_A) { 605 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) {
606 sel = antenna_sel_a; 606 sel = antenna_sel_a;
607 lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); 607 lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
608 } else { 608 } else {
@@ -616,10 +616,9 @@ static void rt61pci_config_antenna(struct rt2x00_dev *rt2x00dev,
616 rt2x00pci_register_read(rt2x00dev, PHY_CSR0, &reg); 616 rt2x00pci_register_read(rt2x00dev, PHY_CSR0, &reg);
617 617
618 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 618 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG,
619 (rt2x00dev->curr_hwmode == HWMODE_B || 619 rt2x00dev->curr_band == IEEE80211_BAND_2GHZ);
620 rt2x00dev->curr_hwmode == HWMODE_G));
621 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 620 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A,
622 (rt2x00dev->curr_hwmode == HWMODE_A)); 621 rt2x00dev->curr_band == IEEE80211_BAND_5GHZ);
623 622
624 rt2x00pci_register_write(rt2x00dev, PHY_CSR0, reg); 623 rt2x00pci_register_write(rt2x00dev, PHY_CSR0, reg);
625 624
@@ -698,9 +697,9 @@ static void rt61pci_enable_led(struct rt2x00_dev *rt2x00dev)
698 697
699 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); 698 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1);
700 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, 699 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS,
701 (rt2x00dev->rx_status.phymode == MODE_IEEE80211A)); 700 rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ);
702 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, 701 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS,
703 (rt2x00dev->rx_status.phymode != MODE_IEEE80211A)); 702 rt2x00dev->rx_status.band != IEEE80211_BAND_5GHZ);
704 703
705 arg0 = rt2x00dev->led_reg & 0xff; 704 arg0 = rt2x00dev->led_reg & 0xff;
706 arg1 = (rt2x00dev->led_reg >> 8) & 0xff; 705 arg1 = (rt2x00dev->led_reg >> 8) & 0xff;
@@ -798,7 +797,7 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
798 /* 797 /*
799 * Determine r17 bounds. 798 * Determine r17 bounds.
800 */ 799 */
801 if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 800 if (rt2x00dev->rx_status.band == IEEE80211_BAND_2GHZ) {
802 low_bound = 0x28; 801 low_bound = 0x28;
803 up_bound = 0x48; 802 up_bound = 0x48;
804 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { 803 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) {
@@ -1544,8 +1543,10 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1544 rt2x00_desc_write(txd, 2, word); 1543 rt2x00_desc_write(txd, 2, word);
1545 1544
1546 rt2x00_desc_read(txd, 5, &word); 1545 rt2x00_desc_read(txd, 5, &word);
1546/* XXX: removed for now
1547 rt2x00_set_field32(&word, TXD_W5_TX_POWER, 1547 rt2x00_set_field32(&word, TXD_W5_TX_POWER,
1548 TXPOWER_TO_DEV(control->power_level)); 1548 TXPOWER_TO_DEV(control->power_level));
1549 */
1549 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); 1550 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
1550 rt2x00_desc_write(txd, 5, word); 1551 rt2x00_desc_write(txd, 5, word);
1551 1552
@@ -1637,7 +1638,7 @@ static int rt61pci_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1637 return 0; 1638 return 0;
1638 } 1639 }
1639 1640
1640 if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 1641 if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) {
1641 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) 1642 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
1642 offset += 14; 1643 offset += 14;
1643 1644
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 4b5bde8b53de..9cbc879da037 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -439,13 +439,13 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
439 case ANTENNA_HW_DIVERSITY: 439 case ANTENNA_HW_DIVERSITY:
440 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2); 440 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 2);
441 temp = !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags) 441 temp = !test_bit(CONFIG_FRAME_TYPE, &rt2x00dev->flags)
442 && (rt2x00dev->curr_hwmode != HWMODE_A); 442 && (rt2x00dev->curr_band != IEEE80211_BAND_5GHZ);
443 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, temp); 443 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, temp);
444 break; 444 break;
445 case ANTENNA_A: 445 case ANTENNA_A:
446 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 446 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
447 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); 447 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0);
448 if (rt2x00dev->curr_hwmode == HWMODE_A) 448 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)
449 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); 449 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0);
450 else 450 else
451 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); 451 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3);
@@ -460,7 +460,7 @@ static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev,
460 case ANTENNA_B: 460 case ANTENNA_B:
461 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1); 461 rt2x00_set_field8(&r4, BBP_R4_RX_ANTENNA_CONTROL, 1);
462 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0); 462 rt2x00_set_field8(&r4, BBP_R4_RX_FRAME_END, 0);
463 if (rt2x00dev->curr_hwmode == HWMODE_A) 463 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ)
464 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3); 464 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 3);
465 else 465 else
466 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0); 466 rt2x00_set_field8(&r77, BBP_R77_RX_ANTENNA, 0);
@@ -555,7 +555,7 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
555 unsigned int i; 555 unsigned int i;
556 u32 reg; 556 u32 reg;
557 557
558 if (rt2x00dev->curr_hwmode == HWMODE_A) { 558 if (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ) {
559 sel = antenna_sel_a; 559 sel = antenna_sel_a;
560 lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); 560 lna = test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
561 } else { 561 } else {
@@ -569,10 +569,9 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev,
569 rt73usb_register_read(rt2x00dev, PHY_CSR0, &reg); 569 rt73usb_register_read(rt2x00dev, PHY_CSR0, &reg);
570 570
571 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG, 571 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_BG,
572 (rt2x00dev->curr_hwmode == HWMODE_B || 572 (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ));
573 rt2x00dev->curr_hwmode == HWMODE_G));
574 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A, 573 rt2x00_set_field32(&reg, PHY_CSR0_PA_PE_A,
575 (rt2x00dev->curr_hwmode == HWMODE_A)); 574 (rt2x00dev->curr_band == IEEE80211_BAND_5GHZ));
576 575
577 rt73usb_register_write(rt2x00dev, PHY_CSR0, reg); 576 rt73usb_register_write(rt2x00dev, PHY_CSR0, reg);
578 577
@@ -644,9 +643,9 @@ static void rt73usb_enable_led(struct rt2x00_dev *rt2x00dev)
644 643
645 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1); 644 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_RADIO_STATUS, 1);
646 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS, 645 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_A_STATUS,
647 (rt2x00dev->rx_status.phymode == MODE_IEEE80211A)); 646 (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ));
648 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS, 647 rt2x00_set_field16(&rt2x00dev->led_reg, MCU_LEDCS_LINK_BG_STATUS,
649 (rt2x00dev->rx_status.phymode != MODE_IEEE80211A)); 648 (rt2x00dev->rx_status.band != IEEE80211_BAND_5GHZ));
650 649
651 rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000, 650 rt2x00usb_vendor_request_sw(rt2x00dev, USB_LED_CONTROL, 0x0000,
652 rt2x00dev->led_reg, REGISTER_TIMEOUT); 651 rt2x00dev->led_reg, REGISTER_TIMEOUT);
@@ -736,7 +735,7 @@ static void rt73usb_link_tuner(struct rt2x00_dev *rt2x00dev)
736 /* 735 /*
737 * Determine r17 bounds. 736 * Determine r17 bounds.
738 */ 737 */
739 if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 738 if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) {
740 low_bound = 0x28; 739 low_bound = 0x28;
741 up_bound = 0x48; 740 up_bound = 0x48;
742 741
@@ -1278,8 +1277,10 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1278 rt2x00_desc_write(txd, 2, word); 1277 rt2x00_desc_write(txd, 2, word);
1279 1278
1280 rt2x00_desc_read(txd, 5, &word); 1279 rt2x00_desc_read(txd, 5, &word);
1280/* XXX: removed for now
1281 rt2x00_set_field32(&word, TXD_W5_TX_POWER, 1281 rt2x00_set_field32(&word, TXD_W5_TX_POWER,
1282 TXPOWER_TO_DEV(control->power_level)); 1282 TXPOWER_TO_DEV(control->power_level));
1283 */
1283 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); 1284 rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1);
1284 rt2x00_desc_write(txd, 5, word); 1285 rt2x00_desc_write(txd, 5, word);
1285 1286
@@ -1370,7 +1371,7 @@ static int rt73usb_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1)
1370 return 0; 1371 return 0;
1371 } 1372 }
1372 1373
1373 if (rt2x00dev->rx_status.phymode == MODE_IEEE80211A) { 1374 if (rt2x00dev->rx_status.band == IEEE80211_BAND_5GHZ) {
1374 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) { 1375 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) {
1375 if (lna == 3 || lna == 2) 1376 if (lna == 3 || lna == 2)
1376 offset += 10; 1377 offset += 10;