aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-08-29 15:04:26 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-29 16:24:11 -0400
commit0262ab0df64a67d4c0ed7577a29b7d866819cc68 (patch)
tree95c5e7842787c60140fe6c35ff7a1bc8b43bebaf
parentde9cc7a4e6f975ca5e91cf8745b3e35a7e780bae (diff)
rt2x00: Fix race conditions in flag handling
Some of the flags should be accessed atomically to prevent race conditions. The flags that are most important are those that can change often and indicate the actual state of the device, queue or queue entry. The big flag rename was done to move all state flags to the same naming type as the other rt2x00dev flags and made sure all places where the flags were used were changed. ;) Thanks to Stephen for most of the queue flags updates, which fixes some of the most obvious consequences of the race conditions. Among those the notorious: rt2x00queue_write_tx_frame: Error - Arrived at non-free entry in the non-full queue 0. rt2x00queue_write_tx_frame: Error - Arrived at non-free entry in the non-full queue 0. rt2x00queue_write_tx_frame: Error - Arrived at non-free entry in the non-full queue 0. Signed-off-by: Stephen Blackheath <tramp.enshrine.stephen@blacksapphire.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h16
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00config.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c58
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c26
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00rfkill.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c10
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c2
11 files changed, 68 insertions, 66 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 0107cec18b26..18b703c3fc2c 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -1241,7 +1241,7 @@ static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance)
1241 if (!reg) 1241 if (!reg)
1242 return IRQ_NONE; 1242 return IRQ_NONE;
1243 1243
1244 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 1244 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
1245 return IRQ_HANDLED; 1245 return IRQ_HANDLED;
1246 1246
1247 /* 1247 /*
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index e0ff76ff490d..5cc706a45e59 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1377,7 +1377,7 @@ static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance)
1377 if (!reg) 1377 if (!reg)
1378 return IRQ_NONE; 1378 return IRQ_NONE;
1379 1379
1380 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 1380 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
1381 return IRQ_HANDLED; 1381 return IRQ_HANDLED;
1382 1382
1383 /* 1383 /*
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 3b90ed622148..c6be4dd81b1a 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1297,7 +1297,7 @@ static void rt2500usb_beacondone(struct urb *urb)
1297 struct queue_entry *entry = (struct queue_entry *)urb->context; 1297 struct queue_entry *entry = (struct queue_entry *)urb->context;
1298 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data; 1298 struct queue_entry_priv_usb_bcn *bcn_priv = entry->priv_data;
1299 1299
1300 if (!test_bit(DEVICE_ENABLED_RADIO, &entry->queue->rt2x00dev->flags)) 1300 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &entry->queue->rt2x00dev->flags))
1301 return; 1301 return;
1302 1302
1303 /* 1303 /*
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index 3fa3d5b006a6..08095bf3f8f1 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -629,14 +629,14 @@ enum rt2x00_flags {
629 /* 629 /*
630 * Device state flags 630 * Device state flags
631 */ 631 */
632 DEVICE_PRESENT, 632 DEVICE_STATE_PRESENT,
633 DEVICE_REGISTERED_HW, 633 DEVICE_STATE_REGISTERED_HW,
634 DEVICE_INITIALIZED, 634 DEVICE_STATE_INITIALIZED,
635 DEVICE_STARTED, 635 DEVICE_STATE_STARTED,
636 DEVICE_STARTED_SUSPEND, 636 DEVICE_STATE_STARTED_SUSPEND,
637 DEVICE_ENABLED_RADIO, 637 DEVICE_STATE_ENABLED_RADIO,
638 DEVICE_DISABLED_RADIO_HW, 638 DEVICE_STATE_DISABLED_RADIO_HW,
639 DEVICE_DIRTY_CONFIG, 639 DEVICE_STATE_DIRTY_CONFIG,
640 640
641 /* 641 /*
642 * Driver requirements 642 * Driver requirements
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c
index ea37c7962043..ca051f50ef10 100644
--- a/drivers/net/wireless/rt2x00/rt2x00config.c
+++ b/drivers/net/wireless/rt2x00/rt2x00config.c
@@ -121,7 +121,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
121 * Antenna setup changes require the RX to be disabled, 121 * Antenna setup changes require the RX to be disabled,
122 * else the changes will be ignored by the device. 122 * else the changes will be ignored by the device.
123 */ 123 */
124 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 124 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
125 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF_LINK); 125 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF_LINK);
126 126
127 /* 127 /*
@@ -136,7 +136,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
136 rt2x00dev->link.ant.active.rx = libconf.ant.rx; 136 rt2x00dev->link.ant.active.rx = libconf.ant.rx;
137 rt2x00dev->link.ant.active.tx = libconf.ant.tx; 137 rt2x00dev->link.ant.active.tx = libconf.ant.tx;
138 138
139 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 139 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
140 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK); 140 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK);
141} 141}
142 142
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 328ff8bc4c16..330ab77902f7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -34,7 +34,7 @@
34 */ 34 */
35void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev) 35void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev)
36{ 36{
37 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 37 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
38 return; 38 return;
39 39
40 /* 40 /*
@@ -94,8 +94,8 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
94 * Don't enable the radio twice. 94 * Don't enable the radio twice.
95 * And check if the hardware button has been disabled. 95 * And check if the hardware button has been disabled.
96 */ 96 */
97 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || 97 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags) ||
98 test_bit(DEVICE_DISABLED_RADIO_HW, &rt2x00dev->flags)) 98 test_bit(DEVICE_STATE_DISABLED_RADIO_HW, &rt2x00dev->flags))
99 return 0; 99 return 0;
100 100
101 /* 101 /*
@@ -117,7 +117,7 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
117 rt2x00leds_led_radio(rt2x00dev, true); 117 rt2x00leds_led_radio(rt2x00dev, true);
118 rt2x00led_led_activity(rt2x00dev, true); 118 rt2x00led_led_activity(rt2x00dev, true);
119 119
120 __set_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags); 120 set_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags);
121 121
122 /* 122 /*
123 * Enable RX. 123 * Enable RX.
@@ -134,7 +134,7 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
134 134
135void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev) 135void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
136{ 136{
137 if (!__test_and_clear_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 137 if (!test_and_clear_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
138 return; 138 return;
139 139
140 /* 140 /*
@@ -354,7 +354,7 @@ static void rt2x00lib_link_tuner(struct work_struct *work)
354 * When the radio is shutting down we should 354 * When the radio is shutting down we should
355 * immediately cease all link tuning. 355 * immediately cease all link tuning.
356 */ 356 */
357 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 357 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
358 return; 358 return;
359 359
360 /* 360 /*
@@ -431,7 +431,7 @@ static void rt2x00lib_intf_scheduled_iter(void *data, u8 *mac,
431 * note that in the spinlock protected area above the delayed_flags 431 * note that in the spinlock protected area above the delayed_flags
432 * have been cleared correctly. 432 * have been cleared correctly.
433 */ 433 */
434 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 434 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
435 return; 435 return;
436 436
437 if (delayed_flags & DELAYED_UPDATE_BEACON) 437 if (delayed_flags & DELAYED_UPDATE_BEACON)
@@ -484,7 +484,7 @@ static void rt2x00lib_beacondone_iter(void *data, u8 *mac,
484 484
485void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev) 485void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev)
486{ 486{
487 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 487 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
488 return; 488 return;
489 489
490 ieee80211_iterate_active_interfaces_atomic(rt2x00dev->hw, 490 ieee80211_iterate_active_interfaces_atomic(rt2x00dev->hw,
@@ -572,7 +572,7 @@ void rt2x00lib_txdone(struct queue_entry *entry,
572 572
573 rt2x00dev->ops->lib->init_txentry(rt2x00dev, entry); 573 rt2x00dev->ops->lib->init_txentry(rt2x00dev, entry);
574 574
575 __clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 575 clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
576 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE); 576 rt2x00queue_index_inc(entry->queue, Q_INDEX_DONE);
577 577
578 /* 578 /*
@@ -888,7 +888,7 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
888 888
889static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev) 889static void rt2x00lib_remove_hw(struct rt2x00_dev *rt2x00dev)
890{ 890{
891 if (test_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags)) 891 if (test_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags))
892 ieee80211_unregister_hw(rt2x00dev->hw); 892 ieee80211_unregister_hw(rt2x00dev->hw);
893 893
894 if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) { 894 if (likely(rt2x00dev->hw->wiphy->bands[IEEE80211_BAND_2GHZ])) {
@@ -906,6 +906,9 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
906 struct hw_mode_spec *spec = &rt2x00dev->spec; 906 struct hw_mode_spec *spec = &rt2x00dev->spec;
907 int status; 907 int status;
908 908
909 if (test_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags))
910 return 0;
911
909 /* 912 /*
910 * Initialize HW modes. 913 * Initialize HW modes.
911 */ 914 */
@@ -927,7 +930,7 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
927 return status; 930 return status;
928 } 931 }
929 932
930 __set_bit(DEVICE_REGISTERED_HW, &rt2x00dev->flags); 933 set_bit(DEVICE_STATE_REGISTERED_HW, &rt2x00dev->flags);
931 934
932 return 0; 935 return 0;
933} 936}
@@ -937,7 +940,7 @@ static int rt2x00lib_probe_hw(struct rt2x00_dev *rt2x00dev)
937 */ 940 */
938static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev) 941static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
939{ 942{
940 if (!__test_and_clear_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) 943 if (!test_and_clear_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags))
941 return; 944 return;
942 945
943 /* 946 /*
@@ -960,7 +963,7 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
960{ 963{
961 int status; 964 int status;
962 965
963 if (test_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) 966 if (test_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags))
964 return 0; 967 return 0;
965 968
966 /* 969 /*
@@ -979,7 +982,7 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
979 return status; 982 return status;
980 } 983 }
981 984
982 __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags); 985 set_bit(DEVICE_STATE_INITIALIZED, &rt2x00dev->flags);
983 986
984 /* 987 /*
985 * Register the extra components. 988 * Register the extra components.
@@ -993,7 +996,7 @@ int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
993{ 996{
994 int retval; 997 int retval;
995 998
996 if (test_bit(DEVICE_STARTED, &rt2x00dev->flags)) 999 if (test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
997 return 0; 1000 return 0;
998 1001
999 /* 1002 /*
@@ -1024,15 +1027,15 @@ int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
1024 rt2x00dev->intf_sta_count = 0; 1027 rt2x00dev->intf_sta_count = 0;
1025 rt2x00dev->intf_associated = 0; 1028 rt2x00dev->intf_associated = 0;
1026 1029
1027 __set_bit(DEVICE_STARTED, &rt2x00dev->flags); 1030 set_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags);
1028 __set_bit(DEVICE_DIRTY_CONFIG, &rt2x00dev->flags); 1031 set_bit(DEVICE_STATE_DIRTY_CONFIG, &rt2x00dev->flags);
1029 1032
1030 return 0; 1033 return 0;
1031} 1034}
1032 1035
1033void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev) 1036void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev)
1034{ 1037{
1035 if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags)) 1038 if (!test_and_clear_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
1036 return; 1039 return;
1037 1040
1038 /* 1041 /*
@@ -1044,8 +1047,6 @@ void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev)
1044 rt2x00dev->intf_ap_count = 0; 1047 rt2x00dev->intf_ap_count = 0;
1045 rt2x00dev->intf_sta_count = 0; 1048 rt2x00dev->intf_sta_count = 0;
1046 rt2x00dev->intf_associated = 0; 1049 rt2x00dev->intf_associated = 0;
1047
1048 __clear_bit(DEVICE_STARTED, &rt2x00dev->flags);
1049} 1050}
1050 1051
1051/* 1052/*
@@ -1100,7 +1101,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
1100 rt2x00rfkill_allocate(rt2x00dev); 1101 rt2x00rfkill_allocate(rt2x00dev);
1101 rt2x00debug_register(rt2x00dev); 1102 rt2x00debug_register(rt2x00dev);
1102 1103
1103 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags); 1104 set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
1104 1105
1105 return 0; 1106 return 0;
1106 1107
@@ -1113,7 +1114,7 @@ EXPORT_SYMBOL_GPL(rt2x00lib_probe_dev);
1113 1114
1114void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) 1115void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)
1115{ 1116{
1116 __clear_bit(DEVICE_PRESENT, &rt2x00dev->flags); 1117 clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
1117 1118
1118 /* 1119 /*
1119 * Disable radio. 1120 * Disable radio.
@@ -1158,14 +1159,15 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1158 int retval; 1159 int retval;
1159 1160
1160 NOTICE(rt2x00dev, "Going to sleep.\n"); 1161 NOTICE(rt2x00dev, "Going to sleep.\n");
1161 __clear_bit(DEVICE_PRESENT, &rt2x00dev->flags);
1162 1162
1163 /* 1163 /*
1164 * Only continue if mac80211 has open interfaces. 1164 * Only continue if mac80211 has open interfaces.
1165 */ 1165 */
1166 if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags)) 1166 if (!test_and_clear_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
1167 !test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
1167 goto exit; 1168 goto exit;
1168 __set_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags); 1169
1170 set_bit(DEVICE_STATE_STARTED_SUSPEND, &rt2x00dev->flags);
1169 1171
1170 /* 1172 /*
1171 * Disable radio. 1173 * Disable radio.
@@ -1237,7 +1239,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1237 /* 1239 /*
1238 * Only continue if mac80211 had open interfaces. 1240 * Only continue if mac80211 had open interfaces.
1239 */ 1241 */
1240 if (!__test_and_clear_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags)) 1242 if (!test_and_clear_bit(DEVICE_STATE_STARTED_SUSPEND, &rt2x00dev->flags))
1241 return 0; 1243 return 0;
1242 1244
1243 /* 1245 /*
@@ -1264,7 +1266,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1264 /* 1266 /*
1265 * We are ready again to receive requests from mac80211. 1267 * We are ready again to receive requests from mac80211.
1266 */ 1268 */
1267 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags); 1269 set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags);
1268 1270
1269 /* 1271 /*
1270 * It is possible that during that mac80211 has attempted 1272 * It is possible that during that mac80211 has attempted
@@ -1284,7 +1286,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1284 return 0; 1286 return 0;
1285 1287
1286exit: 1288exit:
1287 rt2x00lib_disable_radio(rt2x00dev); 1289 rt2x00lib_stop(rt2x00dev);
1288 rt2x00lib_uninitialize(rt2x00dev); 1290 rt2x00lib_uninitialize(rt2x00dev);
1289 rt2x00debug_deregister(rt2x00dev); 1291 rt2x00debug_deregister(rt2x00dev);
1290 1292
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 3af427339417..11be8957b5c2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -117,7 +117,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
117 * Note that we can only stop the TX queues inside the TX path 117 * Note that we can only stop the TX queues inside the TX path
118 * due to possible race conditions in mac80211. 118 * due to possible race conditions in mac80211.
119 */ 119 */
120 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags)) 120 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
121 goto exit_fail; 121 goto exit_fail;
122 122
123 /* 123 /*
@@ -175,7 +175,7 @@ int rt2x00mac_start(struct ieee80211_hw *hw)
175{ 175{
176 struct rt2x00_dev *rt2x00dev = hw->priv; 176 struct rt2x00_dev *rt2x00dev = hw->priv;
177 177
178 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags)) 178 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
179 return 0; 179 return 0;
180 180
181 return rt2x00lib_start(rt2x00dev); 181 return rt2x00lib_start(rt2x00dev);
@@ -186,7 +186,7 @@ void rt2x00mac_stop(struct ieee80211_hw *hw)
186{ 186{
187 struct rt2x00_dev *rt2x00dev = hw->priv; 187 struct rt2x00_dev *rt2x00dev = hw->priv;
188 188
189 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags)) 189 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
190 return; 190 return;
191 191
192 rt2x00lib_stop(rt2x00dev); 192 rt2x00lib_stop(rt2x00dev);
@@ -206,8 +206,8 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
206 * Don't allow interfaces to be added 206 * Don't allow interfaces to be added
207 * the device has disappeared. 207 * the device has disappeared.
208 */ 208 */
209 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags) || 209 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
210 !test_bit(DEVICE_STARTED, &rt2x00dev->flags)) 210 !test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
211 return -ENODEV; 211 return -ENODEV;
212 212
213 switch (conf->type) { 213 switch (conf->type) {
@@ -256,7 +256,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
256 */ 256 */
257 for (i = 0; i < queue->limit; i++) { 257 for (i = 0; i < queue->limit; i++) {
258 entry = &queue->entries[i]; 258 entry = &queue->entries[i];
259 if (!__test_and_set_bit(ENTRY_BCN_ASSIGNED, &entry->flags)) 259 if (!test_and_set_bit(ENTRY_BCN_ASSIGNED, &entry->flags))
260 break; 260 break;
261 } 261 }
262 262
@@ -310,7 +310,7 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
310 * either the device has disappeared or when 310 * either the device has disappeared or when
311 * no interface is present. 311 * no interface is present.
312 */ 312 */
313 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags) || 313 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
314 (conf->type == IEEE80211_IF_TYPE_AP && !rt2x00dev->intf_ap_count) || 314 (conf->type == IEEE80211_IF_TYPE_AP && !rt2x00dev->intf_ap_count) ||
315 (conf->type != IEEE80211_IF_TYPE_AP && !rt2x00dev->intf_sta_count)) 315 (conf->type != IEEE80211_IF_TYPE_AP && !rt2x00dev->intf_sta_count))
316 return; 316 return;
@@ -324,7 +324,7 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
324 * Release beacon entry so it is available for 324 * Release beacon entry so it is available for
325 * new interfaces again. 325 * new interfaces again.
326 */ 326 */
327 __clear_bit(ENTRY_BCN_ASSIGNED, &intf->beacon->flags); 327 clear_bit(ENTRY_BCN_ASSIGNED, &intf->beacon->flags);
328 328
329 /* 329 /*
330 * Make sure the bssid and mac address registers 330 * Make sure the bssid and mac address registers
@@ -344,14 +344,14 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
344 * Mac80211 might be calling this function while we are trying 344 * Mac80211 might be calling this function while we are trying
345 * to remove the device or perhaps suspending it. 345 * to remove the device or perhaps suspending it.
346 */ 346 */
347 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags)) 347 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
348 return 0; 348 return 0;
349 349
350 /* 350 /*
351 * Check if we need to disable the radio, 351 * Check if we need to disable the radio,
352 * if this is not the case, at least the RX must be disabled. 352 * if this is not the case, at least the RX must be disabled.
353 */ 353 */
354 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) { 354 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) {
355 if (!conf->radio_enabled) 355 if (!conf->radio_enabled)
356 rt2x00lib_disable_radio(rt2x00dev); 356 rt2x00lib_disable_radio(rt2x00dev);
357 else 357 else
@@ -366,14 +366,14 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
366 * initialized. 366 * initialized.
367 */ 367 */
368 force_reconfig = 368 force_reconfig =
369 __test_and_clear_bit(DEVICE_DIRTY_CONFIG, &rt2x00dev->flags); 369 test_and_clear_bit(DEVICE_STATE_DIRTY_CONFIG, &rt2x00dev->flags);
370 370
371 rt2x00lib_config(rt2x00dev, conf, force_reconfig); 371 rt2x00lib_config(rt2x00dev, conf, force_reconfig);
372 372
373 /* 373 /*
374 * Reenable RX only if the radio should be on. 374 * Reenable RX only if the radio should be on.
375 */ 375 */
376 if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 376 if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
377 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON); 377 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
378 else if (conf->radio_enabled) 378 else if (conf->radio_enabled)
379 return rt2x00lib_enable_radio(rt2x00dev); 379 return rt2x00lib_enable_radio(rt2x00dev);
@@ -395,7 +395,7 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw,
395 * Mac80211 might be calling this function while we are trying 395 * Mac80211 might be calling this function while we are trying
396 * to remove the device or perhaps suspending it. 396 * to remove the device or perhaps suspending it.
397 */ 397 */
398 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags)) 398 if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
399 return 0; 399 return 0;
400 400
401 spin_lock(&intf->lock); 401 spin_lock(&intf->lock);
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index c0f97c53e5ce..d10a8012f387 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -356,7 +356,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
356 if (unlikely(rt2x00queue_full(queue))) 356 if (unlikely(rt2x00queue_full(queue)))
357 return -EINVAL; 357 return -EINVAL;
358 358
359 if (__test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) { 359 if (test_and_set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) {
360 ERROR(queue->rt2x00dev, 360 ERROR(queue->rt2x00dev,
361 "Arrived at non-free entry in the non-full queue %d.\n" 361 "Arrived at non-free entry in the non-full queue %d.\n"
362 "Please file bug report to %s.\n", 362 "Please file bug report to %s.\n",
@@ -396,7 +396,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
396 * the frame to mac80211 because the skb->cb has now been tainted. 396 * the frame to mac80211 because the skb->cb has now been tainted.
397 */ 397 */
398 if (unlikely(queue->rt2x00dev->ops->lib->write_tx_data(entry))) { 398 if (unlikely(queue->rt2x00dev->ops->lib->write_tx_data(entry))) {
399 __clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 399 clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
400 dev_kfree_skb_any(entry->skb); 400 dev_kfree_skb_any(entry->skb);
401 entry->skb = NULL; 401 entry->skb = NULL;
402 return 0; 402 return 0;
@@ -405,7 +405,7 @@ int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb)
405 if (test_bit(DRIVER_REQUIRE_DMA, &queue->rt2x00dev->flags)) 405 if (test_bit(DRIVER_REQUIRE_DMA, &queue->rt2x00dev->flags))
406 rt2x00queue_map_txskb(queue->rt2x00dev, skb); 406 rt2x00queue_map_txskb(queue->rt2x00dev, skb);
407 407
408 __set_bit(ENTRY_DATA_PENDING, &entry->flags); 408 set_bit(ENTRY_DATA_PENDING, &entry->flags);
409 409
410 rt2x00queue_index_inc(queue, Q_INDEX); 410 rt2x00queue_index_inc(queue, Q_INDEX);
411 rt2x00queue_write_tx_descriptor(entry, &txdesc); 411 rt2x00queue_write_tx_descriptor(entry, &txdesc);
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
index 04b29716d356..8a2fefb365b7 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -41,16 +41,16 @@ static int rt2x00rfkill_toggle_radio(void *data, enum rfkill_state state)
41 /* 41 /*
42 * Only continue if there are enabled interfaces. 42 * Only continue if there are enabled interfaces.
43 */ 43 */
44 if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags)) 44 if (!test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
45 return 0; 45 return 0;
46 46
47 if (state == RFKILL_STATE_UNBLOCKED) { 47 if (state == RFKILL_STATE_UNBLOCKED) {
48 INFO(rt2x00dev, "Hardware button pressed, enabling radio.\n"); 48 INFO(rt2x00dev, "Hardware button pressed, enabling radio.\n");
49 __clear_bit(DEVICE_DISABLED_RADIO_HW, &rt2x00dev->flags); 49 clear_bit(DEVICE_STATE_DISABLED_RADIO_HW, &rt2x00dev->flags);
50 retval = rt2x00lib_enable_radio(rt2x00dev); 50 retval = rt2x00lib_enable_radio(rt2x00dev);
51 } else if (state == RFKILL_STATE_SOFT_BLOCKED) { 51 } else if (state == RFKILL_STATE_SOFT_BLOCKED) {
52 INFO(rt2x00dev, "Hardware button pressed, disabling radio.\n"); 52 INFO(rt2x00dev, "Hardware button pressed, disabling radio.\n");
53 __set_bit(DEVICE_DISABLED_RADIO_HW, &rt2x00dev->flags); 53 set_bit(DEVICE_STATE_DISABLED_RADIO_HW, &rt2x00dev->flags);
54 rt2x00lib_disable_radio(rt2x00dev); 54 rt2x00lib_disable_radio(rt2x00dev);
55 } else { 55 } else {
56 WARNING(rt2x00dev, "Received unexpected rfkill state %d.\n", 56 WARNING(rt2x00dev, "Received unexpected rfkill state %d.\n",
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 2050227ea530..2dd7c830c125 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -163,7 +163,7 @@ static void rt2x00usb_interrupt_txdone(struct urb *urb)
163 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 163 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
164 struct txdone_entry_desc txdesc; 164 struct txdone_entry_desc txdesc;
165 165
166 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || 166 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags) ||
167 !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) 167 !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
168 return; 168 return;
169 169
@@ -232,7 +232,7 @@ static inline void rt2x00usb_kick_tx_entry(struct queue_entry *entry)
232{ 232{
233 struct queue_entry_priv_usb *entry_priv = entry->priv_data; 233 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
234 234
235 if (__test_and_clear_bit(ENTRY_DATA_PENDING, &entry->flags)) 235 if (test_and_clear_bit(ENTRY_DATA_PENDING, &entry->flags))
236 usb_submit_urb(entry_priv->urb, GFP_ATOMIC); 236 usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
237} 237}
238 238
@@ -283,7 +283,7 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
283 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 283 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
284 u8 rxd[32]; 284 u8 rxd[32];
285 285
286 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) || 286 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags) ||
287 !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags)) 287 !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
288 return; 288 return;
289 289
@@ -293,7 +293,7 @@ static void rt2x00usb_interrupt_rxdone(struct urb *urb)
293 * a problem. 293 * a problem.
294 */ 294 */
295 if (urb->actual_length < entry->queue->desc_size || urb->status) { 295 if (urb->actual_length < entry->queue->desc_size || urb->status) {
296 __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 296 set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
297 usb_submit_urb(urb, GFP_ATOMIC); 297 usb_submit_urb(urb, GFP_ATOMIC);
298 return; 298 return;
299 } 299 }
@@ -361,7 +361,7 @@ void rt2x00usb_init_rxentry(struct rt2x00_dev *rt2x00dev,
361 entry->skb->data, entry->skb->len, 361 entry->skb->data, entry->skb->len,
362 rt2x00usb_interrupt_rxdone, entry); 362 rt2x00usb_interrupt_rxdone, entry);
363 363
364 __set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags); 364 set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
365 usb_submit_urb(entry_priv->urb, GFP_ATOMIC); 365 usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
366} 366}
367EXPORT_SYMBOL_GPL(rt2x00usb_init_rxentry); 367EXPORT_SYMBOL_GPL(rt2x00usb_init_rxentry);
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 23cf93dfda06..9d27ce0e54fe 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2121,7 +2121,7 @@ static irqreturn_t rt61pci_interrupt(int irq, void *dev_instance)
2121 if (!reg && !reg_mcu) 2121 if (!reg && !reg_mcu)
2122 return IRQ_NONE; 2122 return IRQ_NONE;
2123 2123
2124 if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags)) 2124 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
2125 return IRQ_HANDLED; 2125 return IRQ_HANDLED;
2126 2126
2127 /* 2127 /*