aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00config.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00config.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index f8e87aa86335..12914cf7156c 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -97,7 +97,11 @@ void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, const int type)
97void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, 97void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
98 struct ieee80211_conf *conf, const int force_config) 98 struct ieee80211_conf *conf, const int force_config)
99{ 99{
100 struct rt2x00lib_conf libconf;
101 struct ieee80211_hw_mode *mode;
102 struct ieee80211_rate *rate;
100 int flags = 0; 103 int flags = 0;
104 int short_slot_time;
101 105
102 /* 106 /*
103 * In some situations we want to force all configurations 107 * In some situations we want to force all configurations
@@ -128,8 +132,62 @@ void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
128 flags |= CONFIG_UPDATE_SLOT_TIME; 132 flags |= CONFIG_UPDATE_SLOT_TIME;
129 flags |= CONFIG_UPDATE_BEACON_INT; 133 flags |= CONFIG_UPDATE_BEACON_INT;
130 134
135 /*
136 * We have determined what options should be updated,
137 * now precalculate device configuration values depending
138 * on what configuration options need to be updated.
139 */
131config: 140config:
132 rt2x00dev->ops->lib->config(rt2x00dev, flags, conf); 141 memset(&libconf, 0, sizeof(libconf));
142
143 if (flags & CONFIG_UPDATE_PHYMODE) {
144 switch (conf->phymode) {
145 case MODE_IEEE80211A:
146 libconf.phymode = HWMODE_A;
147 break;
148 case MODE_IEEE80211B:
149 libconf.phymode = HWMODE_B;
150 break;
151 case MODE_IEEE80211G:
152 libconf.phymode = HWMODE_G;
153 break;
154 default:
155 ERROR(rt2x00dev,
156 "Attempt to configure unsupported mode (%d)"
157 "Defaulting to 802.11b", conf->phymode);
158 libconf.phymode = HWMODE_B;
159 }
160
161 mode = &rt2x00dev->hwmodes[libconf.phymode];
162 rate = &mode->rates[mode->num_rates - 1];
163
164 libconf.basic_rates =
165 DEVICE_GET_RATE_FIELD(rate->val, RATEMASK) & DEV_BASIC_RATEMASK;
166 }
167
168 if (flags & CONFIG_UPDATE_CHANNEL) {
169 memcpy(&libconf.rf,
170 &rt2x00dev->spec.channels[conf->channel_val],
171 sizeof(libconf.rf));
172 }
173
174 if (flags & CONFIG_UPDATE_SLOT_TIME) {
175 short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME;
176
177 libconf.slot_time =
178 short_slot_time ? SHORT_SLOT_TIME : SLOT_TIME;
179 libconf.sifs = SIFS;
180 libconf.pifs = short_slot_time ? SHORT_PIFS : PIFS;
181 libconf.difs = short_slot_time ? SHORT_DIFS : DIFS;
182 libconf.eifs = EIFS;
183 }
184
185 libconf.conf = conf;
186
187 /*
188 * Start configuration.
189 */
190 rt2x00dev->ops->lib->config(rt2x00dev, flags, &libconf);
133 191
134 /* 192 /*
135 * Some configuration changes affect the link quality 193 * Some configuration changes affect the link quality
@@ -138,6 +196,7 @@ config:
138 if (flags & (CONFIG_UPDATE_CHANNEL | CONFIG_UPDATE_ANTENNA)) 196 if (flags & (CONFIG_UPDATE_CHANNEL | CONFIG_UPDATE_ANTENNA))
139 rt2x00lib_reset_link_tuner(rt2x00dev); 197 rt2x00lib_reset_link_tuner(rt2x00dev);
140 198
199 rt2x00dev->curr_hwmode = libconf.phymode;
141 rt2x00dev->rx_status.phymode = conf->phymode; 200 rt2x00dev->rx_status.phymode = conf->phymode;
142 rt2x00dev->rx_status.freq = conf->freq; 201 rt2x00dev->rx_status.freq = conf->freq;
143 rt2x00dev->rx_status.channel = conf->channel; 202 rt2x00dev->rx_status.channel = conf->channel;