]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/wireless/libertas_tf/cmd.c
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[net-next-2.6.git] / drivers / net / wireless / libertas_tf / cmd.c
CommitLineData
691cdb49
LCC
1/*
2 * Copyright (C) 2008, cozybit Inc.
3 * Copyright (C) 2003-2006, Marvell International Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 */
5a0e3ad6
TH
10#include <linux/slab.h>
11
691cdb49
LCC
12#include "libertas_tf.h"
13
14static const struct channel_range channel_ranges[] = {
15 { LBTF_REGDOMAIN_US, 1, 12 },
16 { LBTF_REGDOMAIN_CA, 1, 12 },
17 { LBTF_REGDOMAIN_EU, 1, 14 },
18 { LBTF_REGDOMAIN_JP, 1, 14 },
19 { LBTF_REGDOMAIN_SP, 1, 14 },
20 { LBTF_REGDOMAIN_FR, 1, 14 },
21};
22
23static u16 lbtf_region_code_to_index[MRVDRV_MAX_REGION_CODE] =
24{
25 LBTF_REGDOMAIN_US, LBTF_REGDOMAIN_CA, LBTF_REGDOMAIN_EU,
26 LBTF_REGDOMAIN_SP, LBTF_REGDOMAIN_FR, LBTF_REGDOMAIN_JP,
27};
28
29static struct cmd_ctrl_node *lbtf_get_cmd_ctrl_node(struct lbtf_private *priv);
30
31
32/**
33 * lbtf_cmd_copyback - Simple callback that copies response back into command
34 *
35 * @priv A pointer to struct lbtf_private structure
36 * @extra A pointer to the original command structure for which
37 * 'resp' is a response
38 * @resp A pointer to the command response
39 *
40 * Returns: 0 on success, error on failure
41 */
42int lbtf_cmd_copyback(struct lbtf_private *priv, unsigned long extra,
43 struct cmd_header *resp)
44{
45 struct cmd_header *buf = (void *)extra;
46 uint16_t copy_len;
47
48 copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size));
49 memcpy(buf, resp, copy_len);
50 return 0;
51}
52EXPORT_SYMBOL_GPL(lbtf_cmd_copyback);
53
54#define CHAN_TO_IDX(chan) ((chan) - 1)
55
56static void lbtf_geo_init(struct lbtf_private *priv)
57{
58 const struct channel_range *range = channel_ranges;
59 u8 ch;
60 int i;
61
62 for (i = 0; i < ARRAY_SIZE(channel_ranges); i++)
63 if (channel_ranges[i].regdomain == priv->regioncode) {
64 range = &channel_ranges[i];
65 break;
66 }
67
68 for (ch = priv->range.start; ch < priv->range.end; ch++)
69 priv->channels[CHAN_TO_IDX(ch)].flags = 0;
70}
71
72/**
73 * lbtf_update_hw_spec: Updates the hardware details.
74 *
75 * @priv A pointer to struct lbtf_private structure
76 *
77 * Returns: 0 on success, error on failure
78 */
79int lbtf_update_hw_spec(struct lbtf_private *priv)
80{
81 struct cmd_ds_get_hw_spec cmd;
82 int ret = -1;
83 u32 i;
691cdb49
LCC
84
85 memset(&cmd, 0, sizeof(cmd));
86 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
87 memcpy(cmd.permanentaddr, priv->current_addr, ETH_ALEN);
88 ret = lbtf_cmd_with_response(priv, CMD_GET_HW_SPEC, &cmd);
89 if (ret)
90 goto out;
91
92 priv->fwcapinfo = le32_to_cpu(cmd.fwcapinfo);
93
94 /* The firmware release is in an interesting format: the patch
95 * level is in the most significant nibble ... so fix that: */
96 priv->fwrelease = le32_to_cpu(cmd.fwrelease);
97 priv->fwrelease = (priv->fwrelease << 8) |
98 (priv->fwrelease >> 24 & 0xff);
99
e174961c
JB
100 printk(KERN_INFO "libertastf: %pM, fw %u.%u.%up%u, cap 0x%08x\n",
101 cmd.permanentaddr,
691cdb49
LCC
102 priv->fwrelease >> 24 & 0xff,
103 priv->fwrelease >> 16 & 0xff,
104 priv->fwrelease >> 8 & 0xff,
105 priv->fwrelease & 0xff,
106 priv->fwcapinfo);
107
108 /* Clamp region code to 8-bit since FW spec indicates that it should
109 * only ever be 8-bit, even though the field size is 16-bit. Some
110 * firmware returns non-zero high 8 bits here.
111 */
112 priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
113
114 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
115 /* use the region code to search for the index */
116 if (priv->regioncode == lbtf_region_code_to_index[i])
117 break;
118 }
119
120 /* if it's unidentified region code, use the default (USA) */
121 if (i >= MRVDRV_MAX_REGION_CODE)
122 priv->regioncode = 0x10;
123
124 if (priv->current_addr[0] == 0xff)
125 memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN);
126
127 SET_IEEE80211_PERM_ADDR(priv->hw, priv->current_addr);
128
129 lbtf_geo_init(priv);
130out:
131 return ret;
132}
133
134/**
135 * lbtf_set_channel: Set the radio channel
136 *
137 * @priv A pointer to struct lbtf_private structure
138 * @channel The desired channel, or 0 to clear a locked channel
139 *
140 * Returns: 0 on success, error on failure
141 */
142int lbtf_set_channel(struct lbtf_private *priv, u8 channel)
143{
144 struct cmd_ds_802_11_rf_channel cmd;
145
146 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
147 cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_SET);
148 cmd.channel = cpu_to_le16(channel);
149
150 return lbtf_cmd_with_response(priv, CMD_802_11_RF_CHANNEL, &cmd);
151}
152
153int lbtf_beacon_set(struct lbtf_private *priv, struct sk_buff *beacon)
154{
155 struct cmd_ds_802_11_beacon_set cmd;
156 int size;
157
158 if (beacon->len > MRVL_MAX_BCN_SIZE)
159 return -1;
160 size = sizeof(cmd) - sizeof(cmd.beacon) + beacon->len;
161 cmd.hdr.size = cpu_to_le16(size);
162 cmd.len = cpu_to_le16(beacon->len);
163 memcpy(cmd.beacon, (u8 *) beacon->data, beacon->len);
164
165 lbtf_cmd_async(priv, CMD_802_11_BEACON_SET, &cmd.hdr, size);
166 return 0;
167}
168
169int lbtf_beacon_ctrl(struct lbtf_private *priv, bool beacon_enable,
170 int beacon_int) {
171 struct cmd_ds_802_11_beacon_control cmd;
172
173 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
174 cmd.action = cpu_to_le16(CMD_ACT_SET);
175 cmd.beacon_enable = cpu_to_le16(beacon_enable);
176 cmd.beacon_period = cpu_to_le16(beacon_int);
177
178 lbtf_cmd_async(priv, CMD_802_11_BEACON_CTRL, &cmd.hdr, sizeof(cmd));
179 return 0;
180}
181
182static void lbtf_queue_cmd(struct lbtf_private *priv,
183 struct cmd_ctrl_node *cmdnode)
184{
185 unsigned long flags;
186
187 if (!cmdnode)
188 return;
189
190 if (!cmdnode->cmdbuf->size)
191 return;
192
193 cmdnode->result = 0;
194 spin_lock_irqsave(&priv->driver_lock, flags);
195 list_add_tail(&cmdnode->list, &priv->cmdpendingq);
196 spin_unlock_irqrestore(&priv->driver_lock, flags);
197}
198
199static void lbtf_submit_command(struct lbtf_private *priv,
200 struct cmd_ctrl_node *cmdnode)
201{
202 unsigned long flags;
203 struct cmd_header *cmd;
204 uint16_t cmdsize;
205 uint16_t command;
206 int timeo = 5 * HZ;
207 int ret;
208
209 cmd = cmdnode->cmdbuf;
210
211 spin_lock_irqsave(&priv->driver_lock, flags);
212 priv->cur_cmd = cmdnode;
213 cmdsize = le16_to_cpu(cmd->size);
214 command = le16_to_cpu(cmd->command);
215 ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
216 spin_unlock_irqrestore(&priv->driver_lock, flags);
217
218 if (ret)
219 /* Let the timer kick in and retry, and potentially reset
220 the whole thing if the condition persists */
221 timeo = HZ;
222
223 /* Setup the timer after transmit command */
224 mod_timer(&priv->command_timer, jiffies + timeo);
225}
226
227/**
228 * This function inserts command node to cmdfreeq
229 * after cleans it. Requires priv->driver_lock held.
230 */
231static void __lbtf_cleanup_and_insert_cmd(struct lbtf_private *priv,
232 struct cmd_ctrl_node *cmdnode)
233{
234 if (!cmdnode)
235 return;
236
237 cmdnode->callback = NULL;
238 cmdnode->callback_arg = 0;
239
240 memset(cmdnode->cmdbuf, 0, LBS_CMD_BUFFER_SIZE);
241
242 list_add_tail(&cmdnode->list, &priv->cmdfreeq);
243}
244
245static void lbtf_cleanup_and_insert_cmd(struct lbtf_private *priv,
246 struct cmd_ctrl_node *ptempcmd)
247{
248 unsigned long flags;
249
250 spin_lock_irqsave(&priv->driver_lock, flags);
251 __lbtf_cleanup_and_insert_cmd(priv, ptempcmd);
252 spin_unlock_irqrestore(&priv->driver_lock, flags);
253}
254
255void lbtf_complete_command(struct lbtf_private *priv, struct cmd_ctrl_node *cmd,
256 int result)
257{
258 cmd->result = result;
259 cmd->cmdwaitqwoken = 1;
260 wake_up_interruptible(&cmd->cmdwait_q);
261
262 if (!cmd->callback)
263 __lbtf_cleanup_and_insert_cmd(priv, cmd);
264 priv->cur_cmd = NULL;
265}
266
267int lbtf_cmd_set_mac_multicast_addr(struct lbtf_private *priv)
268{
269 struct cmd_ds_mac_multicast_addr cmd;
270
271 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
272 cmd.action = cpu_to_le16(CMD_ACT_SET);
273
274 cmd.nr_of_adrs = cpu_to_le16((u16) priv->nr_of_multicastmacaddr);
275 memcpy(cmd.maclist, priv->multicastlist,
276 priv->nr_of_multicastmacaddr * ETH_ALEN);
277
278 lbtf_cmd_async(priv, CMD_MAC_MULTICAST_ADR, &cmd.hdr, sizeof(cmd));
279 return 0;
280}
281
282void lbtf_set_mode(struct lbtf_private *priv, enum lbtf_mode mode)
283{
284 struct cmd_ds_set_mode cmd;
285
286 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
287 cmd.mode = cpu_to_le16(mode);
288 lbtf_cmd_async(priv, CMD_802_11_SET_MODE, &cmd.hdr, sizeof(cmd));
289}
290
5f936f11 291void lbtf_set_bssid(struct lbtf_private *priv, bool activate, const u8 *bssid)
691cdb49
LCC
292{
293 struct cmd_ds_set_bssid cmd;
294
295 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
296 cmd.activate = activate ? 1 : 0;
297 if (activate)
298 memcpy(cmd.bssid, bssid, ETH_ALEN);
299
300 lbtf_cmd_async(priv, CMD_802_11_SET_BSSID, &cmd.hdr, sizeof(cmd));
301}
302
303int lbtf_set_mac_address(struct lbtf_private *priv, uint8_t *mac_addr)
304{
305 struct cmd_ds_802_11_mac_address cmd;
306
307 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
308 cmd.action = cpu_to_le16(CMD_ACT_SET);
309
310 memcpy(cmd.macadd, mac_addr, ETH_ALEN);
311
312 lbtf_cmd_async(priv, CMD_802_11_MAC_ADDRESS, &cmd.hdr, sizeof(cmd));
313 return 0;
314}
315
316int lbtf_set_radio_control(struct lbtf_private *priv)
317{
318 int ret = 0;
319 struct cmd_ds_802_11_radio_control cmd;
320
321 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
322 cmd.action = cpu_to_le16(CMD_ACT_SET);
323
324 switch (priv->preamble) {
325 case CMD_TYPE_SHORT_PREAMBLE:
326 cmd.control = cpu_to_le16(SET_SHORT_PREAMBLE);
327 break;
328
329 case CMD_TYPE_LONG_PREAMBLE:
330 cmd.control = cpu_to_le16(SET_LONG_PREAMBLE);
331 break;
332
333 case CMD_TYPE_AUTO_PREAMBLE:
334 default:
335 cmd.control = cpu_to_le16(SET_AUTO_PREAMBLE);
336 break;
337 }
338
339 if (priv->radioon)
340 cmd.control |= cpu_to_le16(TURN_ON_RF);
341 else
342 cmd.control &= cpu_to_le16(~TURN_ON_RF);
343
344 ret = lbtf_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd);
345 return ret;
346}
347
348void lbtf_set_mac_control(struct lbtf_private *priv)
349{
350 struct cmd_ds_mac_control cmd;
351 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
352 cmd.action = cpu_to_le16(priv->mac_control);
353 cmd.reserved = 0;
354
355 lbtf_cmd_async(priv, CMD_MAC_CONTROL,
356 &cmd.hdr, sizeof(cmd));
357}
358
359/**
360 * lbtf_allocate_cmd_buffer - Allocates cmd buffer, links it to free cmd queue
361 *
362 * @priv A pointer to struct lbtf_private structure
363 *
364 * Returns: 0 on success.
365 */
366int lbtf_allocate_cmd_buffer(struct lbtf_private *priv)
367{
368 u32 bufsize;
369 u32 i;
370 struct cmd_ctrl_node *cmdarray;
371
372 /* Allocate and initialize the command array */
373 bufsize = sizeof(struct cmd_ctrl_node) * LBS_NUM_CMD_BUFFERS;
374 cmdarray = kzalloc(bufsize, GFP_KERNEL);
375 if (!cmdarray)
376 return -1;
377 priv->cmd_array = cmdarray;
378
379 /* Allocate and initialize each command buffer in the command array */
380 for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
381 cmdarray[i].cmdbuf = kzalloc(LBS_CMD_BUFFER_SIZE, GFP_KERNEL);
382 if (!cmdarray[i].cmdbuf)
383 return -1;
384 }
385
386 for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
387 init_waitqueue_head(&cmdarray[i].cmdwait_q);
388 lbtf_cleanup_and_insert_cmd(priv, &cmdarray[i]);
389 }
390 return 0;
391}
392
393/**
394 * lbtf_free_cmd_buffer - Frees the cmd buffer.
395 *
396 * @priv A pointer to struct lbtf_private structure
397 *
398 * Returns: 0
399 */
400int lbtf_free_cmd_buffer(struct lbtf_private *priv)
401{
402 struct cmd_ctrl_node *cmdarray;
403 unsigned int i;
404
405 /* need to check if cmd array is allocated or not */
406 if (priv->cmd_array == NULL)
407 return 0;
408
409 cmdarray = priv->cmd_array;
410
411 /* Release shared memory buffers */
412 for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
413 kfree(cmdarray[i].cmdbuf);
414 cmdarray[i].cmdbuf = NULL;
415 }
416
417 /* Release cmd_ctrl_node */
418 kfree(priv->cmd_array);
419 priv->cmd_array = NULL;
420
421 return 0;
422}
423
424/**
425 * lbtf_get_cmd_ctrl_node - Gets free cmd node from free cmd queue.
426 *
427 * @priv A pointer to struct lbtf_private structure
428 *
429 * Returns: pointer to a struct cmd_ctrl_node or NULL if none available.
430 */
431static struct cmd_ctrl_node *lbtf_get_cmd_ctrl_node(struct lbtf_private *priv)
432{
433 struct cmd_ctrl_node *tempnode;
434 unsigned long flags;
435
436 if (!priv)
437 return NULL;
438
439 spin_lock_irqsave(&priv->driver_lock, flags);
440
441 if (!list_empty(&priv->cmdfreeq)) {
442 tempnode = list_first_entry(&priv->cmdfreeq,
443 struct cmd_ctrl_node, list);
444 list_del(&tempnode->list);
445 } else
446 tempnode = NULL;
447
448 spin_unlock_irqrestore(&priv->driver_lock, flags);
449
450 return tempnode;
451}
452
453/**
454 * lbtf_execute_next_command: execute next command in cmd pending queue.
455 *
456 * @priv A pointer to struct lbtf_private structure
457 *
458 * Returns: 0 on success.
459 */
460int lbtf_execute_next_command(struct lbtf_private *priv)
461{
462 struct cmd_ctrl_node *cmdnode = NULL;
463 struct cmd_header *cmd;
464 unsigned long flags;
465
466 /* Debug group is LBS_DEB_THREAD and not LBS_DEB_HOST, because the
467 * only caller to us is lbtf_thread() and we get even when a
468 * data packet is received */
469
470 spin_lock_irqsave(&priv->driver_lock, flags);
471
472 if (priv->cur_cmd) {
473 spin_unlock_irqrestore(&priv->driver_lock, flags);
474 return -1;
475 }
476
477 if (!list_empty(&priv->cmdpendingq)) {
478 cmdnode = list_first_entry(&priv->cmdpendingq,
479 struct cmd_ctrl_node, list);
480 }
481
482 if (cmdnode) {
483 cmd = cmdnode->cmdbuf;
484
485 list_del(&cmdnode->list);
486 spin_unlock_irqrestore(&priv->driver_lock, flags);
487 lbtf_submit_command(priv, cmdnode);
488 } else
489 spin_unlock_irqrestore(&priv->driver_lock, flags);
490 return 0;
491}
492
493static struct cmd_ctrl_node *__lbtf_cmd_async(struct lbtf_private *priv,
494 uint16_t command, struct cmd_header *in_cmd, int in_cmd_size,
495 int (*callback)(struct lbtf_private *, unsigned long,
496 struct cmd_header *),
497 unsigned long callback_arg)
498{
499 struct cmd_ctrl_node *cmdnode;
500
501 if (priv->surpriseremoved)
502 return ERR_PTR(-ENOENT);
503
504 cmdnode = lbtf_get_cmd_ctrl_node(priv);
505 if (cmdnode == NULL) {
506 /* Wake up main thread to execute next command */
507 queue_work(lbtf_wq, &priv->cmd_work);
508 return ERR_PTR(-ENOBUFS);
509 }
510
511 cmdnode->callback = callback;
512 cmdnode->callback_arg = callback_arg;
513
514 /* Copy the incoming command to the buffer */
515 memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size);
516
517 /* Set sequence number, clean result, move to buffer */
518 priv->seqnum++;
519 cmdnode->cmdbuf->command = cpu_to_le16(command);
520 cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size);
521 cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum);
522 cmdnode->cmdbuf->result = 0;
523 cmdnode->cmdwaitqwoken = 0;
524 lbtf_queue_cmd(priv, cmdnode);
525 queue_work(lbtf_wq, &priv->cmd_work);
526
527 return cmdnode;
528}
529
530void lbtf_cmd_async(struct lbtf_private *priv, uint16_t command,
531 struct cmd_header *in_cmd, int in_cmd_size)
532{
533 __lbtf_cmd_async(priv, command, in_cmd, in_cmd_size, NULL, 0);
534}
535
536int __lbtf_cmd(struct lbtf_private *priv, uint16_t command,
537 struct cmd_header *in_cmd, int in_cmd_size,
538 int (*callback)(struct lbtf_private *,
539 unsigned long, struct cmd_header *),
540 unsigned long callback_arg)
541{
542 struct cmd_ctrl_node *cmdnode;
543 unsigned long flags;
544 int ret = 0;
545
546 cmdnode = __lbtf_cmd_async(priv, command, in_cmd, in_cmd_size,
547 callback, callback_arg);
548 if (IS_ERR(cmdnode))
549 return PTR_ERR(cmdnode);
550
551 might_sleep();
552 ret = wait_event_interruptible(cmdnode->cmdwait_q,
553 cmdnode->cmdwaitqwoken);
554 if (ret) {
555 printk(KERN_DEBUG
556 "libertastf: command 0x%04x interrupted by signal",
557 command);
558 return ret;
559 }
560
561 spin_lock_irqsave(&priv->driver_lock, flags);
562 ret = cmdnode->result;
563 if (ret)
564 printk(KERN_DEBUG "libertastf: command 0x%04x failed: %d\n",
565 command, ret);
566
567 __lbtf_cleanup_and_insert_cmd(priv, cmdnode);
568 spin_unlock_irqrestore(&priv->driver_lock, flags);
569
570 return ret;
571}
572EXPORT_SYMBOL_GPL(__lbtf_cmd);
573
574/* Call holding driver_lock */
575void lbtf_cmd_response_rx(struct lbtf_private *priv)
576{
577 priv->cmd_response_rxed = 1;
578 queue_work(lbtf_wq, &priv->cmd_work);
579}
580EXPORT_SYMBOL_GPL(lbtf_cmd_response_rx);
581
582int lbtf_process_rx_command(struct lbtf_private *priv)
583{
584 uint16_t respcmd, curcmd;
585 struct cmd_header *resp;
586 int ret = 0;
587 unsigned long flags;
588 uint16_t result;
589
590 mutex_lock(&priv->lock);
591 spin_lock_irqsave(&priv->driver_lock, flags);
592
593 if (!priv->cur_cmd) {
594 ret = -1;
595 spin_unlock_irqrestore(&priv->driver_lock, flags);
596 goto done;
597 }
598
599 resp = (void *)priv->cmd_resp_buff;
600 curcmd = le16_to_cpu(priv->cur_cmd->cmdbuf->command);
601 respcmd = le16_to_cpu(resp->command);
602 result = le16_to_cpu(resp->result);
603
604 if (net_ratelimit())
605 printk(KERN_DEBUG "libertastf: cmd response 0x%04x, seq %d, size %d\n",
606 respcmd, le16_to_cpu(resp->seqnum),
607 le16_to_cpu(resp->size));
608
609 if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
610 spin_unlock_irqrestore(&priv->driver_lock, flags);
611 ret = -1;
612 goto done;
613 }
614 if (respcmd != CMD_RET(curcmd)) {
615 spin_unlock_irqrestore(&priv->driver_lock, flags);
616 ret = -1;
617 goto done;
618 }
619
620 if (resp->result == cpu_to_le16(0x0004)) {
621 /* 0x0004 means -EAGAIN. Drop the response, let it time out
622 and be resubmitted */
623 spin_unlock_irqrestore(&priv->driver_lock, flags);
624 ret = -1;
625 goto done;
626 }
627
628 /* Now we got response from FW, cancel the command timer */
629 del_timer(&priv->command_timer);
630 priv->cmd_timed_out = 0;
631 if (priv->nr_retries)
632 priv->nr_retries = 0;
633
634 /* If the command is not successful, cleanup and return failure */
635 if ((result != 0 || !(respcmd & 0x8000))) {
636 /*
637 * Handling errors here
638 */
639 switch (respcmd) {
640 case CMD_RET(CMD_GET_HW_SPEC):
641 case CMD_RET(CMD_802_11_RESET):
642 printk(KERN_DEBUG "libertastf: reset failed\n");
643 break;
644
645 }
646 lbtf_complete_command(priv, priv->cur_cmd, result);
647 spin_unlock_irqrestore(&priv->driver_lock, flags);
648
649 ret = -1;
650 goto done;
651 }
652
653 spin_unlock_irqrestore(&priv->driver_lock, flags);
654
655 if (priv->cur_cmd && priv->cur_cmd->callback) {
656 ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
657 resp);
658 }
659 spin_lock_irqsave(&priv->driver_lock, flags);
660
661 if (priv->cur_cmd) {
662 /* Clean up and Put current command back to cmdfreeq */
663 lbtf_complete_command(priv, priv->cur_cmd, result);
664 }
665 spin_unlock_irqrestore(&priv->driver_lock, flags);
666
667done:
668 mutex_unlock(&priv->lock);
669 return ret;
670}