aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/ath/ath.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/Makefile3
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/beacon.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/common-init.c170
-rw-r--r--drivers/net/wireless/ath/ath9k/common-init.h17
-rw-r--r--drivers/net/wireless/ath/ath9k/common.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c172
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c3
9 files changed, 208 insertions, 163 deletions
diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
index 56d559939cfc..d239acc26125 100644
--- a/drivers/net/wireless/ath/ath.h
+++ b/drivers/net/wireless/ath/ath.h
@@ -163,6 +163,7 @@ struct ath_common {
163 bool bt_ant_diversity; 163 bool bt_ant_diversity;
164 164
165 int last_rssi; 165 int last_rssi;
166 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
166}; 167};
167 168
168struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, 169struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile
index 747975e1860a..b58fe99ef745 100644
--- a/drivers/net/wireless/ath/ath9k/Makefile
+++ b/drivers/net/wireless/ath/ath9k/Makefile
@@ -51,7 +51,8 @@ ath9k_hw-$(CONFIG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \
51obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o 51obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o
52 52
53obj-$(CONFIG_ATH9K_COMMON) += ath9k_common.o 53obj-$(CONFIG_ATH9K_COMMON) += ath9k_common.o
54ath9k_common-y:= common.o 54ath9k_common-y:= common.o \
55 common-init.o
55 56
56ath9k_htc-y += htc_hst.o \ 57ath9k_htc-y += htc_hst.o \
57 hif_usb.o \ 58 hif_usb.o \
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 21d13bc99c5a..e703ddad7ecf 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -753,7 +753,6 @@ struct ath_softc {
753 struct ath_rx rx; 753 struct ath_rx rx;
754 struct ath_tx tx; 754 struct ath_tx tx;
755 struct ath_beacon beacon; 755 struct ath_beacon beacon;
756 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
757 756
758#ifdef CONFIG_MAC80211_LEDS 757#ifdef CONFIG_MAC80211_LEDS
759 bool led_registered; 758 bool led_registered;
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 32d00e8cfd0c..6569528753af 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -80,7 +80,7 @@ static void ath9k_beacon_setup(struct ath_softc *sc, struct ieee80211_vif *vif,
80 u8 chainmask = ah->txchainmask; 80 u8 chainmask = ah->txchainmask;
81 u8 rate = 0; 81 u8 rate = 0;
82 82
83 sband = &sc->sbands[common->hw->conf.chandef.chan->band]; 83 sband = &common->sbands[common->hw->conf.chandef.chan->band];
84 rate = sband->bitrates[rateidx].hw_value; 84 rate = sband->bitrates[rateidx].hw_value;
85 if (vif->bss_conf.use_short_preamble) 85 if (vif->bss_conf.use_short_preamble)
86 rate |= sband->bitrates[rateidx].hw_value_short; 86 rate |= sband->bitrates[rateidx].hw_value_short;
diff --git a/drivers/net/wireless/ath/ath9k/common-init.c b/drivers/net/wireless/ath/ath9k/common-init.c
new file mode 100644
index 000000000000..1fa30c3b7d53
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/common-init.c
@@ -0,0 +1,170 @@
1/*
2 * Copyright (c) 2008-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* We use the hw_value as an index into our private channel structure */
18
19#include "common.h"
20
21#define CHAN2G(_freq, _idx) { \
22 .band = IEEE80211_BAND_2GHZ, \
23 .center_freq = (_freq), \
24 .hw_value = (_idx), \
25 .max_power = 20, \
26}
27
28#define CHAN5G(_freq, _idx) { \
29 .band = IEEE80211_BAND_5GHZ, \
30 .center_freq = (_freq), \
31 .hw_value = (_idx), \
32 .max_power = 20, \
33}
34
35/* Some 2 GHz radios are actually tunable on 2312-2732
36 * on 5 MHz steps, we support the channels which we know
37 * we have calibration data for all cards though to make
38 * this static */
39static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
40 CHAN2G(2412, 0), /* Channel 1 */
41 CHAN2G(2417, 1), /* Channel 2 */
42 CHAN2G(2422, 2), /* Channel 3 */
43 CHAN2G(2427, 3), /* Channel 4 */
44 CHAN2G(2432, 4), /* Channel 5 */
45 CHAN2G(2437, 5), /* Channel 6 */
46 CHAN2G(2442, 6), /* Channel 7 */
47 CHAN2G(2447, 7), /* Channel 8 */
48 CHAN2G(2452, 8), /* Channel 9 */
49 CHAN2G(2457, 9), /* Channel 10 */
50 CHAN2G(2462, 10), /* Channel 11 */
51 CHAN2G(2467, 11), /* Channel 12 */
52 CHAN2G(2472, 12), /* Channel 13 */
53 CHAN2G(2484, 13), /* Channel 14 */
54};
55
56/* Some 5 GHz radios are actually tunable on XXXX-YYYY
57 * on 5 MHz steps, we support the channels which we know
58 * we have calibration data for all cards though to make
59 * this static */
60static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
61 /* _We_ call this UNII 1 */
62 CHAN5G(5180, 14), /* Channel 36 */
63 CHAN5G(5200, 15), /* Channel 40 */
64 CHAN5G(5220, 16), /* Channel 44 */
65 CHAN5G(5240, 17), /* Channel 48 */
66 /* _We_ call this UNII 2 */
67 CHAN5G(5260, 18), /* Channel 52 */
68 CHAN5G(5280, 19), /* Channel 56 */
69 CHAN5G(5300, 20), /* Channel 60 */
70 CHAN5G(5320, 21), /* Channel 64 */
71 /* _We_ call this "Middle band" */
72 CHAN5G(5500, 22), /* Channel 100 */
73 CHAN5G(5520, 23), /* Channel 104 */
74 CHAN5G(5540, 24), /* Channel 108 */
75 CHAN5G(5560, 25), /* Channel 112 */
76 CHAN5G(5580, 26), /* Channel 116 */
77 CHAN5G(5600, 27), /* Channel 120 */
78 CHAN5G(5620, 28), /* Channel 124 */
79 CHAN5G(5640, 29), /* Channel 128 */
80 CHAN5G(5660, 30), /* Channel 132 */
81 CHAN5G(5680, 31), /* Channel 136 */
82 CHAN5G(5700, 32), /* Channel 140 */
83 /* _We_ call this UNII 3 */
84 CHAN5G(5745, 33), /* Channel 149 */
85 CHAN5G(5765, 34), /* Channel 153 */
86 CHAN5G(5785, 35), /* Channel 157 */
87 CHAN5G(5805, 36), /* Channel 161 */
88 CHAN5G(5825, 37), /* Channel 165 */
89};
90
91/* Atheros hardware rate code addition for short premble */
92#define SHPCHECK(__hw_rate, __flags) \
93 ((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0)
94
95#define RATE(_bitrate, _hw_rate, _flags) { \
96 .bitrate = (_bitrate), \
97 .flags = (_flags), \
98 .hw_value = (_hw_rate), \
99 .hw_value_short = (SHPCHECK(_hw_rate, _flags)) \
100}
101
102static struct ieee80211_rate ath9k_legacy_rates[] = {
103 RATE(10, 0x1b, 0),
104 RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE),
105 RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE),
106 RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE),
107 RATE(60, 0x0b, (IEEE80211_RATE_SUPPORTS_5MHZ |
108 IEEE80211_RATE_SUPPORTS_10MHZ)),
109 RATE(90, 0x0f, (IEEE80211_RATE_SUPPORTS_5MHZ |
110 IEEE80211_RATE_SUPPORTS_10MHZ)),
111 RATE(120, 0x0a, (IEEE80211_RATE_SUPPORTS_5MHZ |
112 IEEE80211_RATE_SUPPORTS_10MHZ)),
113 RATE(180, 0x0e, (IEEE80211_RATE_SUPPORTS_5MHZ |
114 IEEE80211_RATE_SUPPORTS_10MHZ)),
115 RATE(240, 0x09, (IEEE80211_RATE_SUPPORTS_5MHZ |
116 IEEE80211_RATE_SUPPORTS_10MHZ)),
117 RATE(360, 0x0d, (IEEE80211_RATE_SUPPORTS_5MHZ |
118 IEEE80211_RATE_SUPPORTS_10MHZ)),
119 RATE(480, 0x08, (IEEE80211_RATE_SUPPORTS_5MHZ |
120 IEEE80211_RATE_SUPPORTS_10MHZ)),
121 RATE(540, 0x0c, (IEEE80211_RATE_SUPPORTS_5MHZ |
122 IEEE80211_RATE_SUPPORTS_10MHZ)),
123};
124
125int ath9k_cmn_init_channels_rates(struct ath_common *common)
126{
127 struct ath_hw *ah = (struct ath_hw *)common->ah;
128 void *channels;
129
130 BUILD_BUG_ON(ARRAY_SIZE(ath9k_2ghz_chantable) +
131 ARRAY_SIZE(ath9k_5ghz_chantable) !=
132 ATH9K_NUM_CHANNELS);
133
134 if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
135 channels = devm_kzalloc(ah->dev,
136 sizeof(ath9k_2ghz_chantable), GFP_KERNEL);
137 if (!channels)
138 return -ENOMEM;
139
140 memcpy(channels, ath9k_2ghz_chantable,
141 sizeof(ath9k_2ghz_chantable));
142 common->sbands[IEEE80211_BAND_2GHZ].channels = channels;
143 common->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
144 common->sbands[IEEE80211_BAND_2GHZ].n_channels =
145 ARRAY_SIZE(ath9k_2ghz_chantable);
146 common->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
147 common->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
148 ARRAY_SIZE(ath9k_legacy_rates);
149 }
150
151 if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) {
152 channels = devm_kzalloc(ah->dev,
153 sizeof(ath9k_5ghz_chantable), GFP_KERNEL);
154 if (!channels)
155 return -ENOMEM;
156
157 memcpy(channels, ath9k_5ghz_chantable,
158 sizeof(ath9k_5ghz_chantable));
159 common->sbands[IEEE80211_BAND_5GHZ].channels = channels;
160 common->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
161 common->sbands[IEEE80211_BAND_5GHZ].n_channels =
162 ARRAY_SIZE(ath9k_5ghz_chantable);
163 common->sbands[IEEE80211_BAND_5GHZ].bitrates =
164 ath9k_legacy_rates + 4;
165 common->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
166 ARRAY_SIZE(ath9k_legacy_rates) - 4;
167 }
168 return 0;
169}
170EXPORT_SYMBOL(ath9k_cmn_init_channels_rates);
diff --git a/drivers/net/wireless/ath/ath9k/common-init.h b/drivers/net/wireless/ath/ath9k/common-init.h
new file mode 100644
index 000000000000..8fc9049ad8b0
--- /dev/null
+++ b/drivers/net/wireless/ath/ath9k/common-init.h
@@ -0,0 +1,17 @@
1/*
2 * Copyright (c) 2009-2011 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17int ath9k_cmn_init_channels_rates(struct ath_common *common);
diff --git a/drivers/net/wireless/ath/ath9k/common.h b/drivers/net/wireless/ath/ath9k/common.h
index 38b5609a4018..4c449e35bd65 100644
--- a/drivers/net/wireless/ath/ath9k/common.h
+++ b/drivers/net/wireless/ath/ath9k/common.h
@@ -21,6 +21,8 @@
21#include "hw.h" 21#include "hw.h"
22#include "hw-ops.h" 22#include "hw-ops.h"
23 23
24#include "common-init.h"
25
24/* Common header for Atheros 802.11n base driver cores */ 26/* Common header for Atheros 802.11n base driver cores */
25 27
26#define WME_BA_BMP_SIZE 64 28#define WME_BA_BMP_SIZE 64
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 4856a1739ade..a6232cf0e998 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -62,111 +62,6 @@ module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
62MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave"); 62MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
63 63
64bool is_ath9k_unloaded; 64bool is_ath9k_unloaded;
65/* We use the hw_value as an index into our private channel structure */
66
67#define CHAN2G(_freq, _idx) { \
68 .band = IEEE80211_BAND_2GHZ, \
69 .center_freq = (_freq), \
70 .hw_value = (_idx), \
71 .max_power = 20, \
72}
73
74#define CHAN5G(_freq, _idx) { \
75 .band = IEEE80211_BAND_5GHZ, \
76 .center_freq = (_freq), \
77 .hw_value = (_idx), \
78 .max_power = 20, \
79}
80
81/* Some 2 GHz radios are actually tunable on 2312-2732
82 * on 5 MHz steps, we support the channels which we know
83 * we have calibration data for all cards though to make
84 * this static */
85static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
86 CHAN2G(2412, 0), /* Channel 1 */
87 CHAN2G(2417, 1), /* Channel 2 */
88 CHAN2G(2422, 2), /* Channel 3 */
89 CHAN2G(2427, 3), /* Channel 4 */
90 CHAN2G(2432, 4), /* Channel 5 */
91 CHAN2G(2437, 5), /* Channel 6 */
92 CHAN2G(2442, 6), /* Channel 7 */
93 CHAN2G(2447, 7), /* Channel 8 */
94 CHAN2G(2452, 8), /* Channel 9 */
95 CHAN2G(2457, 9), /* Channel 10 */
96 CHAN2G(2462, 10), /* Channel 11 */
97 CHAN2G(2467, 11), /* Channel 12 */
98 CHAN2G(2472, 12), /* Channel 13 */
99 CHAN2G(2484, 13), /* Channel 14 */
100};
101
102/* Some 5 GHz radios are actually tunable on XXXX-YYYY
103 * on 5 MHz steps, we support the channels which we know
104 * we have calibration data for all cards though to make
105 * this static */
106static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
107 /* _We_ call this UNII 1 */
108 CHAN5G(5180, 14), /* Channel 36 */
109 CHAN5G(5200, 15), /* Channel 40 */
110 CHAN5G(5220, 16), /* Channel 44 */
111 CHAN5G(5240, 17), /* Channel 48 */
112 /* _We_ call this UNII 2 */
113 CHAN5G(5260, 18), /* Channel 52 */
114 CHAN5G(5280, 19), /* Channel 56 */
115 CHAN5G(5300, 20), /* Channel 60 */
116 CHAN5G(5320, 21), /* Channel 64 */
117 /* _We_ call this "Middle band" */
118 CHAN5G(5500, 22), /* Channel 100 */
119 CHAN5G(5520, 23), /* Channel 104 */
120 CHAN5G(5540, 24), /* Channel 108 */
121 CHAN5G(5560, 25), /* Channel 112 */
122 CHAN5G(5580, 26), /* Channel 116 */
123 CHAN5G(5600, 27), /* Channel 120 */
124 CHAN5G(5620, 28), /* Channel 124 */
125 CHAN5G(5640, 29), /* Channel 128 */
126 CHAN5G(5660, 30), /* Channel 132 */
127 CHAN5G(5680, 31), /* Channel 136 */
128 CHAN5G(5700, 32), /* Channel 140 */
129 /* _We_ call this UNII 3 */
130 CHAN5G(5745, 33), /* Channel 149 */
131 CHAN5G(5765, 34), /* Channel 153 */
132 CHAN5G(5785, 35), /* Channel 157 */
133 CHAN5G(5805, 36), /* Channel 161 */
134 CHAN5G(5825, 37), /* Channel 165 */
135};
136
137/* Atheros hardware rate code addition for short premble */
138#define SHPCHECK(__hw_rate, __flags) \
139 ((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0)
140
141#define RATE(_bitrate, _hw_rate, _flags) { \
142 .bitrate = (_bitrate), \
143 .flags = (_flags), \
144 .hw_value = (_hw_rate), \
145 .hw_value_short = (SHPCHECK(_hw_rate, _flags)) \
146}
147
148static struct ieee80211_rate ath9k_legacy_rates[] = {
149 RATE(10, 0x1b, 0),
150 RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE),
151 RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE),
152 RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE),
153 RATE(60, 0x0b, (IEEE80211_RATE_SUPPORTS_5MHZ |
154 IEEE80211_RATE_SUPPORTS_10MHZ)),
155 RATE(90, 0x0f, (IEEE80211_RATE_SUPPORTS_5MHZ |
156 IEEE80211_RATE_SUPPORTS_10MHZ)),
157 RATE(120, 0x0a, (IEEE80211_RATE_SUPPORTS_5MHZ |
158 IEEE80211_RATE_SUPPORTS_10MHZ)),
159 RATE(180, 0x0e, (IEEE80211_RATE_SUPPORTS_5MHZ |
160 IEEE80211_RATE_SUPPORTS_10MHZ)),
161 RATE(240, 0x09, (IEEE80211_RATE_SUPPORTS_5MHZ |
162 IEEE80211_RATE_SUPPORTS_10MHZ)),
163 RATE(360, 0x0d, (IEEE80211_RATE_SUPPORTS_5MHZ |
164 IEEE80211_RATE_SUPPORTS_10MHZ)),
165 RATE(480, 0x08, (IEEE80211_RATE_SUPPORTS_5MHZ |
166 IEEE80211_RATE_SUPPORTS_10MHZ)),
167 RATE(540, 0x0c, (IEEE80211_RATE_SUPPORTS_5MHZ |
168 IEEE80211_RATE_SUPPORTS_10MHZ)),
169};
170 65
171#ifdef CONFIG_MAC80211_LEDS 66#ifdef CONFIG_MAC80211_LEDS
172static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = { 67static const struct ieee80211_tpt_blink ath9k_tpt_blink[] = {
@@ -486,51 +381,6 @@ static int ath9k_init_queues(struct ath_softc *sc)
486 return 0; 381 return 0;
487} 382}
488 383
489static int ath9k_init_channels_rates(struct ath_softc *sc)
490{
491 void *channels;
492
493 BUILD_BUG_ON(ARRAY_SIZE(ath9k_2ghz_chantable) +
494 ARRAY_SIZE(ath9k_5ghz_chantable) !=
495 ATH9K_NUM_CHANNELS);
496
497 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) {
498 channels = devm_kzalloc(sc->dev,
499 sizeof(ath9k_2ghz_chantable), GFP_KERNEL);
500 if (!channels)
501 return -ENOMEM;
502
503 memcpy(channels, ath9k_2ghz_chantable,
504 sizeof(ath9k_2ghz_chantable));
505 sc->sbands[IEEE80211_BAND_2GHZ].channels = channels;
506 sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
507 sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
508 ARRAY_SIZE(ath9k_2ghz_chantable);
509 sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
510 sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
511 ARRAY_SIZE(ath9k_legacy_rates);
512 }
513
514 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) {
515 channels = devm_kzalloc(sc->dev,
516 sizeof(ath9k_5ghz_chantable), GFP_KERNEL);
517 if (!channels)
518 return -ENOMEM;
519
520 memcpy(channels, ath9k_5ghz_chantable,
521 sizeof(ath9k_5ghz_chantable));
522 sc->sbands[IEEE80211_BAND_5GHZ].channels = channels;
523 sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
524 sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
525 ARRAY_SIZE(ath9k_5ghz_chantable);
526 sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
527 ath9k_legacy_rates + 4;
528 sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
529 ARRAY_SIZE(ath9k_legacy_rates) - 4;
530 }
531 return 0;
532}
533
534static void ath9k_init_misc(struct ath_softc *sc) 384static void ath9k_init_misc(struct ath_softc *sc)
535{ 385{
536 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 386 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -793,7 +643,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
793 if (ret) 643 if (ret)
794 goto err_btcoex; 644 goto err_btcoex;
795 645
796 ret = ath9k_init_channels_rates(sc); 646 ret = ath9k_cmn_init_channels_rates(common);
797 if (ret) 647 if (ret)
798 goto err_btcoex; 648 goto err_btcoex;
799 649
@@ -823,10 +673,11 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
823 struct ieee80211_supported_band *sband; 673 struct ieee80211_supported_band *sband;
824 struct ieee80211_channel *chan; 674 struct ieee80211_channel *chan;
825 struct ath_hw *ah = sc->sc_ah; 675 struct ath_hw *ah = sc->sc_ah;
676 struct ath_common *common = ath9k_hw_common(ah);
826 struct cfg80211_chan_def chandef; 677 struct cfg80211_chan_def chandef;
827 int i; 678 int i;
828 679
829 sband = &sc->sbands[band]; 680 sband = &common->sbands[band];
830 for (i = 0; i < sband->n_channels; i++) { 681 for (i = 0; i < sband->n_channels; i++) {
831 chan = &sband->channels[i]; 682 chan = &sband->channels[i];
832 ah->curchan = &ah->channels[chan->hw_value]; 683 ah->curchan = &ah->channels[chan->hw_value];
@@ -851,13 +702,16 @@ static void ath9k_init_txpower_limits(struct ath_softc *sc)
851 702
852void ath9k_reload_chainmask_settings(struct ath_softc *sc) 703void ath9k_reload_chainmask_settings(struct ath_softc *sc)
853{ 704{
854 if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT)) 705 struct ath_hw *ah = sc->sc_ah;
706 struct ath_common *common = ath9k_hw_common(ah);
707
708 if (!(ah->caps.hw_caps & ATH9K_HW_CAP_HT))
855 return; 709 return;
856 710
857 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) 711 if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
858 setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_2GHZ].ht_cap); 712 setup_ht_cap(sc, &common->sbands[IEEE80211_BAND_2GHZ].ht_cap);
859 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) 713 if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
860 setup_ht_cap(sc, &sc->sbands[IEEE80211_BAND_5GHZ].ht_cap); 714 setup_ht_cap(sc, &common->sbands[IEEE80211_BAND_5GHZ].ht_cap);
861} 715}
862 716
863static const struct ieee80211_iface_limit if_limits[] = { 717static const struct ieee80211_iface_limit if_limits[] = {
@@ -970,10 +824,10 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
970 824
971 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ) 825 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
972 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 826 hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
973 &sc->sbands[IEEE80211_BAND_2GHZ]; 827 &common->sbands[IEEE80211_BAND_2GHZ];
974 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ) 828 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
975 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = 829 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
976 &sc->sbands[IEEE80211_BAND_5GHZ]; 830 &common->sbands[IEEE80211_BAND_5GHZ];
977 831
978 ath9k_init_wow(hw); 832 ath9k_init_wow(hw);
979 ath9k_reload_chainmask_settings(sc); 833 ath9k_reload_chainmask_settings(sc);
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index a6507046dfe8..8f28711cfd4e 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1076,6 +1076,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
1076 struct ath_tx_info *info, int len, bool rts) 1076 struct ath_tx_info *info, int len, bool rts)
1077{ 1077{
1078 struct ath_hw *ah = sc->sc_ah; 1078 struct ath_hw *ah = sc->sc_ah;
1079 struct ath_common *common = ath9k_hw_common(ah);
1079 struct sk_buff *skb; 1080 struct sk_buff *skb;
1080 struct ieee80211_tx_info *tx_info; 1081 struct ieee80211_tx_info *tx_info;
1081 struct ieee80211_tx_rate *rates; 1082 struct ieee80211_tx_rate *rates;
@@ -1145,7 +1146,7 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf,
1145 } 1146 }
1146 1147
1147 /* legacy rates */ 1148 /* legacy rates */
1148 rate = &sc->sbands[tx_info->band].bitrates[rates[i].idx]; 1149 rate = &common->sbands[tx_info->band].bitrates[rates[i].idx];
1149 if ((tx_info->band == IEEE80211_BAND_2GHZ) && 1150 if ((tx_info->band == IEEE80211_BAND_2GHZ) &&
1150 !(rate->flags & IEEE80211_RATE_ERP_G)) 1151 !(rate->flags & IEEE80211_RATE_ERP_G))
1151 phy = WLAN_RC_PHY_CCK; 1152 phy = WLAN_RC_PHY_CCK;