aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-01-06 17:40:07 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:24 -0500
commite37ea2135be080dd25f1a2644c9132c109fa77d1 (patch)
tree9e4960846d844f6ae03de2e05b958c156f164976 /drivers/net/wireless/rt2x00
parent042671040db95a896c5ca960b9b656692a787892 (diff)
rt2x00: Move start() and stop() handlers into rt2x00lib.c
suspend & resume was broken since it called rt2x00mac_start() and rt2x00mac_stop() which would fail to execute because the DEVICE_PRESENT flag was not set. Move the start and stop handlers into rt2x00lib.c which are called from rt2x00mac_start() and rt2x00mac_stop() after they have checked the DEVICE_PRESENT flag, while suspend and resume handlers can directly call those functions. 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')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c66
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00mac.c42
3 files changed, 66 insertions, 46 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 9b2bd9176467..cea2bd91ff5f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1046,7 +1046,7 @@ static void rt2x00lib_free_ring_entries(struct rt2x00_dev *rt2x00dev)
1046 } 1046 }
1047} 1047}
1048 1048
1049void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev) 1049static void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
1050{ 1050{
1051 if (!__test_and_clear_bit(DEVICE_INITIALIZED, &rt2x00dev->flags)) 1051 if (!__test_and_clear_bit(DEVICE_INITIALIZED, &rt2x00dev->flags))
1052 return; 1052 return;
@@ -1067,7 +1067,7 @@ void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev)
1067 rt2x00lib_free_ring_entries(rt2x00dev); 1067 rt2x00lib_free_ring_entries(rt2x00dev);
1068} 1068}
1069 1069
1070int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev) 1070static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1071{ 1071{
1072 int status; 1072 int status;
1073 1073
@@ -1110,6 +1110,58 @@ exit:
1110 return status; 1110 return status;
1111} 1111}
1112 1112
1113int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
1114{
1115 int retval;
1116
1117 if (test_bit(DEVICE_STARTED, &rt2x00dev->flags))
1118 return 0;
1119
1120 /*
1121 * If this is the first interface which is added,
1122 * we should load the firmware now.
1123 */
1124 if (test_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags)) {
1125 retval = rt2x00lib_load_firmware(rt2x00dev);
1126 if (retval)
1127 return retval;
1128 }
1129
1130 /*
1131 * Initialize the device.
1132 */
1133 retval = rt2x00lib_initialize(rt2x00dev);
1134 if (retval)
1135 return retval;
1136
1137 /*
1138 * Enable radio.
1139 */
1140 retval = rt2x00lib_enable_radio(rt2x00dev);
1141 if (retval) {
1142 rt2x00lib_uninitialize(rt2x00dev);
1143 return retval;
1144 }
1145
1146 __set_bit(DEVICE_STARTED, &rt2x00dev->flags);
1147
1148 return 0;
1149}
1150
1151void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev)
1152{
1153 if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
1154 return;
1155
1156 /*
1157 * Perhaps we can add something smarter here,
1158 * but for now just disabling the radio should do.
1159 */
1160 rt2x00lib_disable_radio(rt2x00dev);
1161
1162 __clear_bit(DEVICE_STARTED, &rt2x00dev->flags);
1163}
1164
1113/* 1165/*
1114 * driver allocation handlers. 1166 * driver allocation handlers.
1115 */ 1167 */
@@ -1295,7 +1347,7 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
1295 * Disable radio and unitialize all items 1347 * Disable radio and unitialize all items
1296 * that must be recreated on resume. 1348 * that must be recreated on resume.
1297 */ 1349 */
1298 rt2x00mac_stop(rt2x00dev->hw); 1350 rt2x00lib_stop(rt2x00dev);
1299 rt2x00lib_uninitialize(rt2x00dev); 1351 rt2x00lib_uninitialize(rt2x00dev);
1300 rt2x00debug_deregister(rt2x00dev); 1352 rt2x00debug_deregister(rt2x00dev);
1301 1353
@@ -1317,7 +1369,6 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1317 int retval; 1369 int retval;
1318 1370
1319 NOTICE(rt2x00dev, "Waking up.\n"); 1371 NOTICE(rt2x00dev, "Waking up.\n");
1320 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags);
1321 1372
1322 /* 1373 /*
1323 * Open the debugfs entry. 1374 * Open the debugfs entry.
@@ -1333,7 +1384,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1333 /* 1384 /*
1334 * Reinitialize device and all active interfaces. 1385 * Reinitialize device and all active interfaces.
1335 */ 1386 */
1336 retval = rt2x00mac_start(rt2x00dev->hw); 1387 retval = rt2x00lib_start(rt2x00dev);
1337 if (retval) 1388 if (retval)
1338 goto exit; 1389 goto exit;
1339 1390
@@ -1349,6 +1400,11 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
1349 rt2x00lib_config_type(rt2x00dev, intf->type); 1400 rt2x00lib_config_type(rt2x00dev, intf->type);
1350 1401
1351 /* 1402 /*
1403 * We are ready again to receive requests from mac80211.
1404 */
1405 __set_bit(DEVICE_PRESENT, &rt2x00dev->flags);
1406
1407 /*
1352 * It is possible that during that mac80211 has attempted 1408 * It is possible that during that mac80211 has attempted
1353 * to send frames while we were suspending or resuming. 1409 * to send frames while we were suspending or resuming.
1354 * In that case we have disabled the TX queue and should 1410 * In that case we have disabled the TX queue and should
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 108488ddbbb9..1adbd28e0973 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -44,8 +44,8 @@ void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev);
44/* 44/*
45 * Initialization handlers. 45 * Initialization handlers.
46 */ 46 */
47int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev); 47int rt2x00lib_start(struct rt2x00_dev *rt2x00dev);
48void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev); 48void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev);
49 49
50/* 50/*
51 * Configuration handlers. 51 * Configuration handlers.
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 1ab2fb6c38da..e99d167d7df6 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -139,41 +139,11 @@ EXPORT_SYMBOL_GPL(rt2x00mac_tx);
139int rt2x00mac_start(struct ieee80211_hw *hw) 139int rt2x00mac_start(struct ieee80211_hw *hw)
140{ 140{
141 struct rt2x00_dev *rt2x00dev = hw->priv; 141 struct rt2x00_dev *rt2x00dev = hw->priv;
142 int status;
143 142
144 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags) || 143 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags))
145 test_bit(DEVICE_STARTED, &rt2x00dev->flags))
146 return 0; 144 return 0;
147 145
148 /* 146 return rt2x00lib_start(rt2x00dev);
149 * If this is the first interface which is added,
150 * we should load the firmware now.
151 */
152 if (test_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags)) {
153 status = rt2x00lib_load_firmware(rt2x00dev);
154 if (status)
155 return status;
156 }
157
158 /*
159 * Initialize the device.
160 */
161 status = rt2x00lib_initialize(rt2x00dev);
162 if (status)
163 return status;
164
165 /*
166 * Enable radio.
167 */
168 status = rt2x00lib_enable_radio(rt2x00dev);
169 if (status) {
170 rt2x00lib_uninitialize(rt2x00dev);
171 return status;
172 }
173
174 __set_bit(DEVICE_STARTED, &rt2x00dev->flags);
175
176 return 0;
177} 147}
178EXPORT_SYMBOL_GPL(rt2x00mac_start); 148EXPORT_SYMBOL_GPL(rt2x00mac_start);
179 149
@@ -184,13 +154,7 @@ void rt2x00mac_stop(struct ieee80211_hw *hw)
184 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags)) 154 if (!test_bit(DEVICE_PRESENT, &rt2x00dev->flags))
185 return; 155 return;
186 156
187 /* 157 rt2x00lib_stop(rt2x00dev);
188 * Perhaps we can add something smarter here,
189 * but for now just disabling the radio should do.
190 */
191 rt2x00lib_disable_radio(rt2x00dev);
192
193 __clear_bit(DEVICE_STARTED, &rt2x00dev->flags);
194} 158}
195EXPORT_SYMBOL_GPL(rt2x00mac_stop); 159EXPORT_SYMBOL_GPL(rt2x00mac_stop);
196 160