aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/common.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/common.c91
1 files changed, 26 insertions, 65 deletions
diff --git a/drivers/net/wireless/ath/ath9k/common.c b/drivers/net/wireless/ath/ath9k/common.c
index d3063c21e16c..a7e5a05b2eff 100644
--- a/drivers/net/wireless/ath/ath9k/common.c
+++ b/drivers/net/wireless/ath/ath9k/common.c
@@ -49,103 +49,64 @@ int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb)
49} 49}
50EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype); 50EXPORT_SYMBOL(ath9k_cmn_get_hw_crypto_keytype);
51 51
52static u32 ath9k_get_extchanmode(struct cfg80211_chan_def *chandef)
53{
54 u32 chanmode = 0;
55
56 switch (chandef->chan->band) {
57 case IEEE80211_BAND_2GHZ:
58 switch (chandef->width) {
59 case NL80211_CHAN_WIDTH_20_NOHT:
60 case NL80211_CHAN_WIDTH_20:
61 chanmode = CHANNEL_G_HT20;
62 break;
63 case NL80211_CHAN_WIDTH_40:
64 if (chandef->center_freq1 > chandef->chan->center_freq)
65 chanmode = CHANNEL_G_HT40PLUS;
66 else
67 chanmode = CHANNEL_G_HT40MINUS;
68 break;
69 default:
70 break;
71 }
72 break;
73 case IEEE80211_BAND_5GHZ:
74 switch (chandef->width) {
75 case NL80211_CHAN_WIDTH_20_NOHT:
76 case NL80211_CHAN_WIDTH_20:
77 chanmode = CHANNEL_A_HT20;
78 break;
79 case NL80211_CHAN_WIDTH_40:
80 if (chandef->center_freq1 > chandef->chan->center_freq)
81 chanmode = CHANNEL_A_HT40PLUS;
82 else
83 chanmode = CHANNEL_A_HT40MINUS;
84 break;
85 default:
86 break;
87 }
88 break;
89 default:
90 break;
91 }
92
93 return chanmode;
94}
95
96/* 52/*
97 * Update internal channel flags. 53 * Update internal channel flags.
98 */ 54 */
99void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan, 55static void ath9k_cmn_update_ichannel(struct ath9k_channel *ichan,
100 struct cfg80211_chan_def *chandef) 56 struct cfg80211_chan_def *chandef)
101{ 57{
102 ichan->channel = chandef->chan->center_freq; 58 struct ieee80211_channel *chan = chandef->chan;
103 ichan->chan = chandef->chan; 59 u16 flags = 0;
104 60
105 if (chandef->chan->band == IEEE80211_BAND_2GHZ) { 61 ichan->channel = chan->center_freq;
106 ichan->chanmode = CHANNEL_G; 62 ichan->chan = chan;
107 ichan->channelFlags = CHANNEL_2GHZ | CHANNEL_OFDM; 63
108 } else { 64 if (chan->band == IEEE80211_BAND_5GHZ)
109 ichan->chanmode = CHANNEL_A; 65 flags |= CHANNEL_5GHZ;
110 ichan->channelFlags = CHANNEL_5GHZ | CHANNEL_OFDM;
111 }
112 66
113 switch (chandef->width) { 67 switch (chandef->width) {
114 case NL80211_CHAN_WIDTH_5: 68 case NL80211_CHAN_WIDTH_5:
115 ichan->channelFlags |= CHANNEL_QUARTER; 69 flags |= CHANNEL_QUARTER;
116 break; 70 break;
117 case NL80211_CHAN_WIDTH_10: 71 case NL80211_CHAN_WIDTH_10:
118 ichan->channelFlags |= CHANNEL_HALF; 72 flags |= CHANNEL_HALF;
119 break; 73 break;
120 case NL80211_CHAN_WIDTH_20_NOHT: 74 case NL80211_CHAN_WIDTH_20_NOHT:
121 break; 75 break;
122 case NL80211_CHAN_WIDTH_20: 76 case NL80211_CHAN_WIDTH_20:
77 flags |= CHANNEL_HT;
78 break;
123 case NL80211_CHAN_WIDTH_40: 79 case NL80211_CHAN_WIDTH_40:
124 ichan->chanmode = ath9k_get_extchanmode(chandef); 80 if (chandef->center_freq1 > chandef->chan->center_freq)
81 flags |= CHANNEL_HT40PLUS | CHANNEL_HT;
82 else
83 flags |= CHANNEL_HT40MINUS | CHANNEL_HT;
125 break; 84 break;
126 default: 85 default:
127 WARN_ON(1); 86 WARN_ON(1);
128 } 87 }
88
89 ichan->channelFlags = flags;
129} 90}
130EXPORT_SYMBOL(ath9k_cmn_update_ichannel);
131 91
132/* 92/*
133 * Get the internal channel reference. 93 * Get the internal channel reference.
134 */ 94 */
135struct ath9k_channel *ath9k_cmn_get_curchannel(struct ieee80211_hw *hw, 95struct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw,
136 struct ath_hw *ah) 96 struct ath_hw *ah,
97 struct cfg80211_chan_def *chandef)
137{ 98{
138 struct ieee80211_channel *curchan = hw->conf.chandef.chan; 99 struct ieee80211_channel *curchan = chandef->chan;
139 struct ath9k_channel *channel; 100 struct ath9k_channel *channel;
140 u8 chan_idx; 101 u8 chan_idx;
141 102
142 chan_idx = curchan->hw_value; 103 chan_idx = curchan->hw_value;
143 channel = &ah->channels[chan_idx]; 104 channel = &ah->channels[chan_idx];
144 ath9k_cmn_update_ichannel(channel, &hw->conf.chandef); 105 ath9k_cmn_update_ichannel(channel, chandef);
145 106
146 return channel; 107 return channel;
147} 108}
148EXPORT_SYMBOL(ath9k_cmn_get_curchannel); 109EXPORT_SYMBOL(ath9k_cmn_get_channel);
149 110
150int ath9k_cmn_count_streams(unsigned int chainmask, int max) 111int ath9k_cmn_count_streams(unsigned int chainmask, int max)
151{ 112{