2 * Atheros AR9170 driver
6 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
7 * Copyright 2009, Christian Lamparter <chunkeey@web.de>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; see the file COPYING. If not, see
21 * http://www.gnu.org/licenses/.
23 * This file incorporates work covered by the following copyright and
25 * Copyright (c) 2007-2008 Atheros Communications, Inc.
27 * Permission to use, copy, modify, and/or distribute this software for any
28 * purpose with or without fee is hereby granted, provided that the above
29 * copyright notice and this permission notice appear in all copies.
31 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
32 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
33 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
34 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
35 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
36 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
37 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40 #include <linux/module.h>
41 #include <linux/slab.h>
42 #include <linux/usb.h>
43 #include <linux/firmware.h>
44 #include <linux/etherdevice.h>
45 #include <linux/device.h>
46 #include <net/mac80211.h>
52 MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
53 MODULE_AUTHOR("Christian Lamparter <chunkeey@web.de>");
54 MODULE_LICENSE("GPL");
55 MODULE_DESCRIPTION("Atheros AR9170 802.11n USB wireless");
56 MODULE_FIRMWARE("ar9170.fw");
58 enum ar9170_requirements {
59 AR9170_REQ_FW1_ONLY = 1,
62 static struct usb_device_id ar9170_usb_ids[] = {
64 { USB_DEVICE(0x0cf3, 0x9170) },
66 { USB_DEVICE(0x0cf3, 0x1001) },
67 /* TP-Link TL-WN821N v2 */
68 { USB_DEVICE(0x0cf3, 0x1002) },
69 /* 3Com Dual Band 802.11n USB Adapter */
70 { USB_DEVICE(0x0cf3, 0x1010) },
71 /* H3C Dual Band 802.11n USB Adapter */
72 { USB_DEVICE(0x0cf3, 0x1011) },
74 { USB_DEVICE(0xcace, 0x0300) },
75 /* D-Link DWA 160 A1 */
76 { USB_DEVICE(0x07d1, 0x3c10) },
77 /* D-Link DWA 160 A2 */
78 { USB_DEVICE(0x07d1, 0x3a09) },
80 { USB_DEVICE(0x0846, 0x9040) },
81 /* Netgear WNDA3100 */
82 { USB_DEVICE(0x0846, 0x9010) },
83 /* Netgear WN111 v2 */
84 { USB_DEVICE(0x0846, 0x9001) },
86 { USB_DEVICE(0x0ace, 0x1221) },
87 /* Proxim ORiNOCO 802.11n USB */
88 { USB_DEVICE(0x1435, 0x0804) },
89 /* WNC Generic 11n USB Dongle */
90 { USB_DEVICE(0x1435, 0x0326) },
92 { USB_DEVICE(0x0586, 0x3417) },
94 { USB_DEVICE(0x0cde, 0x0023) },
96 { USB_DEVICE(0x0cde, 0x0026) },
97 /* Sphairon Homelink 1202 */
98 { USB_DEVICE(0x0cde, 0x0027) },
100 { USB_DEVICE(0x083a, 0xf522) },
102 { USB_DEVICE(0x2019, 0x5304) },
103 /* IO-Data WNGDNUS2 */
104 { USB_DEVICE(0x04bb, 0x093f) },
105 /* AVM FRITZ!WLAN USB Stick N */
106 { USB_DEVICE(0x057C, 0x8401) },
108 { USB_DEVICE(0x0409, 0x0249) },
109 /* AVM FRITZ!WLAN USB Stick N 2.4 */
110 { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY },
111 /* Qwest/Actiontec 802AIN Wireless N USB Network Adapter */
112 { USB_DEVICE(0x1668, 0x1200) },
117 MODULE_DEVICE_TABLE(usb, ar9170_usb_ids);
119 static void ar9170_usb_submit_urb(struct ar9170_usb *aru)
125 if (unlikely(!IS_STARTED(&aru->common)))
128 spin_lock_irqsave(&aru->tx_urb_lock, flags);
129 if (atomic_read(&aru->tx_submitted_urbs) >= AR9170_NUM_TX_URBS) {
130 spin_unlock_irqrestore(&aru->tx_urb_lock, flags);
133 atomic_inc(&aru->tx_submitted_urbs);
135 urb = usb_get_from_anchor(&aru->tx_pending);
137 atomic_dec(&aru->tx_submitted_urbs);
138 spin_unlock_irqrestore(&aru->tx_urb_lock, flags);
142 spin_unlock_irqrestore(&aru->tx_urb_lock, flags);
144 aru->tx_pending_urbs--;
145 usb_anchor_urb(urb, &aru->tx_submitted);
147 err = usb_submit_urb(urb, GFP_ATOMIC);
149 if (ar9170_nag_limiter(&aru->common))
150 dev_err(&aru->udev->dev, "submit_urb failed (%d).\n",
153 usb_unanchor_urb(urb);
154 atomic_dec(&aru->tx_submitted_urbs);
155 ar9170_tx_callback(&aru->common, urb->context);
161 static void ar9170_usb_tx_urb_complete_frame(struct urb *urb)
163 struct sk_buff *skb = urb->context;
164 struct ar9170_usb *aru = (struct ar9170_usb *)
165 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
167 if (unlikely(!aru)) {
168 dev_kfree_skb_irq(skb);
172 atomic_dec(&aru->tx_submitted_urbs);
174 ar9170_tx_callback(&aru->common, skb);
176 ar9170_usb_submit_urb(aru);
179 static void ar9170_usb_tx_urb_complete(struct urb *urb)
183 static void ar9170_usb_irq_completed(struct urb *urb)
185 struct ar9170_usb *aru = urb->context;
187 switch (urb->status) {
188 /* everything is fine */
203 ar9170_handle_command_response(&aru->common, urb->transfer_buffer,
207 usb_anchor_urb(urb, &aru->rx_submitted);
208 if (usb_submit_urb(urb, GFP_ATOMIC)) {
209 usb_unanchor_urb(urb);
216 usb_free_coherent(aru->udev, 64, urb->transfer_buffer, urb->transfer_dma);
219 static void ar9170_usb_rx_completed(struct urb *urb)
221 struct sk_buff *skb = urb->context;
222 struct ar9170_usb *aru = (struct ar9170_usb *)
223 usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
229 switch (urb->status) {
230 /* everything is fine */
245 skb_put(skb, urb->actual_length);
246 ar9170_rx(&aru->common, skb);
249 skb_reset_tail_pointer(skb);
252 usb_anchor_urb(urb, &aru->rx_submitted);
253 err = usb_submit_urb(urb, GFP_ATOMIC);
255 usb_unanchor_urb(urb);
262 dev_kfree_skb_irq(skb);
265 static int ar9170_usb_prep_rx_urb(struct ar9170_usb *aru,
266 struct urb *urb, gfp_t gfp)
270 skb = __dev_alloc_skb(AR9170_MAX_RX_BUFFER_SIZE + 32, gfp);
274 /* reserve some space for mac80211's radiotap */
275 skb_reserve(skb, 32);
277 usb_fill_bulk_urb(urb, aru->udev,
278 usb_rcvbulkpipe(aru->udev, AR9170_EP_RX),
279 skb->data, min(skb_tailroom(skb),
280 AR9170_MAX_RX_BUFFER_SIZE),
281 ar9170_usb_rx_completed, skb);
286 static int ar9170_usb_alloc_rx_irq_urb(struct ar9170_usb *aru)
288 struct urb *urb = NULL;
292 /* initialize interrupt endpoint */
293 urb = usb_alloc_urb(0, GFP_KERNEL);
297 ibuf = usb_alloc_coherent(aru->udev, 64, GFP_KERNEL, &urb->transfer_dma);
301 usb_fill_int_urb(urb, aru->udev,
302 usb_rcvintpipe(aru->udev, AR9170_EP_IRQ), ibuf,
303 64, ar9170_usb_irq_completed, aru, 1);
304 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
306 usb_anchor_urb(urb, &aru->rx_submitted);
307 err = usb_submit_urb(urb, GFP_KERNEL);
309 usb_unanchor_urb(urb);
310 usb_free_coherent(aru->udev, 64, urb->transfer_buffer,
319 static int ar9170_usb_alloc_rx_bulk_urbs(struct ar9170_usb *aru)
325 for (i = 0; i < AR9170_NUM_RX_URBS; i++) {
327 urb = usb_alloc_urb(0, GFP_KERNEL);
331 err = ar9170_usb_prep_rx_urb(aru, urb, GFP_KERNEL);
337 usb_anchor_urb(urb, &aru->rx_submitted);
338 err = usb_submit_urb(urb, GFP_KERNEL);
340 usb_unanchor_urb(urb);
341 dev_kfree_skb_any((void *) urb->transfer_buffer);
348 /* the device now waiting for a firmware. */
349 aru->common.state = AR9170_IDLE;
354 usb_kill_anchored_urbs(&aru->rx_submitted);
358 static int ar9170_usb_flush(struct ar9170 *ar)
360 struct ar9170_usb *aru = (void *) ar;
365 aru->common.state = AR9170_IDLE;
367 usb_wait_anchor_empty_timeout(&aru->tx_pending,
368 msecs_to_jiffies(800));
369 while ((urb = usb_get_from_anchor(&aru->tx_pending))) {
370 ar9170_tx_callback(&aru->common, (void *) urb->context);
374 /* lets wait a while until the tx - queues are dried out */
375 ret = usb_wait_anchor_empty_timeout(&aru->tx_submitted,
376 msecs_to_jiffies(100));
380 usb_kill_anchored_urbs(&aru->tx_submitted);
382 if (IS_ACCEPTING_CMD(ar))
383 aru->common.state = AR9170_STARTED;
388 static void ar9170_usb_cancel_urbs(struct ar9170_usb *aru)
392 aru->common.state = AR9170_UNKNOWN_STATE;
394 err = ar9170_usb_flush(&aru->common);
396 dev_err(&aru->udev->dev, "stuck tx urbs!\n");
398 usb_poison_anchored_urbs(&aru->tx_submitted);
399 usb_poison_anchored_urbs(&aru->rx_submitted);
402 static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd,
403 unsigned int plen, void *payload,
404 unsigned int outlen, void *out)
406 struct ar9170_usb *aru = (void *) ar;
407 struct urb *urb = NULL;
411 if (unlikely(!IS_ACCEPTING_CMD(ar)))
414 if (WARN_ON(plen > AR9170_MAX_CMD_LEN - 4))
417 urb = usb_alloc_urb(0, GFP_ATOMIC);
421 ar->cmdbuf[0] = cpu_to_le32(plen);
422 ar->cmdbuf[0] |= cpu_to_le32(cmd << 8);
423 /* writing multiple regs fills this buffer already */
424 if (plen && payload != (u8 *)(&ar->cmdbuf[1]))
425 memcpy(&ar->cmdbuf[1], payload, plen);
427 spin_lock_irqsave(&aru->common.cmdlock, flags);
428 aru->readbuf = (u8 *)out;
429 aru->readlen = outlen;
430 spin_unlock_irqrestore(&aru->common.cmdlock, flags);
432 usb_fill_int_urb(urb, aru->udev,
433 usb_sndintpipe(aru->udev, AR9170_EP_CMD),
434 aru->common.cmdbuf, plen + 4,
435 ar9170_usb_tx_urb_complete, NULL, 1);
437 usb_anchor_urb(urb, &aru->tx_submitted);
438 err = usb_submit_urb(urb, GFP_ATOMIC);
440 usb_unanchor_urb(urb);
446 err = wait_for_completion_timeout(&aru->cmd_wait, HZ);
452 if (aru->readlen != outlen) {
460 /* Maybe the device was removed in the second we were waiting? */
461 if (IS_STARTED(ar)) {
462 dev_err(&aru->udev->dev, "no command feedback "
463 "received (%d).\n", err);
465 /* provide some maybe useful debug information */
466 print_hex_dump_bytes("ar9170 cmd: ", DUMP_PREFIX_NONE,
467 aru->common.cmdbuf, plen + 4);
471 /* invalidate to avoid completing the next prematurely */
472 spin_lock_irqsave(&aru->common.cmdlock, flags);
475 spin_unlock_irqrestore(&aru->common.cmdlock, flags);
482 static int ar9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb)
484 struct ar9170_usb *aru = (struct ar9170_usb *) ar;
487 if (unlikely(!IS_STARTED(ar))) {
488 /* Seriously, what were you drink... err... thinking!? */
492 urb = usb_alloc_urb(0, GFP_ATOMIC);
496 usb_fill_bulk_urb(urb, aru->udev,
497 usb_sndbulkpipe(aru->udev, AR9170_EP_TX),
499 ar9170_usb_tx_urb_complete_frame, skb);
500 urb->transfer_flags |= URB_ZERO_PACKET;
502 usb_anchor_urb(urb, &aru->tx_pending);
503 aru->tx_pending_urbs++;
507 ar9170_usb_submit_urb(aru);
511 static void ar9170_usb_callback_cmd(struct ar9170 *ar, u32 len , void *buffer)
513 struct ar9170_usb *aru = (void *) ar;
517 if (unlikely(!buffer))
520 in = le32_to_cpup((__le32 *)buffer);
521 out = le32_to_cpu(ar->cmdbuf[0]);
523 /* mask off length byte */
526 if (aru->readlen >= 0) {
527 /* add expected length */
530 /* add obtained length */
535 * Some commands (e.g: AR9170_CMD_FREQUENCY) have a variable response
536 * length and we cannot predict the correct length in advance.
537 * So we only check if we provided enough space for the data.
539 if (unlikely(out < in)) {
540 dev_warn(&aru->udev->dev, "received invalid command response "
541 "got %d bytes, instead of %d bytes "
542 "and the resp length is %d bytes\n",
544 print_hex_dump_bytes("ar9170 invalid resp: ",
545 DUMP_PREFIX_OFFSET, buffer, len);
547 * Do not complete, then the command times out,
548 * and we get a stack trace from there.
553 spin_lock_irqsave(&aru->common.cmdlock, flags);
554 if (aru->readbuf && len > 0) {
555 memcpy(aru->readbuf, buffer + 4, len - 4);
558 complete(&aru->cmd_wait);
559 spin_unlock_irqrestore(&aru->common.cmdlock, flags);
562 static int ar9170_usb_upload(struct ar9170_usb *aru, const void *data,
563 size_t len, u32 addr, bool complete)
566 u8 *buf = kmalloc(4096, GFP_KERNEL);
572 transfer = min_t(int, len, 4096);
573 memcpy(buf, data, transfer);
575 err = usb_control_msg(aru->udev, usb_sndctrlpipe(aru->udev, 0),
576 0x30 /* FW DL */, 0x40 | USB_DIR_OUT,
577 addr >> 8, 0, buf, transfer, 1000);
591 err = usb_control_msg(aru->udev, usb_sndctrlpipe(aru->udev, 0),
592 0x31 /* FW DL COMPLETE */,
593 0x40 | USB_DIR_OUT, 0, 0, NULL, 0, 5000);
599 static int ar9170_usb_reset(struct ar9170_usb *aru)
601 int ret, lock = (aru->intf->condition != USB_INTERFACE_BINDING);
604 ret = usb_lock_device_for_reset(aru->udev, aru->intf);
606 dev_err(&aru->udev->dev, "unable to lock device "
607 "for reset (%d).\n", ret);
612 ret = usb_reset_device(aru->udev);
614 usb_unlock_device(aru->udev);
616 /* let it rest - for a second - */
622 static int ar9170_usb_upload_firmware(struct ar9170_usb *aru)
626 if (!aru->init_values)
627 goto upload_fw_start;
629 /* First, upload initial values to device RAM */
630 err = ar9170_usb_upload(aru, aru->init_values->data,
631 aru->init_values->size, 0x102800, false);
633 dev_err(&aru->udev->dev, "firmware part 1 "
634 "upload failed (%d).\n", err);
640 /* Then, upload the firmware itself and start it */
641 return ar9170_usb_upload(aru, aru->firmware->data, aru->firmware->size,
645 static int ar9170_usb_init_transport(struct ar9170_usb *aru)
647 struct ar9170 *ar = (void *) &aru->common;
650 ar9170_regwrite_begin(ar);
652 /* Set USB Rx stream mode MAX packet number to 2 */
653 ar9170_regwrite(AR9170_USB_REG_MAX_AGG_UPLOAD, 0x4);
655 /* Set USB Rx stream mode timeout to 10us */
656 ar9170_regwrite(AR9170_USB_REG_UPLOAD_TIME_CTL, 0x80);
658 ar9170_regwrite_finish();
660 err = ar9170_regwrite_result();
662 dev_err(&aru->udev->dev, "USB setup failed (%d).\n", err);
667 static void ar9170_usb_stop(struct ar9170 *ar)
669 struct ar9170_usb *aru = (void *) ar;
672 if (IS_ACCEPTING_CMD(ar))
673 aru->common.state = AR9170_STOPPED;
675 ret = ar9170_usb_flush(ar);
677 dev_err(&aru->udev->dev, "kill pending tx urbs.\n");
679 usb_poison_anchored_urbs(&aru->tx_submitted);
683 * So far we freed all tx urbs, but we won't dare to touch any rx urbs.
684 * Else we would end up with a unresponsive device...
688 static int ar9170_usb_open(struct ar9170 *ar)
690 struct ar9170_usb *aru = (void *) ar;
693 usb_unpoison_anchored_urbs(&aru->tx_submitted);
694 err = ar9170_usb_init_transport(aru);
696 usb_poison_anchored_urbs(&aru->tx_submitted);
700 aru->common.state = AR9170_IDLE;
704 static int ar9170_usb_init_device(struct ar9170_usb *aru)
708 err = ar9170_usb_alloc_rx_irq_urb(aru);
712 err = ar9170_usb_alloc_rx_bulk_urbs(aru);
716 err = ar9170_usb_upload_firmware(aru);
718 err = ar9170_echo_test(&aru->common, 0x60d43110);
720 /* force user invention, by disabling the device */
721 err = usb_driver_set_configuration(aru->udev, -1);
722 dev_err(&aru->udev->dev, "device is in a bad state. "
723 "please reconnect it!\n");
731 ar9170_usb_cancel_urbs(aru);
737 static void ar9170_usb_firmware_failed(struct ar9170_usb *aru)
739 struct device *parent = aru->udev->dev.parent;
740 struct usb_device *udev;
743 * Store a copy of the usb_device pointer locally.
744 * This is because device_release_driver initiates
745 * ar9170_usb_disconnect, which in turn frees our
746 * driver context (aru).
750 complete(&aru->firmware_loading_complete);
752 /* unbind anything failed */
756 device_release_driver(&udev->dev);
758 device_unlock(parent);
763 static void ar9170_usb_firmware_finish(const struct firmware *fw, void *context)
765 struct ar9170_usb *aru = context;
771 dev_err(&aru->udev->dev, "firmware file not found.\n");
775 err = ar9170_usb_init_device(aru);
779 err = ar9170_usb_open(&aru->common);
783 err = ar9170_register(&aru->common, &aru->udev->dev);
785 ar9170_usb_stop(&aru->common);
789 complete(&aru->firmware_loading_complete);
790 usb_put_dev(aru->udev);
794 ar9170_usb_cancel_urbs(aru);
797 ar9170_usb_firmware_failed(aru);
800 static void ar9170_usb_firmware_inits(const struct firmware *fw,
803 struct ar9170_usb *aru = context;
807 dev_err(&aru->udev->dev, "file with init values not found.\n");
808 ar9170_usb_firmware_failed(aru);
812 aru->init_values = fw;
814 /* ok so we have the init values -- get code for two-stage */
816 err = request_firmware_nowait(THIS_MODULE, 1, "ar9170-2.fw",
817 &aru->udev->dev, GFP_KERNEL, aru,
818 ar9170_usb_firmware_finish);
820 ar9170_usb_firmware_failed(aru);
823 static void ar9170_usb_firmware_step2(const struct firmware *fw, void *context)
825 struct ar9170_usb *aru = context;
829 ar9170_usb_firmware_finish(fw, context);
833 if (aru->req_one_stage_fw) {
834 dev_err(&aru->udev->dev, "ar9170.fw firmware file "
835 "not found and is required for this device\n");
836 ar9170_usb_firmware_failed(aru);
840 dev_err(&aru->udev->dev, "ar9170.fw firmware file "
841 "not found, trying old firmware...\n");
843 err = request_firmware_nowait(THIS_MODULE, 1, "ar9170-1.fw",
844 &aru->udev->dev, GFP_KERNEL, aru,
845 ar9170_usb_firmware_inits);
847 ar9170_usb_firmware_failed(aru);
850 static bool ar9170_requires_one_stage(const struct usb_device_id *id)
852 if (!id->driver_info)
854 if (id->driver_info == AR9170_REQ_FW1_ONLY)
859 static int ar9170_usb_probe(struct usb_interface *intf,
860 const struct usb_device_id *id)
862 struct ar9170_usb *aru;
864 struct usb_device *udev;
867 aru = ar9170_alloc(sizeof(*aru));
873 udev = interface_to_usbdev(intf);
879 aru->req_one_stage_fw = ar9170_requires_one_stage(id);
881 usb_set_intfdata(intf, aru);
882 SET_IEEE80211_DEV(ar->hw, &intf->dev);
884 init_usb_anchor(&aru->rx_submitted);
885 init_usb_anchor(&aru->tx_pending);
886 init_usb_anchor(&aru->tx_submitted);
887 init_completion(&aru->cmd_wait);
888 init_completion(&aru->firmware_loading_complete);
889 spin_lock_init(&aru->tx_urb_lock);
891 aru->tx_pending_urbs = 0;
892 atomic_set(&aru->tx_submitted_urbs, 0);
894 aru->common.stop = ar9170_usb_stop;
895 aru->common.flush = ar9170_usb_flush;
896 aru->common.open = ar9170_usb_open;
897 aru->common.tx = ar9170_usb_tx;
898 aru->common.exec_cmd = ar9170_usb_exec_cmd;
899 aru->common.callback_cmd = ar9170_usb_callback_cmd;
902 udev->reset_resume = 1;
903 #endif /* CONFIG_PM */
904 err = ar9170_usb_reset(aru);
908 usb_get_dev(aru->udev);
909 return request_firmware_nowait(THIS_MODULE, 1, "ar9170.fw",
910 &aru->udev->dev, GFP_KERNEL, aru,
911 ar9170_usb_firmware_step2);
913 usb_set_intfdata(intf, NULL);
915 ieee80211_free_hw(ar->hw);
920 static void ar9170_usb_disconnect(struct usb_interface *intf)
922 struct ar9170_usb *aru = usb_get_intfdata(intf);
927 aru->common.state = AR9170_IDLE;
929 wait_for_completion(&aru->firmware_loading_complete);
931 ar9170_unregister(&aru->common);
932 ar9170_usb_cancel_urbs(aru);
934 usb_put_dev(aru->udev);
935 usb_set_intfdata(intf, NULL);
936 ieee80211_free_hw(aru->common.hw);
938 release_firmware(aru->init_values);
939 release_firmware(aru->firmware);
943 static int ar9170_suspend(struct usb_interface *intf,
944 pm_message_t message)
946 struct ar9170_usb *aru = usb_get_intfdata(intf);
951 aru->common.state = AR9170_IDLE;
952 ar9170_usb_cancel_urbs(aru);
957 static int ar9170_resume(struct usb_interface *intf)
959 struct ar9170_usb *aru = usb_get_intfdata(intf);
965 usb_unpoison_anchored_urbs(&aru->rx_submitted);
966 usb_unpoison_anchored_urbs(&aru->tx_submitted);
968 err = ar9170_usb_init_device(aru);
972 err = ar9170_usb_open(&aru->common);
979 aru->common.state = AR9170_IDLE;
980 ar9170_usb_cancel_urbs(aru);
984 #endif /* CONFIG_PM */
986 static struct usb_driver ar9170_driver = {
988 .probe = ar9170_usb_probe,
989 .disconnect = ar9170_usb_disconnect,
990 .id_table = ar9170_usb_ids,
993 .suspend = ar9170_suspend,
994 .resume = ar9170_resume,
995 .reset_resume = ar9170_resume,
996 #endif /* CONFIG_PM */
999 static int __init ar9170_init(void)
1001 return usb_register(&ar9170_driver);
1004 static void __exit ar9170_exit(void)
1006 usb_deregister(&ar9170_driver);
1009 module_init(ar9170_init);
1010 module_exit(ar9170_exit);