aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas@gmail.com>2010-08-17 15:46:55 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-24 16:32:04 -0400
commit7273b9700b74e8c26b612207aea47effb0e530bf (patch)
treef1b8a54e4d4894002465d5a36fae8b97c691485e /drivers/net
parent5b44a1b5164c69cb274215fc79a9f4f5a1203c4d (diff)
wl1251: 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. Based on wl1271 patch 99d84c1de8fdf5f9b09f07fdbc628857a040bf8b by Luciano Coelho. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Acked-by: Kalle Valo <kvalo@adurom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_boot.c2
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_event.c29
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_event.h1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c8
4 files changed, 34 insertions, 6 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1251_boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c
index 65e0416be5b6..5e65f47fda8a 100644
--- a/drivers/net/wireless/wl12xx/wl1251_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1251_boot.c
@@ -302,7 +302,7 @@ int wl1251_boot_run_firmware(struct wl1251 *wl)
302 ROAMING_TRIGGER_LOW_RSSI_EVENT_ID | 302 ROAMING_TRIGGER_LOW_RSSI_EVENT_ID |
303 ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID | 303 ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID |
304 REGAINED_BSS_EVENT_ID | BT_PTA_SENSE_EVENT_ID | 304 REGAINED_BSS_EVENT_ID | BT_PTA_SENSE_EVENT_ID |
305 BT_PTA_PREDICTION_EVENT_ID; 305 BT_PTA_PREDICTION_EVENT_ID | JOIN_EVENT_COMPLETE_ID;
306 306
307 ret = wl1251_event_unmask(wl); 307 ret = wl1251_event_unmask(wl);
308 if (ret < 0) { 308 if (ret < 0) {
diff --git a/drivers/net/wireless/wl12xx/wl1251_event.c b/drivers/net/wireless/wl12xx/wl1251_event.c
index 020d764f9c13..e093a1c5a205 100644
--- a/drivers/net/wireless/wl12xx/wl1251_event.c
+++ b/drivers/net/wireless/wl12xx/wl1251_event.c
@@ -97,6 +97,35 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
97 return 0; 97 return 0;
98} 98}
99 99
100/*
101 * Poll the mailbox event field until any of the bits in the mask is set or a
102 * timeout occurs (WL1251_EVENT_TIMEOUT in msecs)
103 */
104int wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms)
105{
106 u32 events_vector, event;
107 unsigned long timeout;
108
109 timeout = jiffies + msecs_to_jiffies(timeout_ms);
110
111 do {
112 if (time_after(jiffies, timeout))
113 return -ETIMEDOUT;
114
115 msleep(1);
116
117 /* read from both event fields */
118 wl1251_mem_read(wl, wl->mbox_ptr[0], &events_vector,
119 sizeof(events_vector));
120 event = events_vector & mask;
121 wl1251_mem_read(wl, wl->mbox_ptr[1], &events_vector,
122 sizeof(events_vector));
123 event |= events_vector & mask;
124 } while (!event);
125
126 return 0;
127}
128
100int wl1251_event_unmask(struct wl1251 *wl) 129int wl1251_event_unmask(struct wl1251 *wl)
101{ 130{
102 int ret; 131 int ret;
diff --git a/drivers/net/wireless/wl12xx/wl1251_event.h b/drivers/net/wireless/wl12xx/wl1251_event.h
index f48a2b66bc5a..ec456474a842 100644
--- a/drivers/net/wireless/wl12xx/wl1251_event.h
+++ b/drivers/net/wireless/wl12xx/wl1251_event.h
@@ -117,5 +117,6 @@ struct event_mailbox {
117int wl1251_event_unmask(struct wl1251 *wl); 117int wl1251_event_unmask(struct wl1251 *wl);
118void wl1251_event_mbox_config(struct wl1251 *wl); 118void wl1251_event_mbox_config(struct wl1251 *wl);
119int wl1251_event_handle(struct wl1251 *wl, u8 mbox); 119int wl1251_event_handle(struct wl1251 *wl, u8 mbox);
120int wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms);
120 121
121#endif 122#endif
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index 51474b697c1a..c81e95b45c14 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -339,11 +339,9 @@ static int wl1251_join(struct wl1251 *wl, u8 bss_type, u8 channel,
339 if (ret < 0) 339 if (ret < 0)
340 goto out; 340 goto out;
341 341
342 /* 342 ret = wl1251_event_wait(wl, JOIN_EVENT_COMPLETE_ID, 100);
343 * FIXME: we should wait for JOIN_EVENT_COMPLETE_ID but to simplify 343 if (ret < 0)
344 * locking we just sleep instead, for now 344 wl1251_warning("join timeout");
345 */
346 msleep(10);
347 345
348out: 346out:
349 return ret; 347 return ret;