aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271.h23
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.c6
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_debugfs.c13
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_event.c11
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c45
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_ps.c15
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_tx.c6
7 files changed, 55 insertions, 64 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271.h b/drivers/net/wireless/wl12xx/wl1271.h
index 9290c92522b..d0938db043b 100644
--- a/drivers/net/wireless/wl12xx/wl1271.h
+++ b/drivers/net/wireless/wl12xx/wl1271.h
@@ -324,6 +324,13 @@ struct wl1271 {
324 324
325#define WL1271_FLAG_STA_RATES_CHANGED (0) 325#define WL1271_FLAG_STA_RATES_CHANGED (0)
326#define WL1271_FLAG_STA_ASSOCIATED (1) 326#define WL1271_FLAG_STA_ASSOCIATED (1)
327#define WL1271_FLAG_JOINED (2)
328#define WL1271_FLAG_GPIO_POWER (3)
329#define WL1271_FLAG_TX_QUEUE_STOPPED (4)
330#define WL1271_FLAG_SCANNING (5)
331#define WL1271_FLAG_IN_ELP (6)
332#define WL1271_FLAG_PSM (7)
333#define WL1271_FLAG_PSM_REQUESTED (8)
327 unsigned long flags; 334 unsigned long flags;
328 335
329 struct wl1271_partition_set part; 336 struct wl1271_partition_set part;
@@ -363,7 +370,6 @@ struct wl1271 {
363 370
364 /* Frames scheduled for transmission, not handled yet */ 371 /* Frames scheduled for transmission, not handled yet */
365 struct sk_buff_head tx_queue; 372 struct sk_buff_head tx_queue;
366 bool tx_queue_stopped;
367 373
368 struct work_struct tx_work; 374 struct work_struct tx_work;
369 375
@@ -391,7 +397,6 @@ struct wl1271 {
391 u32 mbox_ptr[2]; 397 u32 mbox_ptr[2];
392 398
393 /* Are we currently scanning */ 399 /* Are we currently scanning */
394 bool scanning;
395 struct wl1271_scan scan; 400 struct wl1271_scan scan;
396 401
397 /* Our association ID */ 402 /* Our association ID */
@@ -411,18 +416,9 @@ struct wl1271 {
411 unsigned int rx_config; 416 unsigned int rx_config;
412 unsigned int rx_filter; 417 unsigned int rx_filter;
413 418
414 /* is firmware in elp mode */
415 bool elp;
416
417 struct completion *elp_compl; 419 struct completion *elp_compl;
418 struct delayed_work elp_work; 420 struct delayed_work elp_work;
419 421
420 /* we can be in psm, but not in elp, we have to differentiate */
421 bool psm;
422
423 /* PSM mode requested */
424 bool psm_requested;
425
426 /* retry counter for PSM entries */ 422 /* retry counter for PSM entries */
427 u8 psm_entry_retry; 423 u8 psm_entry_retry;
428 424
@@ -441,15 +437,10 @@ struct wl1271 {
441 437
442 struct ieee80211_vif *vif; 438 struct ieee80211_vif *vif;
443 439
444 /* Used for a workaround to send disconnect before rejoining */
445 bool joined;
446
447 /* Current chipset configuration */ 440 /* Current chipset configuration */
448 struct conf_drv_settings conf; 441 struct conf_drv_settings conf;
449 442
450 struct list_head list; 443 struct list_head list;
451
452 bool gpio_power;
453}; 444};
454 445
455int wl1271_plt_start(struct wl1271 *wl); 446int wl1271_plt_start(struct wl1271 *wl);
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c
index 20f3e67c8e4..b5eb9edc63a 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c
@@ -655,7 +655,7 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len,
655 channels = wl->hw->wiphy->bands[ieee_band]->channels; 655 channels = wl->hw->wiphy->bands[ieee_band]->channels;
656 n_ch = wl->hw->wiphy->bands[ieee_band]->n_channels; 656 n_ch = wl->hw->wiphy->bands[ieee_band]->n_channels;
657 657
658 if (wl->scanning) 658 if (test_bit(WL1271_FLAG_SCANNING, &wl->flags))
659 return -EINVAL; 659 return -EINVAL;
660 660
661 params = kzalloc(sizeof(*params), GFP_KERNEL); 661 params = kzalloc(sizeof(*params), GFP_KERNEL);
@@ -730,7 +730,7 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len,
730 730
731 wl1271_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params)); 731 wl1271_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params));
732 732
733 wl->scanning = true; 733 set_bit(WL1271_FLAG_SCANNING, &wl->flags);
734 if (wl1271_11a_enabled()) { 734 if (wl1271_11a_enabled()) {
735 wl->scan.state = band; 735 wl->scan.state = band;
736 if (band == WL1271_SCAN_BAND_DUAL) { 736 if (band == WL1271_SCAN_BAND_DUAL) {
@@ -748,7 +748,7 @@ int wl1271_cmd_scan(struct wl1271 *wl, u8 *ssid, size_t len,
748 ret = wl1271_cmd_send(wl, CMD_SCAN, params, sizeof(*params), 0); 748 ret = wl1271_cmd_send(wl, CMD_SCAN, params, sizeof(*params), 0);
749 if (ret < 0) { 749 if (ret < 0) {
750 wl1271_error("SCAN failed"); 750 wl1271_error("SCAN failed");
751 wl->scanning = false; 751 clear_bit(WL1271_FLAG_SCANNING, &wl->flags);
752 goto out; 752 goto out;
753 } 753 }
754 754
diff --git a/drivers/net/wireless/wl12xx/wl1271_debugfs.c b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
index 4eaf40c5756..8d7588ca68f 100644
--- a/drivers/net/wireless/wl12xx/wl1271_debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1271_debugfs.c
@@ -241,10 +241,12 @@ static ssize_t gpio_power_read(struct file *file, char __user *user_buf,
241 size_t count, loff_t *ppos) 241 size_t count, loff_t *ppos)
242{ 242{
243 struct wl1271 *wl = file->private_data; 243 struct wl1271 *wl = file->private_data;
244 bool state = test_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
245
244 int res; 246 int res;
245 char buf[10]; 247 char buf[10];
246 248
247 res = scnprintf(buf, sizeof(buf), "%d\n", wl->gpio_power); 249 res = scnprintf(buf, sizeof(buf), "%d\n", state);
248 250
249 return simple_read_from_buffer(user_buf, count, ppos, buf, res); 251 return simple_read_from_buffer(user_buf, count, ppos, buf, res);
250} 252}
@@ -274,8 +276,13 @@ static ssize_t gpio_power_write(struct file *file,
274 goto out; 276 goto out;
275 } 277 }
276 278
277 wl->set_power(!!value); 279 if (value) {
278 wl->gpio_power = !!value; 280 wl->set_power(true);
281 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
282 } else {
283 wl->set_power(false);
284 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
285 }
279 286
280out: 287out:
281 mutex_unlock(&wl->mutex); 288 mutex_unlock(&wl->mutex);
diff --git a/drivers/net/wireless/wl12xx/wl1271_event.c b/drivers/net/wireless/wl12xx/wl1271_event.c
index 8d0c18dec2c..6ff535d5c7e 100644
--- a/drivers/net/wireless/wl12xx/wl1271_event.c
+++ b/drivers/net/wireless/wl12xx/wl1271_event.c
@@ -35,7 +35,7 @@ static int wl1271_event_scan_complete(struct wl1271 *wl,
35 wl1271_debug(DEBUG_EVENT, "status: 0x%x", 35 wl1271_debug(DEBUG_EVENT, "status: 0x%x",
36 mbox->scheduled_scan_status); 36 mbox->scheduled_scan_status);
37 37
38 if (wl->scanning) { 38 if (test_bit(WL1271_FLAG_SCANNING, &wl->flags)) {
39 if (wl->scan.state == WL1271_SCAN_BAND_DUAL) { 39 if (wl->scan.state == WL1271_SCAN_BAND_DUAL) {
40 wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, 40 wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4,
41 NULL, size); 41 NULL, size);
@@ -43,7 +43,7 @@ static int wl1271_event_scan_complete(struct wl1271 *wl,
43 * to the wl1271_cmd_scan function that we are not 43 * to the wl1271_cmd_scan function that we are not
44 * scanning as it checks that. 44 * scanning as it checks that.
45 */ 45 */
46 wl->scanning = false; 46 clear_bit(WL1271_FLAG_SCANNING, &wl->flags);
47 wl1271_cmd_scan(wl, wl->scan.ssid, wl->scan.ssid_len, 47 wl1271_cmd_scan(wl, wl->scan.ssid, wl->scan.ssid_len,
48 wl->scan.active, 48 wl->scan.active,
49 wl->scan.high_prio, 49 wl->scan.high_prio,
@@ -62,7 +62,7 @@ static int wl1271_event_scan_complete(struct wl1271 *wl,
62 mutex_unlock(&wl->mutex); 62 mutex_unlock(&wl->mutex);
63 ieee80211_scan_completed(wl->hw, false); 63 ieee80211_scan_completed(wl->hw, false);
64 mutex_lock(&wl->mutex); 64 mutex_lock(&wl->mutex);
65 wl->scanning = false; 65 clear_bit(WL1271_FLAG_SCANNING, &wl->flags);
66 } 66 }
67 } 67 }
68 return 0; 68 return 0;
@@ -78,7 +78,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl,
78 78
79 switch (mbox->ps_status) { 79 switch (mbox->ps_status) {
80 case EVENT_ENTER_POWER_SAVE_FAIL: 80 case EVENT_ENTER_POWER_SAVE_FAIL:
81 if (!wl->psm) { 81 if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) {
82 wl->psm_entry_retry = 0; 82 wl->psm_entry_retry = 0;
83 break; 83 break;
84 } 84 }
@@ -135,7 +135,8 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox)
135 * filtering) is enabled. Without PSM, the stack will receive all 135 * filtering) is enabled. Without PSM, the stack will receive all
136 * beacons and can detect beacon loss by itself. 136 * beacons and can detect beacon loss by itself.
137 */ 137 */
138 if (vector & BSS_LOSE_EVENT_ID && wl->psm) { 138 if (vector & BSS_LOSE_EVENT_ID &&
139 test_bit(WL1271_FLAG_PSM, &wl->flags)) {
139 wl1271_debug(DEBUG_EVENT, "BSS_LOSE_EVENT"); 140 wl1271_debug(DEBUG_EVENT, "BSS_LOSE_EVENT");
140 141
141 /* indicate to the stack, that beacons have been lost */ 142 /* indicate to the stack, that beacons have been lost */
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 775b1e82ca8..90a60c1147a 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -378,13 +378,13 @@ static void wl1271_disable_interrupts(struct wl1271 *wl)
378static void wl1271_power_off(struct wl1271 *wl) 378static void wl1271_power_off(struct wl1271 *wl)
379{ 379{
380 wl->set_power(false); 380 wl->set_power(false);
381 wl->gpio_power = false; 381 clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
382} 382}
383 383
384static void wl1271_power_on(struct wl1271 *wl) 384static void wl1271_power_on(struct wl1271 *wl)
385{ 385{
386 wl->set_power(true); 386 wl->set_power(true);
387 wl->gpio_power = true; 387 set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
388} 388}
389 389
390static void wl1271_fw_status(struct wl1271 *wl, 390static void wl1271_fw_status(struct wl1271 *wl,
@@ -812,7 +812,7 @@ static int wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
812 * protected. Maybe fix this by removing the stupid 812 * protected. Maybe fix this by removing the stupid
813 * variable altogether and checking the real queue state? 813 * variable altogether and checking the real queue state?
814 */ 814 */
815 wl->tx_queue_stopped = true; 815 set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);
816 } 816 }
817 817
818 return NETDEV_TX_OK; 818 return NETDEV_TX_OK;
@@ -985,11 +985,10 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
985 985
986 WARN_ON(wl->state != WL1271_STATE_ON); 986 WARN_ON(wl->state != WL1271_STATE_ON);
987 987
988 if (wl->scanning) { 988 if (test_and_clear_bit(WL1271_FLAG_SCANNING, &wl->flags)) {
989 mutex_unlock(&wl->mutex); 989 mutex_unlock(&wl->mutex);
990 ieee80211_scan_completed(wl->hw, true); 990 ieee80211_scan_completed(wl->hw, true);
991 mutex_lock(&wl->mutex); 991 mutex_lock(&wl->mutex);
992 wl->scanning = false;
993 } 992 }
994 993
995 wl->state = WL1271_STATE_OFF; 994 wl->state = WL1271_STATE_OFF;
@@ -1014,10 +1013,7 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
1014 wl->band = IEEE80211_BAND_2GHZ; 1013 wl->band = IEEE80211_BAND_2GHZ;
1015 1014
1016 wl->rx_counter = 0; 1015 wl->rx_counter = 0;
1017 wl->elp = false;
1018 wl->psm = 0;
1019 wl->psm_entry_retry = 0; 1016 wl->psm_entry_retry = 0;
1020 wl->tx_queue_stopped = false;
1021 wl->power_level = WL1271_DEFAULT_POWER_LEVEL; 1017 wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
1022 wl->tx_blocks_available = 0; 1018 wl->tx_blocks_available = 0;
1023 wl->tx_results_count = 0; 1019 wl->tx_results_count = 0;
@@ -1027,7 +1023,6 @@ static void wl1271_op_stop(struct ieee80211_hw *hw)
1027 wl->tx_security_seq_32 = 0; 1023 wl->tx_security_seq_32 = 0;
1028 wl->time_offset = 0; 1024 wl->time_offset = 0;
1029 wl->session_counter = 0; 1025 wl->session_counter = 0;
1030 wl->joined = false;
1031 wl->rate_set = CONF_TX_RATE_MASK_BASIC; 1026 wl->rate_set = CONF_TX_RATE_MASK_BASIC;
1032 wl->sta_rate_set = 0; 1027 wl->sta_rate_set = 0;
1033 wl->flags = 0; 1028 wl->flags = 0;
@@ -1174,7 +1169,7 @@ static int wl1271_join_channel(struct wl1271 *wl, int channel)
1174 if (ret < 0) 1169 if (ret < 0)
1175 goto out; 1170 goto out;
1176 1171
1177 wl->joined = true; 1172 set_bit(WL1271_FLAG_JOINED, &wl->flags);
1178 1173
1179out: 1174out:
1180 return ret; 1175 return ret;
@@ -1189,7 +1184,7 @@ static int wl1271_unjoin_channel(struct wl1271 *wl)
1189 if (ret < 0) 1184 if (ret < 0)
1190 goto out; 1185 goto out;
1191 1186
1192 wl->joined = false; 1187 clear_bit(WL1271_FLAG_JOINED, &wl->flags);
1193 wl->channel = 0; 1188 wl->channel = 0;
1194 memset(wl->bssid, 0, ETH_ALEN); 1189 memset(wl->bssid, 0, ETH_ALEN);
1195 wl->rx_config = WL1271_DEFAULT_RX_CONFIG; 1190 wl->rx_config = WL1271_DEFAULT_RX_CONFIG;
@@ -1221,7 +1216,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
1221 goto out; 1216 goto out;
1222 1217
1223 if (changed & IEEE80211_CONF_CHANGE_IDLE) { 1218 if (changed & IEEE80211_CONF_CHANGE_IDLE) {
1224 if (conf->flags & IEEE80211_CONF_IDLE && wl->joined) 1219 if (conf->flags & IEEE80211_CONF_IDLE &&
1220 test_bit(WL1271_FLAG_JOINED, &wl->flags))
1225 wl1271_unjoin_channel(wl); 1221 wl1271_unjoin_channel(wl);
1226 else 1222 else
1227 wl1271_join_channel(wl, channel); 1223 wl1271_join_channel(wl, channel);
@@ -1234,11 +1230,12 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
1234 } 1230 }
1235 1231
1236 /* if the channel changes while joined, join again */ 1232 /* if the channel changes while joined, join again */
1237 if (channel != wl->channel && wl->joined) 1233 if (channel != wl->channel && test_bit(WL1271_FLAG_JOINED, &wl->flags))
1238 wl1271_join_channel(wl, channel); 1234 wl1271_join_channel(wl, channel);
1239 1235
1240 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { 1236 if (conf->flags & IEEE80211_CONF_PS &&
1241 wl->psm_requested = true; 1237 !test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) {
1238 set_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags);
1242 1239
1243 /* 1240 /*
1244 * We enter PSM only if we're already associated. 1241 * We enter PSM only if we're already associated.
@@ -1250,12 +1247,12 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
1250 ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE); 1247 ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
1251 } 1248 }
1252 } else if (!(conf->flags & IEEE80211_CONF_PS) && 1249 } else if (!(conf->flags & IEEE80211_CONF_PS) &&
1253 wl->psm_requested) { 1250 test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) {
1254 wl1271_info("psm disabled"); 1251 wl1271_info("psm disabled");
1255 1252
1256 wl->psm_requested = false; 1253 clear_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags);
1257 1254
1258 if (wl->psm) 1255 if (test_bit(WL1271_FLAG_PSM, &wl->flags))
1259 ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE); 1256 ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE);
1260 } 1257 }
1261 1258
@@ -1574,7 +1571,7 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
1574 wl1271_warning("cmd join failed %d", ret); 1571 wl1271_warning("cmd join failed %d", ret);
1575 goto out_sleep; 1572 goto out_sleep;
1576 } 1573 }
1577 wl->joined = true; 1574 set_bit(WL1271_FLAG_JOINED, &wl->flags);
1578 } 1575 }
1579 1576
1580 if (wl->bss_type == BSS_TYPE_IBSS) { 1577 if (wl->bss_type == BSS_TYPE_IBSS) {
@@ -1633,7 +1630,8 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
1633 goto out_sleep; 1630 goto out_sleep;
1634 1631
1635 /* If we want to go in PSM but we're not there yet */ 1632 /* If we want to go in PSM but we're not there yet */
1636 if (wl->psm_requested && !wl->psm) { 1633 if (test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags) &&
1634 !test_bit(WL1271_FLAG_PSM, &wl->flags)) {
1637 mode = STATION_POWER_SAVE_MODE; 1635 mode = STATION_POWER_SAVE_MODE;
1638 ret = wl1271_ps_set_mode(wl, mode); 1636 ret = wl1271_ps_set_mode(wl, mode);
1639 if (ret < 0) 1637 if (ret < 0)
@@ -1949,24 +1947,17 @@ static int __devinit wl1271_probe(struct spi_device *spi)
1949 1947
1950 INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work); 1948 INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work);
1951 wl->channel = WL1271_DEFAULT_CHANNEL; 1949 wl->channel = WL1271_DEFAULT_CHANNEL;
1952 wl->scanning = false;
1953 wl->default_key = 0; 1950 wl->default_key = 0;
1954 wl->rx_counter = 0; 1951 wl->rx_counter = 0;
1955 wl->rx_config = WL1271_DEFAULT_RX_CONFIG; 1952 wl->rx_config = WL1271_DEFAULT_RX_CONFIG;
1956 wl->rx_filter = WL1271_DEFAULT_RX_FILTER; 1953 wl->rx_filter = WL1271_DEFAULT_RX_FILTER;
1957 wl->elp = false;
1958 wl->psm = 0;
1959 wl->psm_requested = false;
1960 wl->psm_entry_retry = 0; 1954 wl->psm_entry_retry = 0;
1961 wl->tx_queue_stopped = false;
1962 wl->power_level = WL1271_DEFAULT_POWER_LEVEL; 1955 wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
1963 wl->basic_rate_set = CONF_TX_RATE_MASK_BASIC; 1956 wl->basic_rate_set = CONF_TX_RATE_MASK_BASIC;
1964 wl->rate_set = CONF_TX_RATE_MASK_BASIC; 1957 wl->rate_set = CONF_TX_RATE_MASK_BASIC;
1965 wl->sta_rate_set = 0; 1958 wl->sta_rate_set = 0;
1966 wl->band = IEEE80211_BAND_2GHZ; 1959 wl->band = IEEE80211_BAND_2GHZ;
1967 wl->vif = NULL; 1960 wl->vif = NULL;
1968 wl->joined = false;
1969 wl->gpio_power = false;
1970 wl->flags = 0; 1961 wl->flags = 0;
1971 1962
1972 for (i = 0; i < ACX_TX_DESCRIPTORS; i++) 1963 for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
diff --git a/drivers/net/wireless/wl12xx/wl1271_ps.c b/drivers/net/wireless/wl12xx/wl1271_ps.c
index 507cd91d7ee..e407790f677 100644
--- a/drivers/net/wireless/wl12xx/wl1271_ps.c
+++ b/drivers/net/wireless/wl12xx/wl1271_ps.c
@@ -39,12 +39,13 @@ void wl1271_elp_work(struct work_struct *work)
39 39
40 mutex_lock(&wl->mutex); 40 mutex_lock(&wl->mutex);
41 41
42 if (wl->elp || !wl->psm) 42 if (test_bit(WL1271_FLAG_IN_ELP, &wl->flags) ||
43 !test_bit(WL1271_FLAG_PSM, &wl->flags))
43 goto out; 44 goto out;
44 45
45 wl1271_debug(DEBUG_PSM, "chip to elp"); 46 wl1271_debug(DEBUG_PSM, "chip to elp");
46 wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); 47 wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP);
47 wl->elp = true; 48 set_bit(WL1271_FLAG_IN_ELP, &wl->flags);
48 49
49out: 50out:
50 mutex_unlock(&wl->mutex); 51 mutex_unlock(&wl->mutex);
@@ -55,7 +56,7 @@ out:
55/* Routines to toggle sleep mode while in ELP */ 56/* Routines to toggle sleep mode while in ELP */
56void wl1271_ps_elp_sleep(struct wl1271 *wl) 57void wl1271_ps_elp_sleep(struct wl1271 *wl)
57{ 58{
58 if (wl->psm) { 59 if (test_bit(WL1271_FLAG_PSM, &wl->flags)) {
59 cancel_delayed_work(&wl->elp_work); 60 cancel_delayed_work(&wl->elp_work);
60 ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, 61 ieee80211_queue_delayed_work(wl->hw, &wl->elp_work,
61 msecs_to_jiffies(ELP_ENTRY_DELAY)); 62 msecs_to_jiffies(ELP_ENTRY_DELAY));
@@ -70,7 +71,7 @@ int wl1271_ps_elp_wakeup(struct wl1271 *wl, bool chip_awake)
70 u32 start_time = jiffies; 71 u32 start_time = jiffies;
71 bool pending = false; 72 bool pending = false;
72 73
73 if (!wl->elp) 74 if (!test_bit(WL1271_FLAG_IN_ELP, &wl->flags))
74 return 0; 75 return 0;
75 76
76 wl1271_debug(DEBUG_PSM, "waking up chip from elp"); 77 wl1271_debug(DEBUG_PSM, "waking up chip from elp");
@@ -101,7 +102,7 @@ int wl1271_ps_elp_wakeup(struct wl1271 *wl, bool chip_awake)
101 } 102 }
102 } 103 }
103 104
104 wl->elp = false; 105 clear_bit(WL1271_FLAG_IN_ELP, &wl->flags);
105 106
106 wl1271_debug(DEBUG_PSM, "wakeup time: %u ms", 107 wl1271_debug(DEBUG_PSM, "wakeup time: %u ms",
107 jiffies_to_msecs(jiffies - start_time)); 108 jiffies_to_msecs(jiffies - start_time));
@@ -143,7 +144,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode)
143 if (ret < 0) 144 if (ret < 0)
144 return ret; 145 return ret;
145 146
146 wl->psm = 1; 147 set_bit(WL1271_FLAG_PSM, &wl->flags);
147 break; 148 break;
148 case STATION_ACTIVE_MODE: 149 case STATION_ACTIVE_MODE:
149 default: 150 default:
@@ -166,7 +167,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode)
166 if (ret < 0) 167 if (ret < 0)
167 return ret; 168 return ret;
168 169
169 wl->psm = 0; 170 clear_bit(WL1271_FLAG_PSM, &wl->flags);
170 break; 171 break;
171 } 172 }
172 173
diff --git a/drivers/net/wireless/wl12xx/wl1271_tx.c b/drivers/net/wireless/wl12xx/wl1271_tx.c
index 75f53270633..a288cc317d7 100644
--- a/drivers/net/wireless/wl12xx/wl1271_tx.c
+++ b/drivers/net/wireless/wl12xx/wl1271_tx.c
@@ -277,18 +277,18 @@ void wl1271_tx_work(struct work_struct *work)
277 wl1271_debug(DEBUG_TX, "tx_work: fw buffer full, " 277 wl1271_debug(DEBUG_TX, "tx_work: fw buffer full, "
278 "stop queues"); 278 "stop queues");
279 ieee80211_stop_queues(wl->hw); 279 ieee80211_stop_queues(wl->hw);
280 wl->tx_queue_stopped = true; 280 set_bit(WL1271_FLAG_TX_QUEUE_STOPPED, &wl->flags);
281 skb_queue_head(&wl->tx_queue, skb); 281 skb_queue_head(&wl->tx_queue, skb);
282 goto out; 282 goto out;
283 } else if (ret < 0) { 283 } else if (ret < 0) {
284 dev_kfree_skb(skb); 284 dev_kfree_skb(skb);
285 goto out; 285 goto out;
286 } else if (wl->tx_queue_stopped) { 286 } else if (test_and_clear_bit(WL1271_FLAG_TX_QUEUE_STOPPED,
287 &wl->flags)) {
287 /* firmware buffer has space, restart queues */ 288 /* firmware buffer has space, restart queues */
288 wl1271_debug(DEBUG_TX, 289 wl1271_debug(DEBUG_TX,
289 "complete_packet: waking queues"); 290 "complete_packet: waking queues");
290 ieee80211_wake_queues(wl->hw); 291 ieee80211_wake_queues(wl->hw);
291 wl->tx_queue_stopped = false;
292 } 292 }
293 } 293 }
294 294