aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx
diff options
context:
space:
mode:
authorLuciano Coelho <luciano.coelho@nokia.com>2010-03-26 06:53:20 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-03-31 14:39:13 -0400
commit99d84c1de8fdf5f9b09f07fdbc628857a040bf8b (patch)
tree1ac0570e5c04f9d581ede7ee8931e8995497b0f7 /drivers/net/wireless/wl12xx
parent9560134ff929a037f0c967ae47089586f4b34390 (diff)
wl1271: wait for join command complete event
Poll for join command completion instead of waiting blindly for 10 msecs. There is a timeout of 100 msecs, if the command doesn't complete by then, we return an error code. Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com> Reviewed-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_boot.c3
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.c38
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_cmd.h1
3 files changed, 36 insertions, 6 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.c b/drivers/net/wireless/wl12xx/wl1271_boot.c
index 4195298b5abc..2c7e5612d5ba 100644
--- a/drivers/net/wireless/wl12xx/wl1271_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1271_boot.c
@@ -410,7 +410,8 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl)
410 /* unmask required mbox events */ 410 /* unmask required mbox events */
411 wl->event_mask = BSS_LOSE_EVENT_ID | 411 wl->event_mask = BSS_LOSE_EVENT_ID |
412 SCAN_COMPLETE_EVENT_ID | 412 SCAN_COMPLETE_EVENT_ID |
413 PS_REPORT_EVENT_ID; 413 PS_REPORT_EVENT_ID |
414 JOIN_EVENT_COMPLETE_ID;
414 415
415 ret = wl1271_event_unmask(wl); 416 ret = wl1271_event_unmask(wl);
416 if (ret < 0) { 417 if (ret < 0) {
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c
index efd94f2c3168..e677f979ca6b 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c
@@ -34,6 +34,7 @@
34#include "wl1271_acx.h" 34#include "wl1271_acx.h"
35#include "wl12xx_80211.h" 35#include "wl12xx_80211.h"
36#include "wl1271_cmd.h" 36#include "wl1271_cmd.h"
37#include "wl1271_event.h"
37 38
38/* 39/*
39 * send command to firmware 40 * send command to firmware
@@ -248,6 +249,35 @@ int wl1271_cmd_radio_parms(struct wl1271 *wl)
248 return ret; 249 return ret;
249} 250}
250 251
252/*
253 * Poll the mailbox event field until any of the bits in the mask is set or a
254 * timeout occurs (WL1271_EVENT_TIMEOUT in msecs)
255 */
256static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask)
257{
258 u32 events_vector, event;
259 unsigned long timeout;
260
261 timeout = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
262
263 do {
264 if (time_after(jiffies, timeout))
265 return -ETIMEDOUT;
266
267 msleep(1);
268
269 /* read from both event fields */
270 wl1271_read(wl, wl->mbox_ptr[0], &events_vector,
271 sizeof(events_vector), false);
272 event = events_vector & mask;
273 wl1271_read(wl, wl->mbox_ptr[1], &events_vector,
274 sizeof(events_vector), false);
275 event |= events_vector & mask;
276 } while (!event);
277
278 return 0;
279}
280
251int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type) 281int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type)
252{ 282{
253 static bool do_cal = true; 283 static bool do_cal = true;
@@ -318,11 +348,9 @@ int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type)
318 goto out_free; 348 goto out_free;
319 } 349 }
320 350
321 /* 351 ret = wl1271_cmd_wait_for_event(wl, JOIN_EVENT_COMPLETE_ID);
322 * ugly hack: we should wait for JOIN_EVENT_COMPLETE_ID but to 352 if (ret < 0)
323 * simplify locking we just sleep instead, for now 353 wl1271_error("cmd join event completion error");
324 */
325 msleep(10);
326 354
327out_free: 355out_free:
328 kfree(join); 356 kfree(join);
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.h b/drivers/net/wireless/wl12xx/wl1271_cmd.h
index 6324bbf36843..bdd7a3d8ece6 100644
--- a/drivers/net/wireless/wl12xx/wl1271_cmd.h
+++ b/drivers/net/wireless/wl12xx/wl1271_cmd.h
@@ -123,6 +123,7 @@ enum cmd_templ {
123/* unit ms */ 123/* unit ms */
124#define WL1271_COMMAND_TIMEOUT 2000 124#define WL1271_COMMAND_TIMEOUT 2000
125#define WL1271_CMD_TEMPL_MAX_SIZE 252 125#define WL1271_CMD_TEMPL_MAX_SIZE 252
126#define WL1271_EVENT_TIMEOUT 100
126 127
127struct wl1271_cmd_header { 128struct wl1271_cmd_header {
128 __le16 id; 129 __le16 id;