Commit | Line | Data |
---|---|---|
9bc6772e | 1 | #include "cmd.h" |
2f01a1f5 KV |
2 | |
3 | #include <linux/module.h> | |
5a0e3ad6 | 4 | #include <linux/slab.h> |
64322e28 | 5 | #include <linux/etherdevice.h> |
2f01a1f5 | 6 | |
13674118 | 7 | #include "wl1251.h" |
9bc6772e KV |
8 | #include "reg.h" |
9 | #include "io.h" | |
10 | #include "ps.h" | |
11 | #include "acx.h" | |
ff25839b KV |
12 | |
13 | /** | |
14 | * send command to firmware | |
15 | * | |
16 | * @wl: wl struct | |
17 | * @id: command id | |
18 | * @buf: buffer containing the command, must work with dma | |
19 | * @len: length of the buffer | |
20 | */ | |
80301cdc | 21 | int wl1251_cmd_send(struct wl1251 *wl, u16 id, void *buf, size_t len) |
2f01a1f5 | 22 | { |
80301cdc | 23 | struct wl1251_cmd_header *cmd; |
2f01a1f5 | 24 | unsigned long timeout; |
2f01a1f5 KV |
25 | u32 intr; |
26 | int ret = 0; | |
27 | ||
ff25839b KV |
28 | cmd = buf; |
29 | cmd->id = id; | |
30 | cmd->status = 0; | |
31 | ||
32 | WARN_ON(len % 4 != 0); | |
2f01a1f5 | 33 | |
0764de64 | 34 | wl1251_mem_write(wl, wl->cmd_box_addr, buf, len); |
2f01a1f5 | 35 | |
80301cdc | 36 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); |
2f01a1f5 | 37 | |
80301cdc | 38 | timeout = jiffies + msecs_to_jiffies(WL1251_COMMAND_TIMEOUT); |
2f01a1f5 | 39 | |
80301cdc | 40 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); |
0e71bb08 | 41 | while (!(intr & WL1251_ACX_INTR_CMD_COMPLETE)) { |
2f01a1f5 | 42 | if (time_after(jiffies, timeout)) { |
80301cdc | 43 | wl1251_error("command complete timeout"); |
2f01a1f5 KV |
44 | ret = -ETIMEDOUT; |
45 | goto out; | |
46 | } | |
47 | ||
48 | msleep(1); | |
49 | ||
80301cdc | 50 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); |
2f01a1f5 KV |
51 | } |
52 | ||
80301cdc | 53 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_ACK, |
0e71bb08 | 54 | WL1251_ACX_INTR_CMD_COMPLETE); |
2f01a1f5 KV |
55 | |
56 | out: | |
2f01a1f5 KV |
57 | return ret; |
58 | } | |
59 | ||
ff25839b KV |
60 | /** |
61 | * send test command to firmware | |
62 | * | |
63 | * @wl: wl struct | |
6021b289 | 64 | * @buf: buffer containing the command, with all headers, must work with dma |
ff25839b KV |
65 | * @len: length of the buffer |
66 | * @answer: is answer needed | |
ff25839b | 67 | */ |
80301cdc | 68 | int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer) |
2f01a1f5 KV |
69 | { |
70 | int ret; | |
71 | ||
80301cdc | 72 | wl1251_debug(DEBUG_CMD, "cmd test"); |
2f01a1f5 | 73 | |
80301cdc | 74 | ret = wl1251_cmd_send(wl, CMD_TEST, buf, buf_len); |
ff25839b | 75 | |
2f01a1f5 | 76 | if (ret < 0) { |
80301cdc | 77 | wl1251_warning("TEST command failed"); |
6021b289 | 78 | return ret; |
2f01a1f5 KV |
79 | } |
80 | ||
81 | if (answer) { | |
80301cdc | 82 | struct wl1251_command *cmd_answer; |
6021b289 | 83 | |
2f01a1f5 KV |
84 | /* |
85 | * The test command got in, we can read the answer. | |
80301cdc | 86 | * The answer would be a wl1251_command, where the |
2f01a1f5 KV |
87 | * parameter array contains the actual answer. |
88 | */ | |
0764de64 | 89 | wl1251_mem_read(wl, wl->cmd_box_addr, buf, buf_len); |
2f01a1f5 | 90 | |
6021b289 AK |
91 | cmd_answer = buf; |
92 | ||
93 | if (cmd_answer->header.status != CMD_STATUS_SUCCESS) | |
80301cdc | 94 | wl1251_error("TEST command answer error: %d", |
6021b289 | 95 | cmd_answer->header.status); |
2f01a1f5 KV |
96 | } |
97 | ||
6021b289 | 98 | return 0; |
2f01a1f5 KV |
99 | } |
100 | ||
ff25839b KV |
101 | /** |
102 | * read acx from firmware | |
103 | * | |
104 | * @wl: wl struct | |
105 | * @id: acx id | |
106 | * @buf: buffer for the response, including all headers, must work with dma | |
25985edc | 107 | * @len: length of buf |
ff25839b | 108 | */ |
80301cdc | 109 | int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len) |
2f01a1f5 | 110 | { |
ff25839b | 111 | struct acx_header *acx = buf; |
2f01a1f5 KV |
112 | int ret; |
113 | ||
80301cdc | 114 | wl1251_debug(DEBUG_CMD, "cmd interrogate"); |
2f01a1f5 | 115 | |
ff25839b | 116 | acx->id = id; |
2f01a1f5 | 117 | |
ff25839b KV |
118 | /* payload length, does not include any headers */ |
119 | acx->len = len - sizeof(*acx); | |
120 | ||
80301cdc | 121 | ret = wl1251_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx)); |
2f01a1f5 | 122 | if (ret < 0) { |
80301cdc | 123 | wl1251_error("INTERROGATE command failed"); |
ff25839b | 124 | goto out; |
2f01a1f5 KV |
125 | } |
126 | ||
2f01a1f5 | 127 | /* the interrogate command got in, we can read the answer */ |
0764de64 | 128 | wl1251_mem_read(wl, wl->cmd_box_addr, buf, len); |
2f01a1f5 | 129 | |
ff25839b KV |
130 | acx = buf; |
131 | if (acx->cmd.status != CMD_STATUS_SUCCESS) | |
80301cdc | 132 | wl1251_error("INTERROGATE command error: %d", |
ff25839b | 133 | acx->cmd.status); |
2f01a1f5 | 134 | |
ff25839b KV |
135 | out: |
136 | return ret; | |
2f01a1f5 KV |
137 | } |
138 | ||
ff25839b KV |
139 | /** |
140 | * write acx value to firmware | |
141 | * | |
142 | * @wl: wl struct | |
143 | * @id: acx id | |
144 | * @buf: buffer containing acx, including all headers, must work with dma | |
145 | * @len: length of buf | |
146 | */ | |
80301cdc | 147 | int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len) |
2f01a1f5 | 148 | { |
ff25839b | 149 | struct acx_header *acx = buf; |
2f01a1f5 KV |
150 | int ret; |
151 | ||
80301cdc | 152 | wl1251_debug(DEBUG_CMD, "cmd configure"); |
2f01a1f5 | 153 | |
ff25839b KV |
154 | acx->id = id; |
155 | ||
156 | /* payload length, does not include any headers */ | |
157 | acx->len = len - sizeof(*acx); | |
158 | ||
80301cdc | 159 | ret = wl1251_cmd_send(wl, CMD_CONFIGURE, acx, len); |
2f01a1f5 | 160 | if (ret < 0) { |
80301cdc | 161 | wl1251_warning("CONFIGURE command NOK"); |
2f01a1f5 KV |
162 | return ret; |
163 | } | |
164 | ||
165 | return 0; | |
2f01a1f5 KV |
166 | } |
167 | ||
80301cdc | 168 | int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity, |
2f01a1f5 KV |
169 | void *bitmap, u16 bitmap_len, u8 bitmap_control) |
170 | { | |
80301cdc | 171 | struct wl1251_cmd_vbm_update *vbm; |
2f01a1f5 KV |
172 | int ret; |
173 | ||
80301cdc | 174 | wl1251_debug(DEBUG_CMD, "cmd vbm"); |
2f01a1f5 | 175 | |
ff25839b KV |
176 | vbm = kzalloc(sizeof(*vbm), GFP_KERNEL); |
177 | if (!vbm) { | |
178 | ret = -ENOMEM; | |
179 | goto out; | |
180 | } | |
181 | ||
2f01a1f5 | 182 | /* Count and period will be filled by the target */ |
ff25839b | 183 | vbm->tim.bitmap_ctrl = bitmap_control; |
2f01a1f5 | 184 | if (bitmap_len > PARTIAL_VBM_MAX) { |
80301cdc | 185 | wl1251_warning("cmd vbm len is %d B, truncating to %d", |
2f01a1f5 KV |
186 | bitmap_len, PARTIAL_VBM_MAX); |
187 | bitmap_len = PARTIAL_VBM_MAX; | |
188 | } | |
ff25839b KV |
189 | memcpy(vbm->tim.pvb_field, bitmap, bitmap_len); |
190 | vbm->tim.identity = identity; | |
191 | vbm->tim.length = bitmap_len + 3; | |
2f01a1f5 | 192 | |
ff25839b | 193 | vbm->len = cpu_to_le16(bitmap_len + 5); |
2f01a1f5 | 194 | |
80301cdc | 195 | ret = wl1251_cmd_send(wl, CMD_VBM, vbm, sizeof(*vbm)); |
2f01a1f5 | 196 | if (ret < 0) { |
80301cdc | 197 | wl1251_error("VBM command failed"); |
ff25839b | 198 | goto out; |
2f01a1f5 KV |
199 | } |
200 | ||
ff25839b KV |
201 | out: |
202 | kfree(vbm); | |
9f19fa62 | 203 | return ret; |
2f01a1f5 KV |
204 | } |
205 | ||
9281691f | 206 | int wl1251_cmd_data_path_rx(struct wl1251 *wl, u8 channel, bool enable) |
2f01a1f5 | 207 | { |
ff25839b | 208 | struct cmd_enabledisable_path *cmd; |
2f01a1f5 | 209 | int ret; |
9281691f | 210 | u16 cmd_rx; |
2f01a1f5 | 211 | |
80301cdc | 212 | wl1251_debug(DEBUG_CMD, "cmd data path"); |
2f01a1f5 | 213 | |
ff25839b KV |
214 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
215 | if (!cmd) { | |
216 | ret = -ENOMEM; | |
217 | goto out; | |
218 | } | |
219 | ||
220 | cmd->channel = channel; | |
221 | ||
9281691f | 222 | if (enable) |
2f01a1f5 | 223 | cmd_rx = CMD_ENABLE_RX; |
9281691f | 224 | else |
2f01a1f5 | 225 | cmd_rx = CMD_DISABLE_RX; |
2f01a1f5 | 226 | |
80301cdc | 227 | ret = wl1251_cmd_send(wl, cmd_rx, cmd, sizeof(*cmd)); |
2f01a1f5 | 228 | if (ret < 0) { |
80301cdc | 229 | wl1251_error("rx %s cmd for channel %d failed", |
2f01a1f5 | 230 | enable ? "start" : "stop", channel); |
ff25839b | 231 | goto out; |
2f01a1f5 KV |
232 | } |
233 | ||
80301cdc | 234 | wl1251_debug(DEBUG_BOOT, "rx %s cmd channel %d", |
2f01a1f5 KV |
235 | enable ? "start" : "stop", channel); |
236 | ||
9281691f DG |
237 | out: |
238 | kfree(cmd); | |
239 | return ret; | |
240 | } | |
241 | ||
242 | int wl1251_cmd_data_path_tx(struct wl1251 *wl, u8 channel, bool enable) | |
243 | { | |
244 | struct cmd_enabledisable_path *cmd; | |
245 | int ret; | |
246 | u16 cmd_tx; | |
247 | ||
248 | wl1251_debug(DEBUG_CMD, "cmd data path"); | |
249 | ||
250 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | |
251 | if (!cmd) | |
252 | return -ENOMEM; | |
253 | ||
254 | cmd->channel = channel; | |
255 | ||
256 | if (enable) | |
257 | cmd_tx = CMD_ENABLE_TX; | |
258 | else | |
259 | cmd_tx = CMD_DISABLE_TX; | |
260 | ||
80301cdc | 261 | ret = wl1251_cmd_send(wl, cmd_tx, cmd, sizeof(*cmd)); |
9281691f | 262 | if (ret < 0) |
80301cdc | 263 | wl1251_error("tx %s cmd for channel %d failed", |
2f01a1f5 | 264 | enable ? "start" : "stop", channel); |
9281691f DG |
265 | else |
266 | wl1251_debug(DEBUG_BOOT, "tx %s cmd channel %d", | |
267 | enable ? "start" : "stop", channel); | |
2f01a1f5 | 268 | |
ff25839b KV |
269 | kfree(cmd); |
270 | return ret; | |
2f01a1f5 KV |
271 | } |
272 | ||
c88f8754 KV |
273 | int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel, |
274 | u16 beacon_interval, u8 dtim_interval) | |
2f01a1f5 | 275 | { |
ff25839b | 276 | struct cmd_join *join; |
2f01a1f5 KV |
277 | int ret, i; |
278 | u8 *bssid; | |
279 | ||
ff25839b KV |
280 | join = kzalloc(sizeof(*join), GFP_KERNEL); |
281 | if (!join) { | |
282 | ret = -ENOMEM; | |
283 | goto out; | |
284 | } | |
285 | ||
c88f8754 | 286 | wl1251_debug(DEBUG_CMD, "cmd join%s ch %d %d/%d", |
e2fd4611 | 287 | bss_type == BSS_TYPE_IBSS ? " ibss" : "", |
c88f8754 | 288 | channel, beacon_interval, dtim_interval); |
2f01a1f5 KV |
289 | |
290 | /* Reverse order BSSID */ | |
ff25839b | 291 | bssid = (u8 *) &join->bssid_lsb; |
2f01a1f5 KV |
292 | for (i = 0; i < ETH_ALEN; i++) |
293 | bssid[i] = wl->bssid[ETH_ALEN - i - 1]; | |
294 | ||
ff25839b KV |
295 | join->rx_config_options = wl->rx_config; |
296 | join->rx_filter_options = wl->rx_filter; | |
2f01a1f5 | 297 | |
ff25839b | 298 | join->basic_rate_set = RATE_MASK_1MBPS | RATE_MASK_2MBPS | |
2f01a1f5 KV |
299 | RATE_MASK_5_5MBPS | RATE_MASK_11MBPS; |
300 | ||
ff25839b KV |
301 | join->beacon_interval = beacon_interval; |
302 | join->dtim_interval = dtim_interval; | |
303 | join->bss_type = bss_type; | |
c88f8754 | 304 | join->channel = channel; |
ff25839b | 305 | join->ctrl = JOIN_CMD_CTRL_TX_FLUSH; |
2f01a1f5 | 306 | |
80301cdc | 307 | ret = wl1251_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join)); |
2f01a1f5 | 308 | if (ret < 0) { |
80301cdc | 309 | wl1251_error("failed to initiate cmd join"); |
ff25839b | 310 | goto out; |
2f01a1f5 KV |
311 | } |
312 | ||
ff25839b KV |
313 | out: |
314 | kfree(join); | |
315 | return ret; | |
2f01a1f5 KV |
316 | } |
317 | ||
80301cdc | 318 | int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode) |
2f01a1f5 | 319 | { |
80301cdc | 320 | struct wl1251_cmd_ps_params *ps_params = NULL; |
ff25839b | 321 | int ret = 0; |
2f01a1f5 | 322 | |
80301cdc | 323 | wl1251_debug(DEBUG_CMD, "cmd set ps mode"); |
2f01a1f5 | 324 | |
ff25839b KV |
325 | ps_params = kzalloc(sizeof(*ps_params), GFP_KERNEL); |
326 | if (!ps_params) { | |
327 | ret = -ENOMEM; | |
328 | goto out; | |
329 | } | |
330 | ||
331 | ps_params->ps_mode = ps_mode; | |
332 | ps_params->send_null_data = 1; | |
333 | ps_params->retries = 5; | |
334 | ps_params->hang_over_period = 128; | |
335 | ps_params->null_data_rate = 1; /* 1 Mbps */ | |
2f01a1f5 | 336 | |
80301cdc | 337 | ret = wl1251_cmd_send(wl, CMD_SET_PS_MODE, ps_params, |
ff25839b | 338 | sizeof(*ps_params)); |
2f01a1f5 | 339 | if (ret < 0) { |
80301cdc | 340 | wl1251_error("cmd set_ps_mode failed"); |
ff25839b | 341 | goto out; |
2f01a1f5 KV |
342 | } |
343 | ||
ff25839b KV |
344 | out: |
345 | kfree(ps_params); | |
346 | return ret; | |
2f01a1f5 KV |
347 | } |
348 | ||
80301cdc | 349 | int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer, |
ff25839b | 350 | size_t len) |
2f01a1f5 | 351 | { |
ff25839b KV |
352 | struct cmd_read_write_memory *cmd; |
353 | int ret = 0; | |
2f01a1f5 | 354 | |
80301cdc | 355 | wl1251_debug(DEBUG_CMD, "cmd read memory"); |
2f01a1f5 | 356 | |
ff25839b KV |
357 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); |
358 | if (!cmd) { | |
359 | ret = -ENOMEM; | |
360 | goto out; | |
361 | } | |
362 | ||
363 | WARN_ON(len > MAX_READ_SIZE); | |
364 | len = min_t(size_t, len, MAX_READ_SIZE); | |
365 | ||
366 | cmd->addr = addr; | |
367 | cmd->size = len; | |
2f01a1f5 | 368 | |
80301cdc | 369 | ret = wl1251_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd)); |
2f01a1f5 | 370 | if (ret < 0) { |
80301cdc | 371 | wl1251_error("read memory command failed: %d", ret); |
ff25839b | 372 | goto out; |
2f01a1f5 KV |
373 | } |
374 | ||
375 | /* the read command got in, we can now read the answer */ | |
0764de64 | 376 | wl1251_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); |
2f01a1f5 | 377 | |
ff25839b | 378 | if (cmd->header.status != CMD_STATUS_SUCCESS) |
80301cdc | 379 | wl1251_error("error in read command result: %d", |
ff25839b | 380 | cmd->header.status); |
2f01a1f5 | 381 | |
ff25839b | 382 | memcpy(answer, cmd->value, len); |
2f01a1f5 | 383 | |
ff25839b KV |
384 | out: |
385 | kfree(cmd); | |
386 | return ret; | |
2f01a1f5 KV |
387 | } |
388 | ||
80301cdc | 389 | int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id, |
2f01a1f5 KV |
390 | void *buf, size_t buf_len) |
391 | { | |
80301cdc | 392 | struct wl1251_cmd_packet_template *cmd; |
ff25839b KV |
393 | size_t cmd_len; |
394 | int ret = 0; | |
2f01a1f5 | 395 | |
80301cdc | 396 | wl1251_debug(DEBUG_CMD, "cmd template %d", cmd_id); |
2f01a1f5 | 397 | |
80301cdc KV |
398 | WARN_ON(buf_len > WL1251_MAX_TEMPLATE_SIZE); |
399 | buf_len = min_t(size_t, buf_len, WL1251_MAX_TEMPLATE_SIZE); | |
ff25839b KV |
400 | cmd_len = ALIGN(sizeof(*cmd) + buf_len, 4); |
401 | ||
402 | cmd = kzalloc(cmd_len, GFP_KERNEL); | |
403 | if (!cmd) { | |
404 | ret = -ENOMEM; | |
405 | goto out; | |
406 | } | |
407 | ||
408 | cmd->size = cpu_to_le16(buf_len); | |
2f01a1f5 KV |
409 | |
410 | if (buf) | |
ff25839b | 411 | memcpy(cmd->data, buf, buf_len); |
2f01a1f5 | 412 | |
80301cdc | 413 | ret = wl1251_cmd_send(wl, cmd_id, cmd, cmd_len); |
2f01a1f5 | 414 | if (ret < 0) { |
80301cdc | 415 | wl1251_warning("cmd set_template failed: %d", ret); |
ff25839b | 416 | goto out; |
2f01a1f5 KV |
417 | } |
418 | ||
ff25839b KV |
419 | out: |
420 | kfree(cmd); | |
421 | return ret; | |
2f01a1f5 | 422 | } |
3a98c30f KV |
423 | |
424 | int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len, | |
dc52f0a8 | 425 | struct ieee80211_channel *channels[], |
3a98c30f KV |
426 | unsigned int n_channels, unsigned int n_probes) |
427 | { | |
428 | struct wl1251_cmd_scan *cmd; | |
429 | int i, ret = 0; | |
430 | ||
64322e28 DG |
431 | wl1251_debug(DEBUG_CMD, "cmd scan channels %d", n_channels); |
432 | ||
433 | WARN_ON(n_channels > SCAN_MAX_NUM_OF_CHANNELS); | |
3a98c30f KV |
434 | |
435 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | |
436 | if (!cmd) | |
437 | return -ENOMEM; | |
438 | ||
439 | cmd->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD); | |
440 | cmd->params.rx_filter_options = cpu_to_le32(CFG_RX_PRSP_EN | | |
441 | CFG_RX_MGMT_EN | | |
442 | CFG_RX_BCN_EN); | |
443 | cmd->params.scan_options = 0; | |
64322e28 DG |
444 | /* |
445 | * Use high priority scan when not associated to prevent fw issue | |
446 | * causing never-ending scans (sometimes 20+ minutes). | |
447 | * Note: This bug may be caused by the fw's DTIM handling. | |
448 | */ | |
449 | if (is_zero_ether_addr(wl->bssid)) | |
76be3434 | 450 | cmd->params.scan_options |= cpu_to_le16(WL1251_SCAN_OPT_PRIORITY_HIGH); |
3a98c30f KV |
451 | cmd->params.num_channels = n_channels; |
452 | cmd->params.num_probe_requests = n_probes; | |
453 | cmd->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */ | |
454 | cmd->params.tid_trigger = 0; | |
455 | ||
456 | for (i = 0; i < n_channels; i++) { | |
457 | cmd->channels[i].min_duration = | |
458 | cpu_to_le32(WL1251_SCAN_MIN_DURATION); | |
459 | cmd->channels[i].max_duration = | |
460 | cpu_to_le32(WL1251_SCAN_MAX_DURATION); | |
461 | memset(&cmd->channels[i].bssid_lsb, 0xff, 4); | |
462 | memset(&cmd->channels[i].bssid_msb, 0xff, 2); | |
463 | cmd->channels[i].early_termination = 0; | |
464 | cmd->channels[i].tx_power_att = 0; | |
dc52f0a8 | 465 | cmd->channels[i].channel = channels[i]->hw_value; |
3a98c30f KV |
466 | } |
467 | ||
468 | cmd->params.ssid_len = ssid_len; | |
469 | if (ssid) | |
470 | memcpy(cmd->params.ssid, ssid, ssid_len); | |
471 | ||
472 | ret = wl1251_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd)); | |
473 | if (ret < 0) { | |
474 | wl1251_error("cmd scan failed: %d", ret); | |
475 | goto out; | |
476 | } | |
477 | ||
478 | wl1251_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); | |
479 | ||
480 | if (cmd->header.status != CMD_STATUS_SUCCESS) { | |
481 | wl1251_error("cmd scan status wasn't success: %d", | |
482 | cmd->header.status); | |
483 | ret = -EIO; | |
484 | goto out; | |
485 | } | |
486 | ||
487 | out: | |
488 | kfree(cmd); | |
489 | return ret; | |
490 | } | |
491 | ||
492 | int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout) | |
493 | { | |
494 | struct wl1251_cmd_trigger_scan_to *cmd; | |
495 | int ret; | |
496 | ||
497 | wl1251_debug(DEBUG_CMD, "cmd trigger scan to"); | |
498 | ||
499 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | |
500 | if (!cmd) | |
501 | return -ENOMEM; | |
502 | ||
503 | cmd->timeout = timeout; | |
504 | ||
fe0dbcc9 | 505 | ret = wl1251_cmd_send(wl, CMD_TRIGGER_SCAN_TO, cmd, sizeof(*cmd)); |
3a98c30f KV |
506 | if (ret < 0) { |
507 | wl1251_error("cmd trigger scan to failed: %d", ret); | |
508 | goto out; | |
509 | } | |
510 | ||
511 | out: | |
512 | kfree(cmd); | |
513 | return ret; | |
514 | } |