2 * Copyright (c) 2010 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.
19 #define ATH9K_FW_USB_DEV(devid, fw) \
20 { USB_DEVICE(0x0cf3, devid), .driver_info = (unsigned long) fw }
22 static struct usb_device_id ath9k_hif_usb_ids[] = {
23 ATH9K_FW_USB_DEV(0x9271, "ar9271.fw"),
27 MODULE_DEVICE_TABLE(usb, ath9k_hif_usb_ids);
29 static int __hif_usb_tx(struct hif_device_usb *hif_dev);
31 static void hif_usb_regout_cb(struct urb *urb)
33 struct cmd_buf *cmd = (struct cmd_buf *)urb->context;
34 struct hif_device_usb *hif_dev = cmd->hif_dev;
40 dev_kfree_skb_any(cmd->skb);
46 switch (urb->status) {
60 ath9k_htc_txcompletion_cb(cmd->hif_dev->htc_handle,
67 static int hif_usb_send_regout(struct hif_device_usb *hif_dev,
74 urb = usb_alloc_urb(0, GFP_KERNEL);
78 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
85 cmd->hif_dev = hif_dev;
87 usb_fill_int_urb(urb, hif_dev->udev,
88 usb_sndintpipe(hif_dev->udev, USB_REG_OUT_PIPE),
90 hif_usb_regout_cb, cmd, 1);
92 ret = usb_submit_urb(urb, GFP_KERNEL);
101 static void hif_usb_tx_cb(struct urb *urb)
103 struct tx_buf *tx_buf = (struct tx_buf *) urb->context;
104 struct hif_device_usb *hif_dev = tx_buf->hif_dev;
111 switch (urb->status) {
125 spin_lock(&hif_dev->tx.tx_lock);
126 drop = !!(hif_dev->tx.flags & HIF_USB_TX_STOP);
127 flush = !!(hif_dev->tx.flags & HIF_USB_TX_FLUSH);
128 spin_unlock(&hif_dev->tx.tx_lock);
130 while ((skb = __skb_dequeue(&tx_buf->skb_queue)) != NULL) {
131 if (!drop && !flush) {
132 ath9k_htc_txcompletion_cb(hif_dev->htc_handle,
134 TX_STAT_INC(skb_completed);
136 dev_kfree_skb_any(skb);
143 tx_buf->len = tx_buf->offset = 0;
144 __skb_queue_head_init(&tx_buf->skb_queue);
146 spin_lock(&hif_dev->tx.tx_lock);
147 list_del(&tx_buf->list);
148 list_add_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
149 hif_dev->tx.tx_buf_cnt++;
151 __hif_usb_tx(hif_dev); /* Check for pending SKBs */
152 TX_STAT_INC(buf_completed);
153 spin_unlock(&hif_dev->tx.tx_lock);
157 /* TX lock has to be taken */
158 static int __hif_usb_tx(struct hif_device_usb *hif_dev)
160 struct tx_buf *tx_buf = NULL;
161 struct sk_buff *nskb = NULL;
163 u16 *hdr, tx_skb_cnt = 0;
166 if (hif_dev->tx.tx_skb_cnt == 0)
169 /* Check if a free TX buffer is available */
170 if (list_empty(&hif_dev->tx.tx_buf))
173 tx_buf = list_first_entry(&hif_dev->tx.tx_buf, struct tx_buf, list);
174 list_del(&tx_buf->list);
175 list_add_tail(&tx_buf->list, &hif_dev->tx.tx_pending);
176 hif_dev->tx.tx_buf_cnt--;
178 tx_skb_cnt = min_t(u16, hif_dev->tx.tx_skb_cnt, MAX_TX_AGGR_NUM);
180 for (i = 0; i < tx_skb_cnt; i++) {
181 nskb = __skb_dequeue(&hif_dev->tx.tx_skb_queue);
183 /* Should never be NULL */
186 hif_dev->tx.tx_skb_cnt--;
189 buf += tx_buf->offset;
192 *hdr++ = ATH_USB_TX_STREAM_MODE_TAG;
194 memcpy(buf, nskb->data, nskb->len);
195 tx_buf->len = nskb->len + 4;
197 if (i < (tx_skb_cnt - 1))
198 tx_buf->offset += (((tx_buf->len - 1) / 4) + 1) * 4;
200 if (i == (tx_skb_cnt - 1))
201 tx_buf->len += tx_buf->offset;
203 __skb_queue_tail(&tx_buf->skb_queue, nskb);
204 TX_STAT_INC(skb_queued);
207 usb_fill_bulk_urb(tx_buf->urb, hif_dev->udev,
208 usb_sndbulkpipe(hif_dev->udev, USB_WLAN_TX_PIPE),
209 tx_buf->buf, tx_buf->len,
210 hif_usb_tx_cb, tx_buf);
212 ret = usb_submit_urb(tx_buf->urb, GFP_ATOMIC);
214 tx_buf->len = tx_buf->offset = 0;
215 __skb_queue_purge(&tx_buf->skb_queue);
216 __skb_queue_head_init(&tx_buf->skb_queue);
217 list_move_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
218 hif_dev->tx.tx_buf_cnt++;
222 TX_STAT_INC(buf_queued);
227 static int hif_usb_send_tx(struct hif_device_usb *hif_dev, struct sk_buff *skb,
228 struct ath9k_htc_tx_ctl *tx_ctl)
232 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
234 if (hif_dev->tx.flags & HIF_USB_TX_STOP) {
235 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
239 /* Check if the max queue count has been reached */
240 if (hif_dev->tx.tx_skb_cnt > MAX_TX_BUF_NUM) {
241 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
245 __skb_queue_tail(&hif_dev->tx.tx_skb_queue, skb);
246 hif_dev->tx.tx_skb_cnt++;
248 /* Send normal frames immediately */
249 if (!tx_ctl || (tx_ctl && (tx_ctl->type == ATH9K_HTC_NORMAL)))
250 __hif_usb_tx(hif_dev);
252 /* Check if AMPDUs have to be sent immediately */
253 if (tx_ctl && (tx_ctl->type == ATH9K_HTC_AMPDU) &&
254 (hif_dev->tx.tx_buf_cnt == MAX_TX_URB_NUM) &&
255 (hif_dev->tx.tx_skb_cnt < 2)) {
256 __hif_usb_tx(hif_dev);
259 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
264 static void hif_usb_start(void *hif_handle, u8 pipe_id)
266 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
269 hif_dev->flags |= HIF_USB_START;
271 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
272 hif_dev->tx.flags &= ~HIF_USB_TX_STOP;
273 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
276 static void hif_usb_stop(void *hif_handle, u8 pipe_id)
278 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
281 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
282 __skb_queue_purge(&hif_dev->tx.tx_skb_queue);
283 hif_dev->tx.tx_skb_cnt = 0;
284 hif_dev->tx.flags |= HIF_USB_TX_STOP;
285 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
288 static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb,
289 struct ath9k_htc_tx_ctl *tx_ctl)
291 struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle;
295 case USB_WLAN_TX_PIPE:
296 ret = hif_usb_send_tx(hif_dev, skb, tx_ctl);
298 case USB_REG_OUT_PIPE:
299 ret = hif_usb_send_regout(hif_dev, skb);
302 dev_err(&hif_dev->udev->dev,
303 "ath9k_htc: Invalid TX pipe: %d\n", pipe_id);
311 static struct ath9k_htc_hif hif_usb = {
312 .transport = ATH9K_HIF_USB,
313 .name = "ath9k_hif_usb",
315 .control_ul_pipe = USB_REG_OUT_PIPE,
316 .control_dl_pipe = USB_REG_IN_PIPE,
318 .start = hif_usb_start,
319 .stop = hif_usb_stop,
320 .send = hif_usb_send,
323 static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
326 struct sk_buff *nskb, *skb_pool[8];
327 int index = 0, i = 0, chk_idx, len = skb->len;
328 int rx_remain_len = 0, rx_pkt_len = 0;
329 u16 pkt_len, pkt_tag, pool_index = 0;
332 rx_remain_len = hif_dev->rx_remain_len;
333 rx_pkt_len = hif_dev->rx_transfer_len;
335 if (rx_remain_len != 0) {
336 struct sk_buff *remain_skb = hif_dev->remain_skb;
339 ptr = (u8 *) remain_skb->data;
341 index = rx_remain_len;
342 rx_remain_len -= hif_dev->rx_pad_len;
345 memcpy(ptr, skb->data, rx_remain_len);
347 rx_pkt_len += rx_remain_len;
348 hif_dev->rx_remain_len = 0;
349 skb_put(remain_skb, rx_pkt_len);
351 skb_pool[pool_index++] = remain_skb;
354 index = rx_remain_len;
358 while (index < len) {
359 ptr = (u8 *) skb->data;
361 pkt_len = ptr[index] + (ptr[index+1] << 8);
362 pkt_tag = ptr[index+2] + (ptr[index+3] << 8);
364 if (pkt_tag == ATH_USB_RX_STREAM_MODE_TAG) {
367 pad_len = 4 - (pkt_len & 0x3);
372 index = index + 4 + pkt_len + pad_len;
374 if (index > MAX_RX_BUF_SIZE) {
375 hif_dev->rx_remain_len = index - MAX_RX_BUF_SIZE;
376 hif_dev->rx_transfer_len =
377 MAX_RX_BUF_SIZE - chk_idx - 4;
378 hif_dev->rx_pad_len = pad_len;
380 nskb = __dev_alloc_skb(pkt_len + 32,
383 dev_err(&hif_dev->udev->dev,
384 "ath9k_htc: RX memory allocation"
388 skb_reserve(nskb, 32);
389 RX_STAT_INC(skb_allocated);
391 memcpy(nskb->data, &(skb->data[chk_idx+4]),
392 hif_dev->rx_transfer_len);
394 /* Record the buffer pointer */
395 hif_dev->remain_skb = nskb;
397 nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
399 dev_err(&hif_dev->udev->dev,
400 "ath9k_htc: RX memory allocation"
404 skb_reserve(nskb, 32);
405 RX_STAT_INC(skb_allocated);
407 memcpy(nskb->data, &(skb->data[chk_idx+4]), pkt_len);
408 skb_put(nskb, pkt_len);
409 skb_pool[pool_index++] = nskb;
412 RX_STAT_INC(skb_dropped);
418 for (i = 0; i < pool_index; i++) {
419 ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i],
420 skb_pool[i]->len, USB_WLAN_RX_PIPE);
421 RX_STAT_INC(skb_completed);
425 static void ath9k_hif_usb_rx_cb(struct urb *urb)
427 struct sk_buff *skb = (struct sk_buff *) urb->context;
428 struct hif_device_usb *hif_dev = (struct hif_device_usb *)
429 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
438 switch (urb->status) {
450 if (likely(urb->actual_length != 0)) {
451 skb_put(skb, urb->actual_length);
452 ath9k_hif_usb_rx_stream(hif_dev, skb);
456 skb_reset_tail_pointer(skb);
459 usb_anchor_urb(urb, &hif_dev->rx_submitted);
460 ret = usb_submit_urb(urb, GFP_ATOMIC);
462 usb_unanchor_urb(urb);
468 dev_kfree_skb_any(skb);
471 static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
473 struct sk_buff *skb = (struct sk_buff *) urb->context;
474 struct sk_buff *nskb;
475 struct hif_device_usb *hif_dev = (struct hif_device_usb *)
476 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
485 switch (urb->status) {
497 if (likely(urb->actual_length != 0)) {
498 skb_put(skb, urb->actual_length);
500 nskb = __dev_alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_ATOMIC);
504 usb_fill_int_urb(urb, hif_dev->udev,
505 usb_rcvintpipe(hif_dev->udev, USB_REG_IN_PIPE),
506 nskb->data, MAX_REG_IN_BUF_SIZE,
507 ath9k_hif_usb_reg_in_cb, nskb, 1);
509 ret = usb_submit_urb(urb, GFP_ATOMIC);
511 dev_kfree_skb_any(nskb);
515 ath9k_htc_rx_msg(hif_dev->htc_handle, skb,
516 skb->len, USB_REG_IN_PIPE);
522 skb_reset_tail_pointer(skb);
525 ret = usb_submit_urb(urb, GFP_ATOMIC);
531 dev_kfree_skb_any(skb);
535 static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
538 struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL;
540 list_for_each_entry_safe(tx_buf, tx_buf_tmp, &hif_dev->tx.tx_buf, list) {
541 list_del(&tx_buf->list);
542 usb_free_urb(tx_buf->urb);
547 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
548 hif_dev->tx.flags |= HIF_USB_TX_FLUSH;
549 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
551 list_for_each_entry_safe(tx_buf, tx_buf_tmp,
552 &hif_dev->tx.tx_pending, list) {
553 usb_kill_urb(tx_buf->urb);
554 list_del(&tx_buf->list);
555 usb_free_urb(tx_buf->urb);
560 spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
561 hif_dev->tx.flags &= ~HIF_USB_TX_FLUSH;
562 spin_unlock_irqrestore(&hif_dev->tx.tx_lock, flags);
565 static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
567 struct tx_buf *tx_buf;
570 INIT_LIST_HEAD(&hif_dev->tx.tx_buf);
571 INIT_LIST_HEAD(&hif_dev->tx.tx_pending);
572 spin_lock_init(&hif_dev->tx.tx_lock);
573 __skb_queue_head_init(&hif_dev->tx.tx_skb_queue);
575 for (i = 0; i < MAX_TX_URB_NUM; i++) {
576 tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL);
580 tx_buf->buf = kzalloc(MAX_TX_BUF_SIZE, GFP_KERNEL);
584 tx_buf->urb = usb_alloc_urb(0, GFP_KERNEL);
588 tx_buf->hif_dev = hif_dev;
589 __skb_queue_head_init(&tx_buf->skb_queue);
591 list_add_tail(&tx_buf->list, &hif_dev->tx.tx_buf);
594 hif_dev->tx.tx_buf_cnt = MAX_TX_URB_NUM;
598 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
602 static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev)
604 usb_kill_anchored_urbs(&hif_dev->rx_submitted);
607 static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
609 struct urb *urb = NULL;
610 struct sk_buff *skb = NULL;
613 init_usb_anchor(&hif_dev->rx_submitted);
615 for (i = 0; i < MAX_RX_URB_NUM; i++) {
618 urb = usb_alloc_urb(0, GFP_KERNEL);
624 /* Allocate buffer */
625 skb = __dev_alloc_skb(MAX_RX_BUF_SIZE, GFP_KERNEL);
631 usb_fill_bulk_urb(urb, hif_dev->udev,
632 usb_rcvbulkpipe(hif_dev->udev,
634 skb->data, MAX_RX_BUF_SIZE,
635 ath9k_hif_usb_rx_cb, skb);
638 usb_anchor_urb(urb, &hif_dev->rx_submitted);
641 ret = usb_submit_urb(urb, GFP_KERNEL);
643 usb_unanchor_urb(urb);
651 dev_kfree_skb_any(skb);
655 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
659 static void ath9k_hif_usb_dealloc_reg_in_urb(struct hif_device_usb *hif_dev)
661 if (hif_dev->reg_in_urb) {
662 usb_kill_urb(hif_dev->reg_in_urb);
663 if (hif_dev->reg_in_urb->context)
664 dev_kfree_skb_any((void *)hif_dev->reg_in_urb->context);
665 usb_free_urb(hif_dev->reg_in_urb);
666 hif_dev->reg_in_urb = NULL;
670 static int ath9k_hif_usb_alloc_reg_in_urb(struct hif_device_usb *hif_dev)
674 hif_dev->reg_in_urb = usb_alloc_urb(0, GFP_KERNEL);
675 if (hif_dev->reg_in_urb == NULL)
678 skb = __dev_alloc_skb(MAX_REG_IN_BUF_SIZE, GFP_KERNEL);
682 usb_fill_int_urb(hif_dev->reg_in_urb, hif_dev->udev,
683 usb_rcvintpipe(hif_dev->udev, USB_REG_IN_PIPE),
684 skb->data, MAX_REG_IN_BUF_SIZE,
685 ath9k_hif_usb_reg_in_cb, skb, 1);
687 if (usb_submit_urb(hif_dev->reg_in_urb, GFP_KERNEL) != 0)
693 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
697 static int ath9k_hif_usb_alloc_urbs(struct hif_device_usb *hif_dev)
700 if (ath9k_hif_usb_alloc_tx_urbs(hif_dev) < 0)
704 if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0)
707 /* Register Read/Write */
708 if (ath9k_hif_usb_alloc_reg_in_urb(hif_dev) < 0)
716 static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
719 const void *data = hif_dev->firmware->data;
720 size_t len = hif_dev->firmware->size;
721 u32 addr = AR9271_FIRMWARE;
722 u8 *buf = kzalloc(4096, GFP_KERNEL);
728 transfer = min_t(int, len, 4096);
729 memcpy(buf, data, transfer);
731 err = usb_control_msg(hif_dev->udev,
732 usb_sndctrlpipe(hif_dev->udev, 0),
733 FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT,
734 addr >> 8, 0, buf, transfer, HZ);
747 * Issue FW download complete command to firmware.
749 err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
750 FIRMWARE_DOWNLOAD_COMP,
752 AR9271_FIRMWARE_TEXT >> 8, 0, NULL, 0, HZ);
756 dev_info(&hif_dev->udev->dev, "ath9k_htc: Transferred FW: %s, size: %ld\n",
757 "ar9271.fw", (unsigned long) hif_dev->firmware->size);
762 static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
767 /* Request firmware */
768 ret = request_firmware(&hif_dev->firmware, fw_name, &hif_dev->udev->dev);
770 dev_err(&hif_dev->udev->dev,
771 "ath9k_htc: Firmware - %s not found\n", fw_name);
775 /* Download firmware */
776 ret = ath9k_hif_usb_download_fw(hif_dev);
778 dev_err(&hif_dev->udev->dev,
779 "ath9k_htc: Firmware - %s download failed\n", fw_name);
780 goto err_fw_download;
784 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
786 dev_err(&hif_dev->udev->dev,
787 "ath9k_htc: Unable to allocate URBs\n");
796 release_firmware(hif_dev->firmware);
798 hif_dev->firmware = NULL;
802 static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
804 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
805 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
806 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
809 static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev)
811 ath9k_hif_usb_dealloc_urbs(hif_dev);
812 if (hif_dev->firmware)
813 release_firmware(hif_dev->firmware);
816 static int ath9k_hif_usb_probe(struct usb_interface *interface,
817 const struct usb_device_id *id)
819 struct usb_device *udev = interface_to_usbdev(interface);
820 struct hif_device_usb *hif_dev;
821 const char *fw_name = (const char *) id->driver_info;
824 hif_dev = kzalloc(sizeof(struct hif_device_usb), GFP_KERNEL);
831 hif_dev->udev = udev;
832 hif_dev->interface = interface;
833 hif_dev->device_id = id->idProduct;
835 udev->reset_resume = 1;
837 usb_set_intfdata(interface, hif_dev);
839 ret = ath9k_hif_usb_dev_init(hif_dev, fw_name);
842 goto err_hif_init_usb;
845 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev);
846 if (hif_dev->htc_handle == NULL) {
848 goto err_htc_hw_alloc;
851 ret = ath9k_htc_hw_init(&hif_usb, hif_dev->htc_handle, hif_dev,
852 &hif_dev->udev->dev, hif_dev->device_id,
856 goto err_htc_hw_init;
859 dev_info(&hif_dev->udev->dev, "ath9k_htc: USB layer initialized\n");
864 ath9k_htc_hw_free(hif_dev->htc_handle);
866 ath9k_hif_usb_dev_deinit(hif_dev);
868 usb_set_intfdata(interface, NULL);
875 static void ath9k_hif_usb_disconnect(struct usb_interface *interface)
877 struct usb_device *udev = interface_to_usbdev(interface);
878 struct hif_device_usb *hif_dev =
879 (struct hif_device_usb *) usb_get_intfdata(interface);
882 ath9k_htc_hw_deinit(hif_dev->htc_handle, true);
883 ath9k_htc_hw_free(hif_dev->htc_handle);
884 ath9k_hif_usb_dev_deinit(hif_dev);
885 usb_set_intfdata(interface, NULL);
888 if (hif_dev->flags & HIF_USB_START)
889 usb_reset_device(udev);
892 dev_info(&udev->dev, "ath9k_htc: USB layer deinitialized\n");
897 static int ath9k_hif_usb_suspend(struct usb_interface *interface,
898 pm_message_t message)
900 struct hif_device_usb *hif_dev =
901 (struct hif_device_usb *) usb_get_intfdata(interface);
903 ath9k_hif_usb_dealloc_urbs(hif_dev);
908 static int ath9k_hif_usb_resume(struct usb_interface *interface)
910 struct hif_device_usb *hif_dev =
911 (struct hif_device_usb *) usb_get_intfdata(interface);
914 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
918 if (hif_dev->firmware) {
919 ret = ath9k_hif_usb_download_fw(hif_dev);
923 ath9k_hif_usb_dealloc_urbs(hif_dev);
929 ret = ath9k_htc_resume(hif_dev->htc_handle);
937 ath9k_hif_usb_dealloc_urbs(hif_dev);
943 static struct usb_driver ath9k_hif_usb_driver = {
944 .name = "ath9k_hif_usb",
945 .probe = ath9k_hif_usb_probe,
946 .disconnect = ath9k_hif_usb_disconnect,
948 .suspend = ath9k_hif_usb_suspend,
949 .resume = ath9k_hif_usb_resume,
950 .reset_resume = ath9k_hif_usb_resume,
952 .id_table = ath9k_hif_usb_ids,
956 int ath9k_hif_usb_init(void)
958 return usb_register(&ath9k_hif_usb_driver);
961 void ath9k_hif_usb_exit(void)
963 usb_deregister(&ath9k_hif_usb_driver);