aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1251_event.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1251_event.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_event.c29
1 files changed, 29 insertions, 0 deletions
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;