Linux 4.4.145
[linux/fpc-iii.git] / drivers / net / wireless / ath / ath9k / hif_usb.c
blobc92564b3ec85b9cd5edaf6f2703d49af88e6c272
1 /*
2 * Copyright (c) 2010-2011 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <asm/unaligned.h>
18 #include "htc.h"
20 MODULE_FIRMWARE(HTC_7010_MODULE_FW);
21 MODULE_FIRMWARE(HTC_9271_MODULE_FW);
23 static struct usb_device_id ath9k_hif_usb_ids[] = {
24 { USB_DEVICE(0x0cf3, 0x9271) }, /* Atheros */
25 { USB_DEVICE(0x0cf3, 0x1006) }, /* Atheros */
26 { USB_DEVICE(0x0846, 0x9030) }, /* Netgear N150 */
27 { USB_DEVICE(0x07D1, 0x3A10) }, /* Dlink Wireless 150 */
28 { USB_DEVICE(0x13D3, 0x3327) }, /* Azurewave */
29 { USB_DEVICE(0x13D3, 0x3328) }, /* Azurewave */
30 { USB_DEVICE(0x13D3, 0x3346) }, /* IMC Networks */
31 { USB_DEVICE(0x13D3, 0x3348) }, /* Azurewave */
32 { USB_DEVICE(0x13D3, 0x3349) }, /* Azurewave */
33 { USB_DEVICE(0x13D3, 0x3350) }, /* Azurewave */
34 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */
35 { USB_DEVICE(0x040D, 0x3801) }, /* VIA */
36 { USB_DEVICE(0x0cf3, 0xb003) }, /* Ubiquiti WifiStation Ext */
37 { USB_DEVICE(0x0cf3, 0xb002) }, /* Ubiquiti WifiStation */
38 { USB_DEVICE(0x057c, 0x8403) }, /* AVM FRITZ!WLAN 11N v2 USB */
39 { USB_DEVICE(0x0471, 0x209e) }, /* Philips (or NXP) PTA01 */
40 { USB_DEVICE(0x1eda, 0x2315) }, /* AirTies */
42 { USB_DEVICE(0x0cf3, 0x7015),
43 .driver_info = AR9287_USB }, /* Atheros */
44 { USB_DEVICE(0x1668, 0x1200),
45 .driver_info = AR9287_USB }, /* Verizon */
47 { USB_DEVICE(0x0cf3, 0x7010),
48 .driver_info = AR9280_USB }, /* Atheros */
49 { USB_DEVICE(0x0846, 0x9018),
50 .driver_info = AR9280_USB }, /* Netgear WNDA3200 */
51 { USB_DEVICE(0x083A, 0xA704),
52 .driver_info = AR9280_USB }, /* SMC Networks */
53 { USB_DEVICE(0x0411, 0x017f),
54 .driver_info = AR9280_USB }, /* Sony UWA-BR100 */
55 { USB_DEVICE(0x0411, 0x0197),
56 .driver_info = AR9280_USB }, /* Buffalo WLI-UV-AG300P */
57 { USB_DEVICE(0x04da, 0x3904),
58 .driver_info = AR9280_USB },
60 { USB_DEVICE(0x0cf3, 0x20ff),
61 .driver_info = STORAGE_DEVICE },
63 { },
66 MODULE_DEVICE_TABLE(usb, ath9k_hif_usb_ids);
68 static int __hif_usb_tx(struct hif_device_usb *hif_dev);
70 static void hif_usb_regout_cb(struct urb *urb)
72 struct cmd_buf *cmd = (struct cmd_buf *)urb->context;
74 switch (urb->status) {
75 case 0:
76 break;
77 case -ENOENT:
78 case -ECONNRESET:
79 case -ENODEV:
80 case -ESHUTDOWN:
81 goto free;
82 default:
83 break;
86 if (cmd) {
87 ath9k_htc_txcompletion_cb(cmd->hif_dev->htc_handle,
88 cmd->skb, true);
89 kfree(cmd);
92 return;
93 free:
94 kfree_skb(cmd->skb);
95 kfree(cmd);
98 static int hif_usb_send_regout(struct hif_device_usb *hif_dev,
99 struct sk_buff *skb)
101 struct urb *urb;
102 struct cmd_buf *cmd;
103 int ret = 0;
105 urb = usb_alloc_urb(0, GFP_KERNEL);
106 if (urb == NULL)
107 return -ENOMEM;
109 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
110 if (cmd == NULL) {
111 usb_free_urb(urb);
112 return -ENOMEM;
115 cmd->skb = skb;
116 cmd->hif_dev = hif_dev;
118 usb_fill_int_urb(urb, hif_dev->udev,
119 usb_sndintpipe(hif_dev->udev, USB_REG_OUT_PIPE),
120 skb->data, skb->len,
121 hif_usb_regout_cb, cmd, 1);
123 usb_anchor_urb(urb, &hif_dev->regout_submitted);
124 ret = usb_submit_urb(urb, GFP_KERNEL);
125 if (ret) {
126 usb_unanchor_urb(urb);
127 kfree(cmd);
129 usb_free_urb(urb);
131 return ret;
134 static void hif_usb_mgmt_cb(struct urb *urb)
136 struct cmd_buf *cmd = (struct cmd_buf *)urb->context;
137 struct hif_device_usb *hif_dev;
138 bool txok = true;
140 if (!cmd || !cmd->skb || !cmd->hif_dev)
141 return;
143 hif_dev = cmd->hif_dev;
145 switch (urb->status) {
146 case 0:
147 break;
148 case -ENOENT:
149 case -ECONNRESET:
150 case -ENODEV:
151 case -ESHUTDOWN:
152 txok = false;
155 * If the URBs are being flushed, no need to complete
156 * this packet.
158 spin_lock(&hif_dev->tx.tx_lock);
159 if (hif_dev->tx.flags & HIF_USB_TX_FLUSH) {
160 spin_unlock(&hif_dev->tx.tx_lock);
161 dev_kfree_skb_any(cmd->skb);
162 kfree(cmd);
163 return;
165 spin_unlock(&hif_dev->tx.tx_lock);
167 break;
168 default:
169 txok = false;
170 break;
173 skb_pull(cmd->skb, 4);
174 ath9k_htc_txcompletion_cb(cmd->hif_dev->htc_handle,
175 cmd->skb, txok);
176 kfree(cmd);
179 static int hif_usb_send_mgmt(struct hif_device_usb *hif_dev,
180 struct sk_buff *skb)
182 struct urb *urb;
183 struct cmd_buf *cmd;
184 int ret = 0;
185 __le16 *hdr;
187 urb = usb_alloc_urb(0, GFP_ATOMIC);
188 if (urb == NULL)
189 return -ENOMEM;
191 cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
192 if (cmd == NULL) {
193 usb_free_urb(urb);
194 return -ENOMEM;
197 cmd->skb = skb;
198 cmd->hif_dev = hif_dev;
200 hdr = (__le16 *) skb_push(skb, 4);
201 *hdr++ = cpu_to_le16(skb->len - 4);
202 *hdr++ = cpu_to_le16(ATH_USB_TX_STREAM_MODE_TAG);
204 usb_fill_bulk_urb(urb, hif_dev->udev,
205 usb_sndbulkpipe(hif_dev->udev, USB_WLAN_TX_PIPE),
206 skb->data, skb->len,
207 hif_usb_mgmt_cb, cmd);
209 usb_anchor_urb(urb, &hif_dev->mgmt_submitted);
210 ret = usb_submit_urb(urb, GFP_ATOMIC);
211 if (ret) {
212 usb_unanchor_urb(urb);
213 kfree(cmd);
215 usb_free_urb(urb);
217 return ret;
220 static inline void ath9k_skb_queue_purge(struct hif_device_usb *hif_dev,
221 struct sk_buff_head *list)
223 struct sk_buff *skb;
225 while ((skb = __skb_dequeue(list)) != NULL) {
226 dev_kfree_skb_any(skb);
230 static inline void ath9k_skb_queue_complete(struct hif_device_usb *hif_dev,
231 struct sk_buff_head *queue,
232 bool txok)
234 struct sk_buff *skb;
236 while ((skb = __skb_dequeue(queue)) != NULL) {
237 #ifdef CONFIG_ATH9K_HTC_DEBUGFS
238 int ln = skb->len;
239 #endif
240 ath9k_htc_txcompletion_cb(hif_dev->htc_handle,
241 skb, txok);
242 if (txok) {
243 TX_STAT_INC(skb_success);
244 TX_STAT_ADD(skb_success_bytes, ln);
246 else
247 TX_STAT_INC(skb_failed);
251 static void hif_usb_tx_cb(struct urb *urb)
253 struct tx_buf *tx_buf = (struct tx_buf *) urb->context;
254 struct hif_device_usb *hif_dev;
255 bool txok = true;
257 if (!tx_buf || !tx_buf->hif_dev)
258 return;
260 hif_dev = tx_buf->hif_dev;
262 switch (urb->status) {
263 case 0:
264 break;
265 case -ENOENT:
266 case -ECONNRESET:
267 case -ENODEV:
268 case -ESHUTDOWN:
269 txok = false;
272 * If the URBs are being flushed, no need to add this
273 * URB to the free list.
275 spin_lock(&hif_dev->tx.tx_lock);
276 if (hif_dev->tx.flags & HIF_USB_TX_FLUSH) {
277 spin_unlock(&hif_dev->tx.tx_lock);
278 ath9k_skb_queue_purge(hif_dev, &tx_buf->skb_queue);
279 return;
281 spin_unlock(&hif_dev->tx.tx_lock);
283 break;
284 default:
285 txok = false;
286 break;
289 ath9k_skb_queue_complete(hif_dev, &tx_buf->skb_queue, txok);
291 /* Re-initialize the SKB queue */
292 tx_buf->len = tx_buf->offset = 0;
293 __skb_queue_head_init(&tx_buf->skb_queue);
295 /* Add this TX buffer to the free list */
296 spin_lock(&hif_dev->tx.tx_lock);
297 list_move_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
298 hif_dev->tx.tx_buf_cnt++;
299 if (!(hif_dev->tx.flags & HIF_USB_TX_STOP))
300 __hif_usb_tx(hif_dev); /* Check for pending SKBs */
301 TX_STAT_INC(buf_completed);
302 spin_unlock(&hif_dev->tx.tx_lock);
305 /* TX lock has to be taken */
306 static int __hif_usb_tx(struct hif_device_usb *hif_dev)
308 struct tx_buf *tx_buf = NULL;
309 struct sk_buff *nskb = NULL;
310 int ret = 0, i;
311 u16 tx_skb_cnt = 0;
312 u8 *buf;
313 __le16 *hdr;
315 if (hif_dev->tx.tx_skb_cnt == 0)
316 return 0;
318 /* Check if a free TX buffer is available */
319 if (list_empty(&hif_dev->tx.tx_buf))
320 return 0;
322 tx_buf = list_first_entry(&hif_dev->tx.tx_buf, struct tx_buf, list);
323 list_move_tail(&tx_buf->list, &hif_dev->tx.tx_pending);
324 hif_dev->tx.tx_buf_cnt--;
326 tx_skb_cnt = min_t(u16, hif_dev->tx.tx_skb_cnt, MAX_TX_AGGR_NUM);
328 for (i = 0; i < tx_skb_cnt; i++) {
329 nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue);
331 /* Should never be NULL */
332 BUG_ON(!nskb);
334 hif_dev->tx.tx_skb_cnt--;
336 buf = tx_buf->buf;
337 buf += tx_buf->offset;
338 hdr = (__le16 *)buf;
339 *hdr++ = cpu_to_le16(nskb->len);
340 *hdr++ = cpu_to_le16(ATH_USB_TX_STREAM_MODE_TAG);
341 buf += 4;
342 memcpy(buf, nskb->data, nskb->len);
343 tx_buf->len = nskb->len + 4;
345 if (i < (tx_skb_cnt - 1))
346 tx_buf->offset += (((tx_buf->len - 1) / 4) + 1) * 4;
348 if (i == (tx_skb_cnt - 1))
349 tx_buf->len += tx_buf->offset;
351 __skb_queue_tail(&tx_buf->skb_queue, nskb);
352 TX_STAT_INC(skb_queued);
355 usb_fill_bulk_urb(tx_buf->urb, hif_dev->udev,
356 usb_sndbulkpipe(hif_dev->udev, USB_WLAN_TX_PIPE),
357 tx_buf->buf, tx_buf->len,
358 hif_usb_tx_cb, tx_buf);
360 ret = usb_submit_urb(tx_buf->urb, GFP_ATOMIC);
361 if (ret) {
362 tx_buf->len = tx_buf->offset = 0;
363 ath9k_skb_queue_complete(hif_dev, &tx_buf->skb_queue, false);
364 __skb_queue_head_init(&tx_buf->skb_queue);
365 list_move_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
366 hif_dev->tx.tx_buf_cnt++;
369 if (!ret)
370 TX_STAT_INC(buf_queued);
372 return ret;
375 static int hif_usb_send_tx(struct hif_device_usb *hif_dev, struct sk_buff *skb)
377 struct ath9k_htc_tx_ctl *tx_ctl;
378 unsigned long flags;
379 int ret = 0;
381 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
383 if (hif_dev->tx.flags & HIF_USB_TX_STOP) {
384 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
385 return -ENODEV;
388 /* Check if the max queue count has been reached */
389 if (hif_dev->tx.tx_skb_cnt > MAX_TX_BUF_NUM) {
390 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
391 return -ENOMEM;
394 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
396 tx_ctl = HTC_SKB_CB(skb);
398 /* Mgmt/Beacon frames don't use the TX buffer pool */
399 if ((tx_ctl->type == ATH9K_HTC_MGMT) ||
400 (tx_ctl->type == ATH9K_HTC_BEACON)) {
401 ret = hif_usb_send_mgmt(hif_dev, skb);
404 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
406 if ((tx_ctl->type == ATH9K_HTC_NORMAL) ||
407 (tx_ctl->type == ATH9K_HTC_AMPDU)) {
408 __skb_queue_tail(&hif_dev->tx.tx_skb_queue, skb);
409 hif_dev->tx.tx_skb_cnt++;
412 /* Check if AMPDUs have to be sent immediately */
413 if ((hif_dev->tx.tx_buf_cnt == MAX_TX_URB_NUM) &&
414 (hif_dev->tx.tx_skb_cnt < 2)) {
415 __hif_usb_tx(hif_dev);
418 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
420 return ret;
423 static void hif_usb_start(void *hif_handle)
425 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
426 unsigned long flags;
428 hif_dev->flags |= HIF_USB_START;
430 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
431 hif_dev->tx.flags &= ~HIF_USB_TX_STOP;
432 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
435 static void hif_usb_stop(void *hif_handle)
437 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
438 struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL;
439 unsigned long flags;
441 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
442 ath9k_skb_queue_complete(hif_dev, &hif_dev->tx.tx_skb_queue, false);
443 hif_dev->tx.tx_skb_cnt = 0;
444 hif_dev->tx.flags |= HIF_USB_TX_STOP;
445 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
447 /* The pending URBs have to be canceled. */
448 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
449 &hif_dev->tx.tx_pending, list) {
450 usb_kill_urb(tx_buf->urb);
453 usb_kill_anchored_urbs(&hif_dev->mgmt_submitted);
456 static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb)
458 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
459 int ret = 0;
461 switch (pipe_id) {
462 case USB_WLAN_TX_PIPE:
463 ret = hif_usb_send_tx(hif_dev, skb);
464 break;
465 case USB_REG_OUT_PIPE:
466 ret = hif_usb_send_regout(hif_dev, skb);
467 break;
468 default:
469 dev_err(&hif_dev->udev->dev,
470 "ath9k_htc: Invalid TX pipe: %d\n", pipe_id);
471 ret = -EINVAL;
472 break;
475 return ret;
478 static inline bool check_index(struct sk_buff *skb, u8 idx)
480 struct ath9k_htc_tx_ctl *tx_ctl;
482 tx_ctl = HTC_SKB_CB(skb);
484 if ((tx_ctl->type == ATH9K_HTC_AMPDU) &&
485 (tx_ctl->sta_idx == idx))
486 return true;
488 return false;
491 static void hif_usb_sta_drain(void *hif_handle, u8 idx)
493 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
494 struct sk_buff *skb, *tmp;
495 unsigned long flags;
497 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
499 skb_queue_walk_safe(&hif_dev->tx.tx_skb_queue, skb, tmp) {
500 if (check_index(skb, idx)) {
501 __skb_unlink(skb, &hif_dev->tx.tx_skb_queue);
502 ath9k_htc_txcompletion_cb(hif_dev->htc_handle,
503 skb, false);
504 hif_dev->tx.tx_skb_cnt--;
505 TX_STAT_INC(skb_failed);
509 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
512 static struct ath9k_htc_hif hif_usb = {
513 .transport = ATH9K_HIF_USB,
514 .name = "ath9k_hif_usb",
516 .control_ul_pipe = USB_REG_OUT_PIPE,
517 .control_dl_pipe = USB_REG_IN_PIPE,
519 .start = hif_usb_start,
520 .stop = hif_usb_stop,
521 .sta_drain = hif_usb_sta_drain,
522 .send = hif_usb_send,
525 static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
526 struct sk_buff *skb)
528 struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER];
529 int index = 0, i = 0, len = skb->len;
530 int rx_remain_len, rx_pkt_len;
531 u16 pool_index = 0;
532 u8 *ptr;
534 spin_lock(&hif_dev->rx_lock);
536 rx_remain_len = hif_dev->rx_remain_len;
537 rx_pkt_len = hif_dev->rx_transfer_len;
539 if (rx_remain_len != 0) {
540 struct sk_buff *remain_skb = hif_dev->remain_skb;
542 if (remain_skb) {
543 ptr = (u8 *) remain_skb->data;
545 index = rx_remain_len;
546 rx_remain_len -= hif_dev->rx_pad_len;
547 ptr += rx_pkt_len;
549 memcpy(ptr, skb->data, rx_remain_len);
551 rx_pkt_len += rx_remain_len;
552 hif_dev->rx_remain_len = 0;
553 skb_put(remain_skb, rx_pkt_len);
555 skb_pool[pool_index++] = remain_skb;
557 } else {
558 index = rx_remain_len;
562 spin_unlock(&hif_dev->rx_lock);
564 while (index < len) {
565 u16 pkt_len;
566 u16 pkt_tag;
567 u16 pad_len;
568 int chk_idx;
570 ptr = (u8 *) skb->data;
572 pkt_len = get_unaligned_le16(ptr + index);
573 pkt_tag = get_unaligned_le16(ptr + index + 2);
575 if (pkt_tag != ATH_USB_RX_STREAM_MODE_TAG) {
576 RX_STAT_INC(skb_dropped);
577 return;
580 pad_len = 4 - (pkt_len & 0x3);
581 if (pad_len == 4)
582 pad_len = 0;
584 chk_idx = index;
585 index = index + 4 + pkt_len + pad_len;
587 if (index > MAX_RX_BUF_SIZE) {
588 spin_lock(&hif_dev->rx_lock);
589 hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE;
590 hif_dev->rx_transfer_len =
591 MAX_RX_BUF_SIZE - chk_idx - 4;
592 hif_dev->rx_pad_len = pad_len;
594 nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
595 if (!nskb) {
596 dev_err(&hif_dev->udev->dev,
597 "ath9k_htc: RX memory allocation error\n");
598 spin_unlock(&hif_dev->rx_lock);
599 goto err;
601 skb_reserve(nskb, 32);
602 RX_STAT_INC(skb_allocated);
604 memcpy(nskb->data, &(skb->data[chk_idx+4]),
605 hif_dev->rx_transfer_len);
607 /* Record the buffer pointer */
608 hif_dev->remain_skb = nskb;
609 spin_unlock(&hif_dev->rx_lock);
610 } else {
611 nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
612 if (!nskb) {
613 dev_err(&hif_dev->udev->dev,
614 "ath9k_htc: RX memory allocation error\n");
615 goto err;
617 skb_reserve(nskb, 32);
618 RX_STAT_INC(skb_allocated);
620 memcpy(nskb->data, &(skb->data[chk_idx+4]), pkt_len);
621 skb_put(nskb, pkt_len);
622 skb_pool[pool_index++] = nskb;
626 err:
627 for (i = 0; i < pool_index; i++) {
628 RX_STAT_ADD(skb_completed_bytes, skb_pool[i]->len);
629 ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i],
630 skb_pool[i]->len, USB_WLAN_RX_PIPE);
631 RX_STAT_INC(skb_completed);
635 static void ath9k_hif_usb_rx_cb(struct urb *urb)
637 struct sk_buff *skb = (struct sk_buff *) urb->context;
638 struct hif_device_usb *hif_dev =
639 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
640 int ret;
642 if (!skb)
643 return;
645 if (!hif_dev)
646 goto free;
648 switch (urb->status) {
649 case 0:
650 break;
651 case -ENOENT:
652 case -ECONNRESET:
653 case -ENODEV:
654 case -ESHUTDOWN:
655 goto free;
656 default:
657 goto resubmit;
660 if (likely(urb->actual_length != 0)) {
661 skb_put(skb, urb->actual_length);
662 ath9k_hif_usb_rx_stream(hif_dev, skb);
665 resubmit:
666 skb_reset_tail_pointer(skb);
667 skb_trim(skb, 0);
669 usb_anchor_urb(urb, &hif_dev->rx_submitted);
670 ret = usb_submit_urb(urb, GFP_ATOMIC);
671 if (ret) {
672 usb_unanchor_urb(urb);
673 goto free;
676 return;
677 free:
678 kfree_skb(skb);
681 static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
683 struct sk_buff *skb = (struct sk_buff *) urb->context;
684 struct sk_buff *nskb;
685 struct hif_device_usb *hif_dev =
686 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
687 int ret;
689 if (!skb)
690 return;
692 if (!hif_dev)
693 goto free;
695 switch (urb->status) {
696 case 0:
697 break;
698 case -ENOENT:
699 case -ECONNRESET:
700 case -ENODEV:
701 case -ESHUTDOWN:
702 goto free;
703 default:
704 skb_reset_tail_pointer(skb);
705 skb_trim(skb, 0);
707 goto resubmit;
710 if (likely(urb->actual_length != 0)) {
711 skb_put(skb, urb->actual_length);
713 /* Process the command first */
714 ath9k_htc_rx_msg(hif_dev->htc_handle, skb,
715 skb->len, USB_REG_IN_PIPE);
718 nskb = alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_ATOMIC);
719 if (!nskb) {
720 dev_err(&hif_dev->udev->dev,
721 "ath9k_htc: REG_IN memory allocation failure\n");
722 urb->context = NULL;
723 return;
726 usb_fill_int_urb(urb, hif_dev->udev,
727 usb_rcvintpipe(hif_dev->udev,
728 USB_REG_IN_PIPE),
729 nskb->data, MAX_REG_IN_BUF_SIZE,
730 ath9k_hif_usb_reg_in_cb, nskb, 1);
733 resubmit:
734 usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
735 ret = usb_submit_urb(urb, GFP_ATOMIC);
736 if (ret) {
737 usb_unanchor_urb(urb);
738 goto free;
741 return;
742 free:
743 kfree_skb(skb);
744 urb->context = NULL;
747 static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
749 struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL;
750 unsigned long flags;
752 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
753 &hif_dev->tx.tx_buf, list) {
754 usb_kill_urb(tx_buf->urb);
755 list_del(&tx_buf->list);
756 usb_free_urb(tx_buf->urb);
757 kfree(tx_buf->buf);
758 kfree(tx_buf);
761 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
762 hif_dev->tx.flags |= HIF_USB_TX_FLUSH;
763 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
765 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
766 &hif_dev->tx.tx_pending, list) {
767 usb_kill_urb(tx_buf->urb);
768 list_del(&tx_buf->list);
769 usb_free_urb(tx_buf->urb);
770 kfree(tx_buf->buf);
771 kfree(tx_buf);
774 usb_kill_anchored_urbs(&hif_dev->mgmt_submitted);
777 static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
779 struct tx_buf *tx_buf;
780 int i;
782 INIT_LIST_HEAD(&hif_dev->tx.tx_buf);
783 INIT_LIST_HEAD(&hif_dev->tx.tx_pending);
784 spin_lock_init(&hif_dev->tx.tx_lock);
785 __skb_queue_head_init(&hif_dev->tx.tx_skb_queue);
786 init_usb_anchor(&hif_dev->mgmt_submitted);
788 for (i = 0; i < MAX_TX_URB_NUM; i++) {
789 tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL);
790 if (!tx_buf)
791 goto err;
793 tx_buf->buf = kzalloc(MAX_TX_BUF_SIZE, GFP_KERNEL);
794 if (!tx_buf->buf)
795 goto err;
797 tx_buf->urb = usb_alloc_urb(0, GFP_KERNEL);
798 if (!tx_buf->urb)
799 goto err;
801 tx_buf->hif_dev = hif_dev;
802 __skb_queue_head_init(&tx_buf->skb_queue);
804 list_add_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
807 hif_dev->tx.tx_buf_cnt = MAX_TX_URB_NUM;
809 return 0;
810 err:
811 if (tx_buf) {
812 kfree(tx_buf->buf);
813 kfree(tx_buf);
815 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
816 return -ENOMEM;
819 static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev)
821 usb_kill_anchored_urbs(&hif_dev->rx_submitted);
824 static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
826 struct urb *urb = NULL;
827 struct sk_buff *skb = NULL;
828 int i, ret;
830 init_usb_anchor(&hif_dev->rx_submitted);
831 spin_lock_init(&hif_dev->rx_lock);
833 for (i = 0; i < MAX_RX_URB_NUM; i++) {
835 /* Allocate URB */
836 urb = usb_alloc_urb(0, GFP_KERNEL);
837 if (urb == NULL) {
838 ret = -ENOMEM;
839 goto err_urb;
842 /* Allocate buffer */
843 skb = alloc_skb(MAX_RX_BUF_SIZE, GFP_KERNEL);
844 if (!skb) {
845 ret = -ENOMEM;
846 goto err_skb;
849 usb_fill_bulk_urb(urb, hif_dev->udev,
850 usb_rcvbulkpipe(hif_dev->udev,
851 USB_WLAN_RX_PIPE),
852 skb->data, MAX_RX_BUF_SIZE,
853 ath9k_hif_usb_rx_cb, skb);
855 /* Anchor URB */
856 usb_anchor_urb(urb, &hif_dev->rx_submitted);
858 /* Submit URB */
859 ret = usb_submit_urb(urb, GFP_KERNEL);
860 if (ret) {
861 usb_unanchor_urb(urb);
862 goto err_submit;
866 * Drop reference count.
867 * This ensures that the URB is freed when killing them.
869 usb_free_urb(urb);
872 return 0;
874 err_submit:
875 kfree_skb(skb);
876 err_skb:
877 usb_free_urb(urb);
878 err_urb:
879 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
880 return ret;
883 static void ath9k_hif_usb_dealloc_reg_in_urbs(struct hif_device_usb *hif_dev)
885 usb_kill_anchored_urbs(&hif_dev->reg_in_submitted);
888 static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
890 struct urb *urb = NULL;
891 struct sk_buff *skb = NULL;
892 int i, ret;
894 init_usb_anchor(&hif_dev->reg_in_submitted);
896 for (i = 0; i < MAX_REG_IN_URB_NUM; i++) {
898 /* Allocate URB */
899 urb = usb_alloc_urb(0, GFP_KERNEL);
900 if (urb == NULL) {
901 ret = -ENOMEM;
902 goto err_urb;
905 /* Allocate buffer */
906 skb = alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_KERNEL);
907 if (!skb) {
908 ret = -ENOMEM;
909 goto err_skb;
912 usb_fill_int_urb(urb, hif_dev->udev,
913 usb_rcvintpipe(hif_dev->udev,
914 USB_REG_IN_PIPE),
915 skb->data, MAX_REG_IN_BUF_SIZE,
916 ath9k_hif_usb_reg_in_cb, skb, 1);
918 /* Anchor URB */
919 usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
921 /* Submit URB */
922 ret = usb_submit_urb(urb, GFP_KERNEL);
923 if (ret) {
924 usb_unanchor_urb(urb);
925 goto err_submit;
929 * Drop reference count.
930 * This ensures that the URB is freed when killing them.
932 usb_free_urb(urb);
935 return 0;
937 err_submit:
938 kfree_skb(skb);
939 err_skb:
940 usb_free_urb(urb);
941 err_urb:
942 ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev);
943 return ret;
946 static int ath9k_hif_usb_alloc_urbs(struct hif_device_usb *hif_dev)
948 /* Register Write */
949 init_usb_anchor(&hif_dev->regout_submitted);
951 /* TX */
952 if (ath9k_hif_usb_alloc_tx_urbs(hif_dev) < 0)
953 goto err;
955 /* RX */
956 if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0)
957 goto err_rx;
959 /* Register Read */
960 if (ath9k_hif_usb_alloc_reg_in_urbs(hif_dev) < 0)
961 goto err_reg;
963 return 0;
964 err_reg:
965 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
966 err_rx:
967 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
968 err:
969 return -ENOMEM;
972 static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
974 usb_kill_anchored_urbs(&hif_dev->regout_submitted);
975 ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev);
976 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
977 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
980 static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
982 int transfer, err;
983 const void *data = hif_dev->fw_data;
984 size_t len = hif_dev->fw_size;
985 u32 addr = AR9271_FIRMWARE;
986 u8 *buf = kzalloc(4096, GFP_KERNEL);
987 u32 firm_offset;
989 if (!buf)
990 return -ENOMEM;
992 while (len) {
993 transfer = min_t(size_t, len, 4096);
994 memcpy(buf, data, transfer);
996 err = usb_control_msg(hif_dev->udev,
997 usb_sndctrlpipe(hif_dev->udev, 0),
998 FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT,
999 addr >> 8, 0, buf, transfer, HZ);
1000 if (err < 0) {
1001 kfree(buf);
1002 return err;
1005 len -= transfer;
1006 data += transfer;
1007 addr += transfer;
1009 kfree(buf);
1011 if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
1012 firm_offset = AR7010_FIRMWARE_TEXT;
1013 else
1014 firm_offset = AR9271_FIRMWARE_TEXT;
1017 * Issue FW download complete command to firmware.
1019 err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
1020 FIRMWARE_DOWNLOAD_COMP,
1021 0x40 | USB_DIR_OUT,
1022 firm_offset >> 8, 0, NULL, 0, HZ);
1023 if (err)
1024 return -EIO;
1026 dev_info(&hif_dev->udev->dev, "ath9k_htc: Transferred FW: %s, size: %ld\n",
1027 hif_dev->fw_name, (unsigned long) hif_dev->fw_size);
1029 return 0;
1032 static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev)
1034 int ret;
1036 ret = ath9k_hif_usb_download_fw(hif_dev);
1037 if (ret) {
1038 dev_err(&hif_dev->udev->dev,
1039 "ath9k_htc: Firmware - %s download failed\n",
1040 hif_dev->fw_name);
1041 return ret;
1044 /* Alloc URBs */
1045 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
1046 if (ret) {
1047 dev_err(&hif_dev->udev->dev,
1048 "ath9k_htc: Unable to allocate URBs\n");
1049 return ret;
1052 return 0;
1055 static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev)
1057 ath9k_hif_usb_dealloc_urbs(hif_dev);
1061 * If initialization fails or the FW cannot be retrieved,
1062 * detach the device.
1064 static void ath9k_hif_usb_firmware_fail(struct hif_device_usb *hif_dev)
1066 struct device *dev = &hif_dev->udev->dev;
1067 struct device *parent = dev->parent;
1069 complete_all(&hif_dev->fw_done);
1071 if (parent)
1072 device_lock(parent);
1074 device_release_driver(dev);
1076 if (parent)
1077 device_unlock(parent);
1080 static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context);
1082 /* taken from iwlwifi */
1083 static int ath9k_hif_request_firmware(struct hif_device_usb *hif_dev,
1084 bool first)
1086 char index[8], *chip;
1087 int ret;
1089 if (first) {
1090 if (htc_use_dev_fw) {
1091 hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX + 1;
1092 sprintf(index, "%s", "dev");
1093 } else {
1094 hif_dev->fw_minor_index = FIRMWARE_MINOR_IDX_MAX;
1095 sprintf(index, "%d", hif_dev->fw_minor_index);
1097 } else {
1098 hif_dev->fw_minor_index--;
1099 sprintf(index, "%d", hif_dev->fw_minor_index);
1102 /* test for FW 1.3 */
1103 if (MAJOR_VERSION_REQ == 1 && hif_dev->fw_minor_index == 3) {
1104 const char *filename;
1106 if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
1107 filename = FIRMWARE_AR7010_1_1;
1108 else
1109 filename = FIRMWARE_AR9271;
1111 /* expected fw locations:
1112 * - htc_9271.fw (stable version 1.3, depricated)
1114 snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
1115 "%s", filename);
1117 } else if (hif_dev->fw_minor_index < FIRMWARE_MINOR_IDX_MIN) {
1118 dev_err(&hif_dev->udev->dev, "no suitable firmware found!\n");
1120 return -ENOENT;
1121 } else {
1122 if (IS_AR7010_DEVICE(hif_dev->usb_device_id->driver_info))
1123 chip = "7010";
1124 else
1125 chip = "9271";
1127 /* expected fw locations:
1128 * - ath9k_htc/htc_9271-1.dev.0.fw (development version)
1129 * - ath9k_htc/htc_9271-1.4.0.fw (stable version)
1131 snprintf(hif_dev->fw_name, sizeof(hif_dev->fw_name),
1132 "%s/htc_%s-%d.%s.0.fw", HTC_FW_PATH,
1133 chip, MAJOR_VERSION_REQ, index);
1136 ret = request_firmware_nowait(THIS_MODULE, true, hif_dev->fw_name,
1137 &hif_dev->udev->dev, GFP_KERNEL,
1138 hif_dev, ath9k_hif_usb_firmware_cb);
1139 if (ret) {
1140 dev_err(&hif_dev->udev->dev,
1141 "ath9k_htc: Async request for firmware %s failed\n",
1142 hif_dev->fw_name);
1143 return ret;
1146 dev_info(&hif_dev->udev->dev, "ath9k_htc: Firmware %s requested\n",
1147 hif_dev->fw_name);
1149 return ret;
1152 static void ath9k_hif_usb_firmware_cb(const struct firmware *fw, void *context)
1154 struct hif_device_usb *hif_dev = context;
1155 int ret;
1157 if (!fw) {
1158 ret = ath9k_hif_request_firmware(hif_dev, false);
1159 if (!ret)
1160 return;
1162 dev_err(&hif_dev->udev->dev,
1163 "ath9k_htc: Failed to get firmware %s\n",
1164 hif_dev->fw_name);
1165 goto err_fw;
1168 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb,
1169 &hif_dev->udev->dev);
1170 if (hif_dev->htc_handle == NULL)
1171 goto err_dev_alloc;
1173 hif_dev->fw_data = fw->data;
1174 hif_dev->fw_size = fw->size;
1176 /* Proceed with initialization */
1178 ret = ath9k_hif_usb_dev_init(hif_dev);
1179 if (ret)
1180 goto err_dev_init;
1182 ret = ath9k_htc_hw_init(hif_dev->htc_handle,
1183 &hif_dev->interface->dev,
1184 hif_dev->usb_device_id->idProduct,
1185 hif_dev->udev->product,
1186 hif_dev->usb_device_id->driver_info);
1187 if (ret) {
1188 ret = -EINVAL;
1189 goto err_htc_hw_init;
1192 release_firmware(fw);
1193 hif_dev->flags |= HIF_USB_READY;
1194 complete_all(&hif_dev->fw_done);
1196 return;
1198 err_htc_hw_init:
1199 ath9k_hif_usb_dev_deinit(hif_dev);
1200 err_dev_init:
1201 ath9k_htc_hw_free(hif_dev->htc_handle);
1202 err_dev_alloc:
1203 release_firmware(fw);
1204 err_fw:
1205 ath9k_hif_usb_firmware_fail(hif_dev);
1209 * An exact copy of the function from zd1211rw.
1211 static int send_eject_command(struct usb_interface *interface)
1213 struct usb_device *udev = interface_to_usbdev(interface);
1214 struct usb_host_interface *iface_desc = &interface->altsetting[0];
1215 struct usb_endpoint_descriptor *endpoint;
1216 unsigned char *cmd;
1217 u8 bulk_out_ep;
1218 int r;
1220 if (iface_desc->desc.bNumEndpoints < 2)
1221 return -ENODEV;
1223 /* Find bulk out endpoint */
1224 for (r = 1; r >= 0; r--) {
1225 endpoint = &iface_desc->endpoint[r].desc;
1226 if (usb_endpoint_dir_out(endpoint) &&
1227 usb_endpoint_xfer_bulk(endpoint)) {
1228 bulk_out_ep = endpoint->bEndpointAddress;
1229 break;
1232 if (r == -1) {
1233 dev_err(&udev->dev,
1234 "ath9k_htc: Could not find bulk out endpoint\n");
1235 return -ENODEV;
1238 cmd = kzalloc(31, GFP_KERNEL);
1239 if (cmd == NULL)
1240 return -ENODEV;
1242 /* USB bulk command block */
1243 cmd[0] = 0x55; /* bulk command signature */
1244 cmd[1] = 0x53; /* bulk command signature */
1245 cmd[2] = 0x42; /* bulk command signature */
1246 cmd[3] = 0x43; /* bulk command signature */
1247 cmd[14] = 6; /* command length */
1249 cmd[15] = 0x1b; /* SCSI command: START STOP UNIT */
1250 cmd[19] = 0x2; /* eject disc */
1252 dev_info(&udev->dev, "Ejecting storage device...\n");
1253 r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, bulk_out_ep),
1254 cmd, 31, NULL, 2000);
1255 kfree(cmd);
1256 if (r)
1257 return r;
1259 /* At this point, the device disconnects and reconnects with the real
1260 * ID numbers. */
1262 usb_set_intfdata(interface, NULL);
1263 return 0;
1266 static int ath9k_hif_usb_probe(struct usb_interface *interface,
1267 const struct usb_device_id *id)
1269 struct usb_device *udev = interface_to_usbdev(interface);
1270 struct hif_device_usb *hif_dev;
1271 int ret = 0;
1273 if (id->driver_info == STORAGE_DEVICE)
1274 return send_eject_command(interface);
1276 hif_dev = kzalloc(sizeof(struct hif_device_usb), GFP_KERNEL);
1277 if (!hif_dev) {
1278 ret = -ENOMEM;
1279 goto err_alloc;
1282 usb_get_dev(udev);
1284 hif_dev->udev = udev;
1285 hif_dev->interface = interface;
1286 hif_dev->usb_device_id = id;
1287 #ifdef CONFIG_PM
1288 udev->reset_resume = 1;
1289 #endif
1290 usb_set_intfdata(interface, hif_dev);
1292 init_completion(&hif_dev->fw_done);
1294 ret = ath9k_hif_request_firmware(hif_dev, true);
1295 if (ret)
1296 goto err_fw_req;
1298 return ret;
1300 err_fw_req:
1301 usb_set_intfdata(interface, NULL);
1302 kfree(hif_dev);
1303 usb_put_dev(udev);
1304 err_alloc:
1305 return ret;
1308 static void ath9k_hif_usb_reboot(struct usb_device *udev)
1310 u32 reboot_cmd = 0xffffffff;
1311 void *buf;
1312 int ret;
1314 buf = kmemdup(&reboot_cmd, 4, GFP_KERNEL);
1315 if (!buf)
1316 return;
1318 ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE),
1319 buf, 4, NULL, HZ);
1320 if (ret)
1321 dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n");
1323 kfree(buf);
1326 static void ath9k_hif_usb_disconnect(struct usb_interface *interface)
1328 struct usb_device *udev = interface_to_usbdev(interface);
1329 struct hif_device_usb *hif_dev = usb_get_intfdata(interface);
1330 bool unplugged = (udev->state == USB_STATE_NOTATTACHED) ? true : false;
1332 if (!hif_dev)
1333 return;
1335 wait_for_completion(&hif_dev->fw_done);
1337 if (hif_dev->flags & HIF_USB_READY) {
1338 ath9k_htc_hw_deinit(hif_dev->htc_handle, unplugged);
1339 ath9k_htc_hw_free(hif_dev->htc_handle);
1340 ath9k_hif_usb_dev_deinit(hif_dev);
1343 usb_set_intfdata(interface, NULL);
1345 /* If firmware was loaded we should drop it
1346 * go back to first stage bootloader. */
1347 if (!unplugged && (hif_dev->flags & HIF_USB_READY))
1348 ath9k_hif_usb_reboot(udev);
1350 kfree(hif_dev);
1351 dev_info(&udev->dev, "ath9k_htc: USB layer deinitialized\n");
1352 usb_put_dev(udev);
1355 #ifdef CONFIG_PM
1356 static int ath9k_hif_usb_suspend(struct usb_interface *interface,
1357 pm_message_t message)
1359 struct hif_device_usb *hif_dev = usb_get_intfdata(interface);
1362 * The device has to be set to FULLSLEEP mode in case no
1363 * interface is up.
1365 if (!(hif_dev->flags & HIF_USB_START))
1366 ath9k_htc_suspend(hif_dev->htc_handle);
1368 wait_for_completion(&hif_dev->fw_done);
1370 if (hif_dev->flags & HIF_USB_READY)
1371 ath9k_hif_usb_dealloc_urbs(hif_dev);
1373 return 0;
1376 static int ath9k_hif_usb_resume(struct usb_interface *interface)
1378 struct hif_device_usb *hif_dev = usb_get_intfdata(interface);
1379 struct htc_target *htc_handle = hif_dev->htc_handle;
1380 int ret;
1381 const struct firmware *fw;
1383 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
1384 if (ret)
1385 return ret;
1387 if (hif_dev->flags & HIF_USB_READY) {
1388 /* request cached firmware during suspend/resume cycle */
1389 ret = request_firmware(&fw, hif_dev->fw_name,
1390 &hif_dev->udev->dev);
1391 if (ret)
1392 goto fail_resume;
1394 hif_dev->fw_data = fw->data;
1395 hif_dev->fw_size = fw->size;
1396 ret = ath9k_hif_usb_download_fw(hif_dev);
1397 release_firmware(fw);
1398 if (ret)
1399 goto fail_resume;
1400 } else {
1401 ath9k_hif_usb_dealloc_urbs(hif_dev);
1402 return -EIO;
1405 mdelay(100);
1407 ret = ath9k_htc_resume(htc_handle);
1409 if (ret)
1410 goto fail_resume;
1412 return 0;
1414 fail_resume:
1415 ath9k_hif_usb_dealloc_urbs(hif_dev);
1417 return ret;
1419 #endif
1421 static struct usb_driver ath9k_hif_usb_driver = {
1422 .name = KBUILD_MODNAME,
1423 .probe = ath9k_hif_usb_probe,
1424 .disconnect = ath9k_hif_usb_disconnect,
1425 #ifdef CONFIG_PM
1426 .suspend = ath9k_hif_usb_suspend,
1427 .resume = ath9k_hif_usb_resume,
1428 .reset_resume = ath9k_hif_usb_resume,
1429 #endif
1430 .id_table = ath9k_hif_usb_ids,
1431 .soft_unbind = 1,
1432 .disable_hub_initiated_lpm = 1,
1435 int ath9k_hif_usb_init(void)
1437 return usb_register(&ath9k_hif_usb_driver);
1440 void ath9k_hif_usb_exit(void)
1442 usb_deregister(&ath9k_hif_usb_driver);