aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00mac.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2007-09-25 14:55:39 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:53:03 -0400
commit066cb637b1b562bebd09d237bfaaca6724f247e5 (patch)
tree340b3902e69246cb73e820bbd9994bd1bdcca402 /drivers/net/wireless/rt2x00/rt2x00mac.c
parent12dadb9009723dd0512091643e6e403f9e1b25cb (diff)
[PATCH] rt2x00: Reorganize rt2x00dev->flags
The rt2x00dev->flags has become a chaos over time, this will reorganize the flags by renaming, deleting, adding and properly implement the flags. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00mac.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 17802f6d3d6d..e98d013a189f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -82,6 +82,17 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
82 u16 frame_control; 82 u16 frame_control;
83 83
84 /* 84 /*
85 * Mac80211 might be calling this function while we are trying
86 * to remove the device or perhaps suspending it.
87 * Note that we can only stop the TX queues inside the TX path
88 * due to possible race conditions in mac80211.
89 */
90 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags)) {
91 ieee80211_stop_queues(hw);
92 return 0;
93 }
94
95 /*
85 * Determine which ring to put packet on. 96 * Determine which ring to put packet on.
86 */ 97 */
87 ring = rt2x00lib_get_ring(rt2x00dev, control->queue); 98 ring = rt2x00lib_get_ring(rt2x00dev, control->queue);
@@ -126,14 +137,15 @@ int rt2x00mac_start(struct ieee80211_hw *hw)
126 struct rt2x00_dev *rt2x00dev = hw->priv; 137 struct rt2x00_dev *rt2x00dev = hw->priv;
127 int status; 138 int status;
128 139
129 if (test_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) 140 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags) ||
141 test_bit(DEVICE_STARTED, &rt2x00dev->flags))
130 return 0; 142 return 0;
131 143
132 /* 144 /*
133 * If this is the first interface which is added, 145 * If this is the first interface which is added,
134 * we should load the firmware now. 146 * we should load the firmware now.
135 */ 147 */
136 if (test_bit(REQUIRE_FIRMWARE, &rt2x00dev->flags)) { 148 if (test_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags)) {
137 status = rt2x00lib_load_firmware(rt2x00dev); 149 status = rt2x00lib_load_firmware(rt2x00dev);
138 if (status) 150 if (status)
139 return status; 151 return status;
@@ -155,6 +167,8 @@ int rt2x00mac_start(struct ieee80211_hw *hw)
155 return status; 167 return status;
156 } 168 }
157 169
170 __set_bit(DEVICE_STARTED, &rt2x00dev->flags);
171
158 return 0; 172 return 0;
159} 173}
160EXPORT_SYMBOL_GPL(rt2x00mac_start); 174EXPORT_SYMBOL_GPL(rt2x00mac_start);
@@ -163,11 +177,16 @@ void rt2x00mac_stop(struct ieee80211_hw *hw)
163{ 177{
164 struct rt2x00_dev *rt2x00dev = hw->priv; 178 struct rt2x00_dev *rt2x00dev = hw->priv;
165 179
180 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags))
181 return;
182
166 /* 183 /*
167 * Perhaps we can add something smarter here, 184 * Perhaps we can add something smarter here,
168 * but for now just disabling the radio should do. 185 * but for now just disabling the radio should do.
169 */ 186 */
170 rt2x00lib_disable_radio(rt2x00dev); 187 rt2x00lib_disable_radio(rt2x00dev);
188
189 __clear_bit(DEVICE_STARTED, &rt2x00dev->flags);
171} 190}
172EXPORT_SYMBOL_GPL(rt2x00mac_stop); 191EXPORT_SYMBOL_GPL(rt2x00mac_stop);
173 192
@@ -178,9 +197,12 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
178 struct interface *intf = &rt2x00dev->interface; 197 struct interface *intf = &rt2x00dev->interface;
179 198
180 /* 199 /*
181 * We only support 1 non-monitor interface. 200 * Don't allow interfaces to be added while
201 * either the device has disappeared or when
202 * another interface is already present.
182 */ 203 */
183 if (is_interface_present(intf)) 204 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags) ||
205 is_interface_present(intf))
184 return -ENOBUFS; 206 return -ENOBUFS;
185 207
186 intf->id = conf->if_id; 208 intf->id = conf->if_id;
@@ -208,9 +230,12 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
208 struct interface *intf = &rt2x00dev->interface; 230 struct interface *intf = &rt2x00dev->interface;
209 231
210 /* 232 /*
211 * We only support 1 non-monitor interface. 233 * Don't allow interfaces to be remove while
234 * either the device has disappeared or when
235 * no interface is present.
212 */ 236 */
213 if (!is_interface_present(intf)) 237 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags) ||
238 !is_interface_present(intf))
214 return; 239 return;
215 240
216 intf->id = 0; 241 intf->id = 0;
@@ -233,12 +258,10 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
233 struct rt2x00_dev *rt2x00dev = hw->priv; 258 struct rt2x00_dev *rt2x00dev = hw->priv;
234 259
235 /* 260 /*
236 * If the device is not initialized we shouldn't accept 261 * Mac80211 might be calling this function while we are trying
237 * any configuration changes. Mac80211 might be calling 262 * to remove the device or perhaps suspending it.
238 * this function while we are trying to remove the device
239 * or perhaps suspending it.
240 */ 263 */
241 if (!test_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) 264 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags))
242 return 0; 265 return 0;
243 266
244 /* 267 /*
@@ -252,7 +275,7 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
252 rt2x00lib_toggle_rx(rt2x00dev, 0); 275 rt2x00lib_toggle_rx(rt2x00dev, 0);
253 } 276 }
254 277
255 rt2x00lib_config(rt2x00dev, conf); 278 rt2x00lib_config(rt2x00dev, conf, 0);
256 279
257 /* 280 /*
258 * Reenable RX only if the radio should be on. 281 * Reenable RX only if the radio should be on.
@@ -274,12 +297,10 @@ int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id,
274 int status; 297 int status;
275 298
276 /* 299 /*
277 * If the device is not initialized we shouldn't accept 300 * Mac80211 might be calling this function while we are trying
278 * any configuration changes. Mac80211 might be calling 301 * to remove the device or perhaps suspending it.
279 * this function while we are trying to remove the device
280 * or perhaps suspending it.
281 */ 302 */
282 if (!test_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) 303 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags))
283 return 0; 304 return 0;
284 305
285 /* 306 /*