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 = usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
166
if (unlikely(!aru)) {
167
dev_kfree_skb_irq(skb);
171
atomic_dec(&aru->tx_submitted_urbs);
173
ar9170_tx_callback(&aru->common, skb);
175
ar9170_usb_submit_urb(aru);
178
static void ar9170_usb_tx_urb_complete(struct urb *urb)
182
static void ar9170_usb_irq_completed(struct urb *urb)
184
struct ar9170_usb *aru = urb->context;
186
switch (urb->status) {
187
/* everything is fine */
202
ar9170_handle_command_response(&aru->common, urb->transfer_buffer,
206
usb_anchor_urb(urb, &aru->rx_submitted);
207
if (usb_submit_urb(urb, GFP_ATOMIC)) {
208
usb_unanchor_urb(urb);
215
usb_free_coherent(aru->udev, 64, urb->transfer_buffer, urb->transfer_dma);
218
static void ar9170_usb_rx_completed(struct urb *urb)
220
struct sk_buff *skb = urb->context;
221
struct ar9170_usb *aru = usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
227
switch (urb->status) {
228
/* everything is fine */
243
skb_put(skb, urb->actual_length);
244
ar9170_rx(&aru->common, skb);
247
skb_reset_tail_pointer(skb);
250
usb_anchor_urb(urb, &aru->rx_submitted);
251
err = usb_submit_urb(urb, GFP_ATOMIC);
253
usb_unanchor_urb(urb);
260
dev_kfree_skb_irq(skb);
263
static int ar9170_usb_prep_rx_urb(struct ar9170_usb *aru,
264
struct urb *urb, gfp_t gfp)
268
skb = __dev_alloc_skb(AR9170_MAX_RX_BUFFER_SIZE + 32, gfp);
272
/* reserve some space for mac80211's radiotap */
273
skb_reserve(skb, 32);
275
usb_fill_bulk_urb(urb, aru->udev,
276
usb_rcvbulkpipe(aru->udev, AR9170_EP_RX),
277
skb->data, min(skb_tailroom(skb),
278
AR9170_MAX_RX_BUFFER_SIZE),
279
ar9170_usb_rx_completed, skb);
284
static int ar9170_usb_alloc_rx_irq_urb(struct ar9170_usb *aru)
286
struct urb *urb = NULL;
290
/* initialize interrupt endpoint */
291
urb = usb_alloc_urb(0, GFP_KERNEL);
295
ibuf = usb_alloc_coherent(aru->udev, 64, GFP_KERNEL, &urb->transfer_dma);
299
usb_fill_int_urb(urb, aru->udev,
300
usb_rcvintpipe(aru->udev, AR9170_EP_IRQ), ibuf,
301
64, ar9170_usb_irq_completed, aru, 1);
302
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
304
usb_anchor_urb(urb, &aru->rx_submitted);
305
err = usb_submit_urb(urb, GFP_KERNEL);
307
usb_unanchor_urb(urb);
308
usb_free_coherent(aru->udev, 64, urb->transfer_buffer,
317
static int ar9170_usb_alloc_rx_bulk_urbs(struct ar9170_usb *aru)
323
for (i = 0; i < AR9170_NUM_RX_URBS; i++) {
325
urb = usb_alloc_urb(0, GFP_KERNEL);
329
err = ar9170_usb_prep_rx_urb(aru, urb, GFP_KERNEL);
335
usb_anchor_urb(urb, &aru->rx_submitted);
336
err = usb_submit_urb(urb, GFP_KERNEL);
338
usb_unanchor_urb(urb);
339
dev_kfree_skb_any((void *) urb->transfer_buffer);
346
/* the device now waiting for a firmware. */
347
aru->common.state = AR9170_IDLE;
352
usb_kill_anchored_urbs(&aru->rx_submitted);
356
static int ar9170_usb_flush(struct ar9170 *ar)
358
struct ar9170_usb *aru = (void *) ar;
363
aru->common.state = AR9170_IDLE;
365
usb_wait_anchor_empty_timeout(&aru->tx_pending,
366
msecs_to_jiffies(800));
367
while ((urb = usb_get_from_anchor(&aru->tx_pending))) {
368
ar9170_tx_callback(&aru->common, (void *) urb->context);
372
/* lets wait a while until the tx - queues are dried out */
373
ret = usb_wait_anchor_empty_timeout(&aru->tx_submitted,
374
msecs_to_jiffies(100));
378
usb_kill_anchored_urbs(&aru->tx_submitted);
380
if (IS_ACCEPTING_CMD(ar))
381
aru->common.state = AR9170_STARTED;
386
static void ar9170_usb_cancel_urbs(struct ar9170_usb *aru)
390
aru->common.state = AR9170_UNKNOWN_STATE;
392
err = ar9170_usb_flush(&aru->common);
394
dev_err(&aru->udev->dev, "stuck tx urbs!\n");
396
usb_poison_anchored_urbs(&aru->tx_submitted);
397
usb_poison_anchored_urbs(&aru->rx_submitted);
400
static int ar9170_usb_exec_cmd(struct ar9170 *ar, enum ar9170_cmd cmd,
401
unsigned int plen, void *payload,
402
unsigned int outlen, void *out)
404
struct ar9170_usb *aru = (void *) ar;
405
struct urb *urb = NULL;
409
if (unlikely(!IS_ACCEPTING_CMD(ar)))
412
if (WARN_ON(plen > AR9170_MAX_CMD_LEN - 4))
415
urb = usb_alloc_urb(0, GFP_ATOMIC);
419
ar->cmdbuf[0] = cpu_to_le32(plen);
420
ar->cmdbuf[0] |= cpu_to_le32(cmd << 8);
421
/* writing multiple regs fills this buffer already */
422
if (plen && payload != (u8 *)(&ar->cmdbuf[1]))
423
memcpy(&ar->cmdbuf[1], payload, plen);
425
spin_lock_irqsave(&aru->common.cmdlock, flags);
426
aru->readbuf = (u8 *)out;
427
aru->readlen = outlen;
428
spin_unlock_irqrestore(&aru->common.cmdlock, flags);
430
usb_fill_int_urb(urb, aru->udev,
431
usb_sndintpipe(aru->udev, AR9170_EP_CMD),
432
aru->common.cmdbuf, plen + 4,
433
ar9170_usb_tx_urb_complete, NULL, 1);
435
usb_anchor_urb(urb, &aru->tx_submitted);
436
err = usb_submit_urb(urb, GFP_ATOMIC);
438
usb_unanchor_urb(urb);
444
err = wait_for_completion_timeout(&aru->cmd_wait, HZ);
450
if (aru->readlen != outlen) {
458
/* Maybe the device was removed in the second we were waiting? */
459
if (IS_STARTED(ar)) {
460
dev_err(&aru->udev->dev, "no command feedback "
461
"received (%d).\n", err);
463
/* provide some maybe useful debug information */
464
print_hex_dump_bytes("ar9170 cmd: ", DUMP_PREFIX_NONE,
465
aru->common.cmdbuf, plen + 4);
469
/* invalidate to avoid completing the next prematurely */
470
spin_lock_irqsave(&aru->common.cmdlock, flags);
473
spin_unlock_irqrestore(&aru->common.cmdlock, flags);
480
static int ar9170_usb_tx(struct ar9170 *ar, struct sk_buff *skb)
482
struct ar9170_usb *aru = (struct ar9170_usb *) ar;
485
if (unlikely(!IS_STARTED(ar))) {
486
/* Seriously, what were you drink... err... thinking!? */
490
urb = usb_alloc_urb(0, GFP_ATOMIC);
494
usb_fill_bulk_urb(urb, aru->udev,
495
usb_sndbulkpipe(aru->udev, AR9170_EP_TX),
497
ar9170_usb_tx_urb_complete_frame, skb);
498
urb->transfer_flags |= URB_ZERO_PACKET;
500
usb_anchor_urb(urb, &aru->tx_pending);
501
aru->tx_pending_urbs++;
505
ar9170_usb_submit_urb(aru);
509
static void ar9170_usb_callback_cmd(struct ar9170 *ar, u32 len , void *buffer)
511
struct ar9170_usb *aru = (void *) ar;
515
if (unlikely(!buffer))
518
in = le32_to_cpup((__le32 *)buffer);
519
out = le32_to_cpu(ar->cmdbuf[0]);
521
/* mask off length byte */
524
if (aru->readlen >= 0) {
525
/* add expected length */
528
/* add obtained length */
533
* Some commands (e.g: AR9170_CMD_FREQUENCY) have a variable response
534
* length and we cannot predict the correct length in advance.
535
* So we only check if we provided enough space for the data.
537
if (unlikely(out < in)) {
538
dev_warn(&aru->udev->dev, "received invalid command response "
539
"got %d bytes, instead of %d bytes "
540
"and the resp length is %d bytes\n",
542
print_hex_dump_bytes("ar9170 invalid resp: ",
543
DUMP_PREFIX_OFFSET, buffer, len);
545
* Do not complete, then the command times out,
546
* and we get a stack trace from there.
551
spin_lock_irqsave(&aru->common.cmdlock, flags);
552
if (aru->readbuf && len > 0) {
553
memcpy(aru->readbuf, buffer + 4, len - 4);
556
complete(&aru->cmd_wait);
557
spin_unlock_irqrestore(&aru->common.cmdlock, flags);
560
static int ar9170_usb_upload(struct ar9170_usb *aru, const void *data,
561
size_t len, u32 addr, bool complete)
564
u8 *buf = kmalloc(4096, GFP_KERNEL);
570
transfer = min_t(int, len, 4096);
571
memcpy(buf, data, transfer);
573
err = usb_control_msg(aru->udev, usb_sndctrlpipe(aru->udev, 0),
574
0x30 /* FW DL */, 0x40 | USB_DIR_OUT,
575
addr >> 8, 0, buf, transfer, 1000);
589
err = usb_control_msg(aru->udev, usb_sndctrlpipe(aru->udev, 0),
590
0x31 /* FW DL COMPLETE */,
591
0x40 | USB_DIR_OUT, 0, 0, NULL, 0, 5000);
597
static int ar9170_usb_reset(struct ar9170_usb *aru)
599
int ret, lock = (aru->intf->condition != USB_INTERFACE_BINDING);
602
ret = usb_lock_device_for_reset(aru->udev, aru->intf);
604
dev_err(&aru->udev->dev, "unable to lock device "
605
"for reset (%d).\n", ret);
610
ret = usb_reset_device(aru->udev);
612
usb_unlock_device(aru->udev);
614
/* let it rest - for a second - */
620
static int ar9170_usb_upload_firmware(struct ar9170_usb *aru)
624
if (!aru->init_values)
625
goto upload_fw_start;
627
/* First, upload initial values to device RAM */
628
err = ar9170_usb_upload(aru, aru->init_values->data,
629
aru->init_values->size, 0x102800, false);
631
dev_err(&aru->udev->dev, "firmware part 1 "
632
"upload failed (%d).\n", err);
638
/* Then, upload the firmware itself and start it */
639
return ar9170_usb_upload(aru, aru->firmware->data, aru->firmware->size,
643
static int ar9170_usb_init_transport(struct ar9170_usb *aru)
645
struct ar9170 *ar = (void *) &aru->common;
648
ar9170_regwrite_begin(ar);
650
/* Set USB Rx stream mode MAX packet number to 2 */
651
ar9170_regwrite(AR9170_USB_REG_MAX_AGG_UPLOAD, 0x4);
653
/* Set USB Rx stream mode timeout to 10us */
654
ar9170_regwrite(AR9170_USB_REG_UPLOAD_TIME_CTL, 0x80);
656
ar9170_regwrite_finish();
658
err = ar9170_regwrite_result();
660
dev_err(&aru->udev->dev, "USB setup failed (%d).\n", err);
665
static void ar9170_usb_stop(struct ar9170 *ar)
667
struct ar9170_usb *aru = (void *) ar;
670
if (IS_ACCEPTING_CMD(ar))
671
aru->common.state = AR9170_STOPPED;
673
ret = ar9170_usb_flush(ar);
675
dev_err(&aru->udev->dev, "kill pending tx urbs.\n");
677
usb_poison_anchored_urbs(&aru->tx_submitted);
681
* So far we freed all tx urbs, but we won't dare to touch any rx urbs.
682
* Else we would end up with a unresponsive device...
686
static int ar9170_usb_open(struct ar9170 *ar)
688
struct ar9170_usb *aru = (void *) ar;
691
usb_unpoison_anchored_urbs(&aru->tx_submitted);
692
err = ar9170_usb_init_transport(aru);
694
usb_poison_anchored_urbs(&aru->tx_submitted);
698
aru->common.state = AR9170_IDLE;
702
static int ar9170_usb_init_device(struct ar9170_usb *aru)
706
err = ar9170_usb_alloc_rx_irq_urb(aru);
710
err = ar9170_usb_alloc_rx_bulk_urbs(aru);
714
err = ar9170_usb_upload_firmware(aru);
716
err = ar9170_echo_test(&aru->common, 0x60d43110);
718
/* force user invention, by disabling the device */
719
err = usb_driver_set_configuration(aru->udev, -1);
720
dev_err(&aru->udev->dev, "device is in a bad state. "
721
"please reconnect it!\n");
729
ar9170_usb_cancel_urbs(aru);
735
static void ar9170_usb_firmware_failed(struct ar9170_usb *aru)
737
struct device *parent = aru->udev->dev.parent;
738
struct usb_device *udev;
741
* Store a copy of the usb_device pointer locally.
742
* This is because device_release_driver initiates
743
* ar9170_usb_disconnect, which in turn frees our
744
* driver context (aru).
748
complete(&aru->firmware_loading_complete);
750
/* unbind anything failed */
754
device_release_driver(&udev->dev);
756
device_unlock(parent);
761
static void ar9170_usb_firmware_finish(const struct firmware *fw, void *context)
763
struct ar9170_usb *aru = context;
769
dev_err(&aru->udev->dev, "firmware file not found.\n");
773
err = ar9170_usb_init_device(aru);
777
err = ar9170_usb_open(&aru->common);
781
err = ar9170_register(&aru->common, &aru->udev->dev);
783
ar9170_usb_stop(&aru->common);
787
complete(&aru->firmware_loading_complete);
788
usb_put_dev(aru->udev);
792
ar9170_usb_cancel_urbs(aru);
795
ar9170_usb_firmware_failed(aru);
798
static void ar9170_usb_firmware_inits(const struct firmware *fw,
801
struct ar9170_usb *aru = context;
805
dev_err(&aru->udev->dev, "file with init values not found.\n");
806
ar9170_usb_firmware_failed(aru);
810
aru->init_values = fw;
812
/* ok so we have the init values -- get code for two-stage */
814
err = request_firmware_nowait(THIS_MODULE, 1, "ar9170-2.fw",
815
&aru->udev->dev, GFP_KERNEL, aru,
816
ar9170_usb_firmware_finish);
818
ar9170_usb_firmware_failed(aru);
821
static void ar9170_usb_firmware_step2(const struct firmware *fw, void *context)
823
struct ar9170_usb *aru = context;
827
ar9170_usb_firmware_finish(fw, context);
831
if (aru->req_one_stage_fw) {
832
dev_err(&aru->udev->dev, "ar9170.fw firmware file "
833
"not found and is required for this device\n");
834
ar9170_usb_firmware_failed(aru);
838
dev_err(&aru->udev->dev, "ar9170.fw firmware file "
839
"not found, trying old firmware...\n");
841
err = request_firmware_nowait(THIS_MODULE, 1, "ar9170-1.fw",
842
&aru->udev->dev, GFP_KERNEL, aru,
843
ar9170_usb_firmware_inits);
845
ar9170_usb_firmware_failed(aru);
848
static bool ar9170_requires_one_stage(const struct usb_device_id *id)
850
if (!id->driver_info)
852
if (id->driver_info == AR9170_REQ_FW1_ONLY)
857
static int ar9170_usb_probe(struct usb_interface *intf,
858
const struct usb_device_id *id)
860
struct ar9170_usb *aru;
862
struct usb_device *udev;
865
aru = ar9170_alloc(sizeof(*aru));
871
udev = interface_to_usbdev(intf);
877
aru->req_one_stage_fw = ar9170_requires_one_stage(id);
879
usb_set_intfdata(intf, aru);
880
SET_IEEE80211_DEV(ar->hw, &intf->dev);
882
init_usb_anchor(&aru->rx_submitted);
883
init_usb_anchor(&aru->tx_pending);
884
init_usb_anchor(&aru->tx_submitted);
885
init_completion(&aru->cmd_wait);
886
init_completion(&aru->firmware_loading_complete);
887
spin_lock_init(&aru->tx_urb_lock);
889
aru->tx_pending_urbs = 0;
890
atomic_set(&aru->tx_submitted_urbs, 0);
892
aru->common.stop = ar9170_usb_stop;
893
aru->common.flush = ar9170_usb_flush;
894
aru->common.open = ar9170_usb_open;
895
aru->common.tx = ar9170_usb_tx;
896
aru->common.exec_cmd = ar9170_usb_exec_cmd;
897
aru->common.callback_cmd = ar9170_usb_callback_cmd;
900
udev->reset_resume = 1;
901
#endif /* CONFIG_PM */
902
err = ar9170_usb_reset(aru);
906
usb_get_dev(aru->udev);
907
return request_firmware_nowait(THIS_MODULE, 1, "ar9170.fw",
908
&aru->udev->dev, GFP_KERNEL, aru,
909
ar9170_usb_firmware_step2);
911
usb_set_intfdata(intf, NULL);
913
ieee80211_free_hw(ar->hw);
918
static void ar9170_usb_disconnect(struct usb_interface *intf)
920
struct ar9170_usb *aru = usb_get_intfdata(intf);
925
aru->common.state = AR9170_IDLE;
927
wait_for_completion(&aru->firmware_loading_complete);
929
ar9170_unregister(&aru->common);
930
ar9170_usb_cancel_urbs(aru);
932
usb_put_dev(aru->udev);
933
usb_set_intfdata(intf, NULL);
934
ieee80211_free_hw(aru->common.hw);
936
release_firmware(aru->init_values);
937
release_firmware(aru->firmware);
941
static int ar9170_suspend(struct usb_interface *intf,
942
pm_message_t message)
944
struct ar9170_usb *aru = usb_get_intfdata(intf);
949
aru->common.state = AR9170_IDLE;
950
ar9170_usb_cancel_urbs(aru);
955
static int ar9170_resume(struct usb_interface *intf)
957
struct ar9170_usb *aru = usb_get_intfdata(intf);
963
usb_unpoison_anchored_urbs(&aru->rx_submitted);
964
usb_unpoison_anchored_urbs(&aru->tx_submitted);
966
err = ar9170_usb_init_device(aru);
970
err = ar9170_usb_open(&aru->common);
977
aru->common.state = AR9170_IDLE;
978
ar9170_usb_cancel_urbs(aru);
982
#endif /* CONFIG_PM */
984
static struct usb_driver ar9170_driver = {
986
.probe = ar9170_usb_probe,
987
.disconnect = ar9170_usb_disconnect,
988
.id_table = ar9170_usb_ids,
991
.suspend = ar9170_suspend,
992
.resume = ar9170_resume,
993
.reset_resume = ar9170_resume,
994
#endif /* CONFIG_PM */
997
static int __init ar9170_init(void)
999
return usb_register(&ar9170_driver);
1002
static void __exit ar9170_exit(void)
1004
usb_deregister(&ar9170_driver);
1007
module_init(ar9170_init);
1008
module_exit(ar9170_exit);