]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/wireless/rt2x00/rt2x00usb.c
rt2x00: Optimize get_duration / get_duration_res
[net-next-2.6.git] / drivers / net / wireless / rt2x00 / rt2x00usb.c
CommitLineData
95ea3627 1/*
811aa9ca 2 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
95ea3627
ID
3 <http://rt2x00.serialmonkey.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21/*
22 Module: rt2x00usb
23 Abstract: rt2x00 generic usb device routines.
24 */
25
95ea3627
ID
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/usb.h>
3d82346c 29#include <linux/bug.h>
95ea3627
ID
30
31#include "rt2x00.h"
32#include "rt2x00usb.h"
33
34/*
35 * Interfacing with the HW.
36 */
0e14f6d3 37int rt2x00usb_vendor_request(struct rt2x00_dev *rt2x00dev,
95ea3627
ID
38 const u8 request, const u8 requesttype,
39 const u16 offset, const u16 value,
40 void *buffer, const u16 buffer_length,
e9136550 41 const int timeout)
95ea3627 42{
c1d35dfa 43 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
95ea3627
ID
44 int status;
45 unsigned int i;
46 unsigned int pipe =
47 (requesttype == USB_VENDOR_REQUEST_IN) ?
48 usb_rcvctrlpipe(usb_dev, 0) : usb_sndctrlpipe(usb_dev, 0);
49
3d82346c 50
95ea3627
ID
51 for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
52 status = usb_control_msg(usb_dev, pipe, request, requesttype,
53 value, offset, buffer, buffer_length,
54 timeout);
55 if (status >= 0)
56 return 0;
57
58 /*
e9136550 59 * Check for errors
95ea3627 60 * -ENODEV: Device has disappeared, no point continuing.
e9136550 61 * All other errors: Try again.
95ea3627 62 */
95ea3627
ID
63 else if (status == -ENODEV)
64 break;
65 }
66
67 ERROR(rt2x00dev,
68 "Vendor Request 0x%02x failed for offset 0x%04x with error %d.\n",
69 request, offset, status);
70
71 return status;
72}
73EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request);
74
3d82346c
AB
75int rt2x00usb_vendor_req_buff_lock(struct rt2x00_dev *rt2x00dev,
76 const u8 request, const u8 requesttype,
77 const u16 offset, void *buffer,
78 const u16 buffer_length, const int timeout)
95ea3627
ID
79{
80 int status;
81
3d82346c
AB
82 BUG_ON(!mutex_is_locked(&rt2x00dev->usb_cache_mutex));
83
95ea3627
ID
84 /*
85 * Check for Cache availability.
86 */
21795094 87 if (unlikely(!rt2x00dev->csr.cache || buffer_length > CSR_CACHE_SIZE)) {
95ea3627
ID
88 ERROR(rt2x00dev, "CSR cache not available.\n");
89 return -ENOMEM;
90 }
91
92 if (requesttype == USB_VENDOR_REQUEST_OUT)
21795094 93 memcpy(rt2x00dev->csr.cache, buffer, buffer_length);
95ea3627
ID
94
95 status = rt2x00usb_vendor_request(rt2x00dev, request, requesttype,
21795094 96 offset, 0, rt2x00dev->csr.cache,
95ea3627
ID
97 buffer_length, timeout);
98
99 if (!status && requesttype == USB_VENDOR_REQUEST_IN)
21795094 100 memcpy(buffer, rt2x00dev->csr.cache, buffer_length);
95ea3627
ID
101
102 return status;
103}
3d82346c
AB
104EXPORT_SYMBOL_GPL(rt2x00usb_vendor_req_buff_lock);
105
106int rt2x00usb_vendor_request_buff(struct rt2x00_dev *rt2x00dev,
107 const u8 request, const u8 requesttype,
108 const u16 offset, void *buffer,
109 const u16 buffer_length, const int timeout)
110{
111 int status;
112
113 mutex_lock(&rt2x00dev->usb_cache_mutex);
114
115 status = rt2x00usb_vendor_req_buff_lock(rt2x00dev, request,
116 requesttype, offset, buffer,
117 buffer_length, timeout);
118
119 mutex_unlock(&rt2x00dev->usb_cache_mutex);
120
121 return status;
122}
95ea3627
ID
123EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request_buff);
124
ed0dbeeb
IM
125int rt2x00usb_vendor_request_large_buff(struct rt2x00_dev *rt2x00dev,
126 const u8 request, const u8 requesttype,
82f97b8d 127 const u16 offset, const void *buffer,
ed0dbeeb
IM
128 const u16 buffer_length,
129 const int timeout)
130{
131 int status = 0;
132 unsigned char *tb;
133 u16 off, len, bsize;
134
135 mutex_lock(&rt2x00dev->usb_cache_mutex);
136
82f97b8d 137 tb = (char *)buffer;
ed0dbeeb
IM
138 off = offset;
139 len = buffer_length;
140 while (len && !status) {
141 bsize = min_t(u16, CSR_CACHE_SIZE, len);
142 status = rt2x00usb_vendor_req_buff_lock(rt2x00dev, request,
143 requesttype, off, tb,
144 bsize, timeout);
145
146 tb += bsize;
147 len -= bsize;
148 off += bsize;
149 }
150
151 mutex_unlock(&rt2x00dev->usb_cache_mutex);
152
153 return status;
154}
155EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request_large_buff);
156
95ea3627
ID
157/*
158 * TX data handlers.
159 */
160static void rt2x00usb_interrupt_txdone(struct urb *urb)
161{
181d6902
ID
162 struct queue_entry *entry = (struct queue_entry *)urb->context;
163 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
181d6902 164 struct txdone_entry_desc txdesc;
95ea3627 165
0262ab0d 166 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags) ||
d74f5ba4 167 !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
95ea3627
ID
168 return;
169
95ea3627
ID
170 /*
171 * Obtain the status about this packet.
fb55f4d1
ID
172 * Note that when the status is 0 it does not mean the
173 * frame was send out correctly. It only means the frame
174 * was succesfully pushed to the hardware, we have no
175 * way to determine the transmission status right now.
176 * (Only indirectly by looking at the failed TX counters
177 * in the register).
95ea3627 178 */
f126cba4 179 txdesc.flags = 0;
fb55f4d1
ID
180 if (!urb->status)
181 __set_bit(TXDONE_UNKNOWN, &txdesc.flags);
182 else
183 __set_bit(TXDONE_FAILURE, &txdesc.flags);
181d6902 184 txdesc.retry = 0;
95ea3627 185
181d6902 186 rt2x00lib_txdone(entry, &txdesc);
95ea3627
ID
187}
188
6db3786a 189int rt2x00usb_write_tx_data(struct queue_entry *entry)
95ea3627 190{
6db3786a 191 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
c1d35dfa 192 struct usb_device *usb_dev = to_usb_device_intf(rt2x00dev->dev);
b8be63ff 193 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
181d6902 194 struct skb_frame_desc *skbdesc;
dd9fa2d2 195 u32 length;
95ea3627 196
95ea3627
ID
197 /*
198 * Add the descriptor in front of the skb.
199 */
6db3786a
ID
200 skb_push(entry->skb, entry->queue->desc_size);
201 memset(entry->skb->data, 0, entry->queue->desc_size);
95ea3627 202
08992f7f
ID
203 /*
204 * Fill in skb descriptor
205 */
6db3786a 206 skbdesc = get_skb_frame_desc(entry->skb);
6db3786a
ID
207 skbdesc->desc = entry->skb->data;
208 skbdesc->desc_len = entry->queue->desc_size;
08992f7f 209
95ea3627 210 /*
dd9fa2d2
ID
211 * USB devices cannot blindly pass the skb->len as the
212 * length of the data to usb_fill_bulk_urb. Pass the skb
213 * to the driver to determine what the length should be.
95ea3627 214 */
6db3786a 215 length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev, entry->skb);
95ea3627 216
6db3786a
ID
217 usb_fill_bulk_urb(entry_priv->urb, usb_dev,
218 usb_sndbulkpipe(usb_dev, 1),
219 entry->skb->data, length,
220 rt2x00usb_interrupt_txdone, entry);
95ea3627 221
1abc3656
MN
222 /*
223 * Make sure the skb->data pointer points to the frame, not the
224 * descriptor.
225 */
226 skb_pull(entry->skb, entry->queue->desc_size);
227
95ea3627
ID
228 return 0;
229}
230EXPORT_SYMBOL_GPL(rt2x00usb_write_tx_data);
231
f019d514
ID
232static inline void rt2x00usb_kick_tx_entry(struct queue_entry *entry)
233{
234 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
235
0262ab0d 236 if (test_and_clear_bit(ENTRY_DATA_PENDING, &entry->flags))
f019d514
ID
237 usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
238}
239
240void rt2x00usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
241 const enum data_queue_qid qid)
242{
243 struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, qid);
244 unsigned long irqflags;
245 unsigned int index;
246 unsigned int index_done;
247 unsigned int i;
248
249 /*
250 * Only protect the range we are going to loop over,
251 * if during our loop a extra entry is set to pending
252 * it should not be kicked during this run, since it
253 * is part of another TX operation.
254 */
255 spin_lock_irqsave(&queue->lock, irqflags);
256 index = queue->index[Q_INDEX];
257 index_done = queue->index[Q_INDEX_DONE];
258 spin_unlock_irqrestore(&queue->lock, irqflags);
259
260 /*
261 * Start from the TX done pointer, this guarentees that we will
262 * send out all frames in the correct order.
263 */
264 if (index_done < index) {
265 for (i = index_done; i < index; i++)
266 rt2x00usb_kick_tx_entry(&queue->entries[i]);
267 } else {
268 for (i = index_done; i < queue->limit; i++)
269 rt2x00usb_kick_tx_entry(&queue->entries[i]);
270
271 for (i = 0; i < index; i++)
272 rt2x00usb_kick_tx_entry(&queue->entries[i]);
273 }
274}
275EXPORT_SYMBOL_GPL(rt2x00usb_kick_tx_queue);
276
95ea3627
ID
277/*
278 * RX data handlers.
279 */
280static void rt2x00usb_interrupt_rxdone(struct urb *urb)
281{
181d6902
ID
282 struct queue_entry *entry = (struct queue_entry *)urb->context;
283 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
c4da0048 284 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
a26cbc65 285 u8 rxd[32];
95ea3627 286
0262ab0d 287 if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags) ||
d74f5ba4 288 !test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
95ea3627
ID
289 return;
290
291 /*
292 * Check if the received data is simply too small
293 * to be actually valid, or if the urb is signaling
294 * a problem.
295 */
d74f5ba4 296 if (urb->actual_length < entry->queue->desc_size || urb->status) {
0262ab0d 297 set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
d74f5ba4
ID
298 usb_submit_urb(urb, GFP_ATOMIC);
299 return;
300 }
95ea3627 301
40561b84 302 /*
c4da0048 303 * Fill in desc fields of the skb descriptor
40561b84 304 */
a26cbc65
GW
305 skbdesc->desc = rxd;
306 skbdesc->desc_len = entry->queue->desc_size;
40561b84 307
95ea3627
ID
308 /*
309 * Send the frame to rt2x00lib for further processing.
310 */
c4da0048 311 rt2x00lib_rxdone(rt2x00dev, entry);
95ea3627
ID
312}
313
314/*
315 * Radio handlers
316 */
95ea3627
ID
317void rt2x00usb_disable_radio(struct rt2x00_dev *rt2x00dev)
318{
b8be63ff
ID
319 struct queue_entry_priv_usb *entry_priv;
320 struct queue_entry_priv_usb_bcn *bcn_priv;
40af48ce 321 struct data_queue *queue;
95ea3627
ID
322 unsigned int i;
323
bd394a74 324 rt2x00usb_vendor_request_sw(rt2x00dev, USB_RX_CONTROL, 0, 0,
95ea3627
ID
325 REGISTER_TIMEOUT);
326
327 /*
181d6902 328 * Cancel all queues.
95ea3627 329 */
40af48ce
ID
330 queue_for_each(rt2x00dev, queue) {
331 for (i = 0; i < queue->limit; i++) {
332 entry_priv = queue->entries[i].priv_data;
333 usb_kill_urb(entry_priv->urb);
334 }
95ea3627 335 }
330e3f95 336
b8be63ff 337 /*
edfa78b2 338 * Kill guardian urb (if required by driver).
b8be63ff 339 */
edfa78b2
ID
340 if (!test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags))
341 return;
342
330e3f95 343 for (i = 0; i < rt2x00dev->bcn->limit; i++) {
b8be63ff
ID
344 bcn_priv = rt2x00dev->bcn->entries[i].priv_data;
345 if (bcn_priv->guardian_urb)
346 usb_kill_urb(bcn_priv->guardian_urb);
330e3f95 347 }
95ea3627
ID
348}
349EXPORT_SYMBOL_GPL(rt2x00usb_disable_radio);
350
351/*
352 * Device initialization handlers.
353 */
798b7adb 354void rt2x00usb_clear_entry(struct queue_entry *entry)
837e7f24 355{
798b7adb
ID
356 struct usb_device *usb_dev =
357 to_usb_device_intf(entry->queue->rt2x00dev->dev);
b8be63ff 358 struct queue_entry_priv_usb *entry_priv = entry->priv_data;
837e7f24 359
798b7adb
ID
360 if (entry->queue->qid == QID_RX) {
361 usb_fill_bulk_urb(entry_priv->urb, usb_dev,
362 usb_rcvbulkpipe(usb_dev, 1),
363 entry->skb->data, entry->skb->len,
364 rt2x00usb_interrupt_rxdone, entry);
837e7f24 365
798b7adb
ID
366 set_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags);
367 usb_submit_urb(entry_priv->urb, GFP_ATOMIC);
368 } else {
369 entry->flags = 0;
370 }
837e7f24 371}
798b7adb 372EXPORT_SYMBOL_GPL(rt2x00usb_clear_entry);
837e7f24 373
95ea3627 374static int rt2x00usb_alloc_urb(struct rt2x00_dev *rt2x00dev,
181d6902 375 struct data_queue *queue)
95ea3627 376{
b8be63ff
ID
377 struct queue_entry_priv_usb *entry_priv;
378 struct queue_entry_priv_usb_bcn *bcn_priv;
95ea3627
ID
379 unsigned int i;
380
b8be63ff
ID
381 for (i = 0; i < queue->limit; i++) {
382 entry_priv = queue->entries[i].priv_data;
383 entry_priv->urb = usb_alloc_urb(0, GFP_KERNEL);
384 if (!entry_priv->urb)
385 return -ENOMEM;
386 }
387
95ea3627 388 /*
b8be63ff
ID
389 * If this is not the beacon queue or
390 * no guardian byte was required for the beacon,
391 * then we are done.
95ea3627 392 */
b8be63ff
ID
393 if (rt2x00dev->bcn != queue ||
394 !test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags))
395 return 0;
396
181d6902 397 for (i = 0; i < queue->limit; i++) {
b8be63ff
ID
398 bcn_priv = queue->entries[i].priv_data;
399 bcn_priv->guardian_urb = usb_alloc_urb(0, GFP_KERNEL);
400 if (!bcn_priv->guardian_urb)
95ea3627
ID
401 return -ENOMEM;
402 }
403
404 return 0;
405}
406
407static void rt2x00usb_free_urb(struct rt2x00_dev *rt2x00dev,
181d6902 408 struct data_queue *queue)
95ea3627 409{
b8be63ff
ID
410 struct queue_entry_priv_usb *entry_priv;
411 struct queue_entry_priv_usb_bcn *bcn_priv;
95ea3627
ID
412 unsigned int i;
413
181d6902 414 if (!queue->entries)
95ea3627
ID
415 return;
416
181d6902 417 for (i = 0; i < queue->limit; i++) {
b8be63ff
ID
418 entry_priv = queue->entries[i].priv_data;
419 usb_kill_urb(entry_priv->urb);
420 usb_free_urb(entry_priv->urb);
95ea3627 421 }
b8be63ff
ID
422
423 /*
424 * If this is not the beacon queue or
425 * no guardian byte was required for the beacon,
426 * then we are done.
427 */
428 if (rt2x00dev->bcn != queue ||
429 !test_bit(DRIVER_REQUIRE_BEACON_GUARD, &rt2x00dev->flags))
430 return;
431
432 for (i = 0; i < queue->limit; i++) {
433 bcn_priv = queue->entries[i].priv_data;
434 usb_kill_urb(bcn_priv->guardian_urb);
435 usb_free_urb(bcn_priv->guardian_urb);
436 }
95ea3627
ID
437}
438
439int rt2x00usb_initialize(struct rt2x00_dev *rt2x00dev)
440{
181d6902 441 struct data_queue *queue;
30caa6e3 442 int status;
95ea3627
ID
443
444 /*
445 * Allocate DMA
446 */
181d6902
ID
447 queue_for_each(rt2x00dev, queue) {
448 status = rt2x00usb_alloc_urb(rt2x00dev, queue);
95ea3627
ID
449 if (status)
450 goto exit;
451 }
452
95ea3627
ID
453 return 0;
454
455exit:
456 rt2x00usb_uninitialize(rt2x00dev);
457
458 return status;
459}
460EXPORT_SYMBOL_GPL(rt2x00usb_initialize);
461
462void rt2x00usb_uninitialize(struct rt2x00_dev *rt2x00dev)
463{
181d6902 464 struct data_queue *queue;
95ea3627 465
181d6902
ID
466 queue_for_each(rt2x00dev, queue)
467 rt2x00usb_free_urb(rt2x00dev, queue);
95ea3627
ID
468}
469EXPORT_SYMBOL_GPL(rt2x00usb_uninitialize);
470
471/*
472 * USB driver handlers.
473 */
474static void rt2x00usb_free_reg(struct rt2x00_dev *rt2x00dev)
475{
476 kfree(rt2x00dev->rf);
477 rt2x00dev->rf = NULL;
478
479 kfree(rt2x00dev->eeprom);
480 rt2x00dev->eeprom = NULL;
481
21795094
ID
482 kfree(rt2x00dev->csr.cache);
483 rt2x00dev->csr.cache = NULL;
95ea3627
ID
484}
485
486static int rt2x00usb_alloc_reg(struct rt2x00_dev *rt2x00dev)
487{
21795094
ID
488 rt2x00dev->csr.cache = kzalloc(CSR_CACHE_SIZE, GFP_KERNEL);
489 if (!rt2x00dev->csr.cache)
95ea3627
ID
490 goto exit;
491
492 rt2x00dev->eeprom = kzalloc(rt2x00dev->ops->eeprom_size, GFP_KERNEL);
493 if (!rt2x00dev->eeprom)
494 goto exit;
495
496 rt2x00dev->rf = kzalloc(rt2x00dev->ops->rf_size, GFP_KERNEL);
497 if (!rt2x00dev->rf)
498 goto exit;
499
500 return 0;
501
502exit:
503 ERROR_PROBE("Failed to allocate registers.\n");
504
505 rt2x00usb_free_reg(rt2x00dev);
506
507 return -ENOMEM;
508}
509
510int rt2x00usb_probe(struct usb_interface *usb_intf,
511 const struct usb_device_id *id)
512{
513 struct usb_device *usb_dev = interface_to_usbdev(usb_intf);
514 struct rt2x00_ops *ops = (struct rt2x00_ops *)id->driver_info;
515 struct ieee80211_hw *hw;
516 struct rt2x00_dev *rt2x00dev;
517 int retval;
518
519 usb_dev = usb_get_dev(usb_dev);
520
521 hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
522 if (!hw) {
523 ERROR_PROBE("Failed to allocate hardware.\n");
524 retval = -ENOMEM;
525 goto exit_put_device;
526 }
527
528 usb_set_intfdata(usb_intf, hw);
529
530 rt2x00dev = hw->priv;
14a3bf89 531 rt2x00dev->dev = &usb_intf->dev;
95ea3627
ID
532 rt2x00dev->ops = ops;
533 rt2x00dev->hw = hw;
3d82346c 534 mutex_init(&rt2x00dev->usb_cache_mutex);
95ea3627 535
b242e891
ID
536 rt2x00dev->usb_maxpacket =
537 usb_maxpacket(usb_dev, usb_sndbulkpipe(usb_dev, 1), 1);
538 if (!rt2x00dev->usb_maxpacket)
539 rt2x00dev->usb_maxpacket = 1;
540
95ea3627
ID
541 retval = rt2x00usb_alloc_reg(rt2x00dev);
542 if (retval)
543 goto exit_free_device;
544
545 retval = rt2x00lib_probe_dev(rt2x00dev);
546 if (retval)
547 goto exit_free_reg;
548
549 return 0;
550
551exit_free_reg:
552 rt2x00usb_free_reg(rt2x00dev);
553
554exit_free_device:
555 ieee80211_free_hw(hw);
556
557exit_put_device:
558 usb_put_dev(usb_dev);
559
560 usb_set_intfdata(usb_intf, NULL);
561
562 return retval;
563}
564EXPORT_SYMBOL_GPL(rt2x00usb_probe);
565
566void rt2x00usb_disconnect(struct usb_interface *usb_intf)
567{
568 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
569 struct rt2x00_dev *rt2x00dev = hw->priv;
570
571 /*
572 * Free all allocated data.
573 */
574 rt2x00lib_remove_dev(rt2x00dev);
575 rt2x00usb_free_reg(rt2x00dev);
576 ieee80211_free_hw(hw);
577
578 /*
579 * Free the USB device data.
580 */
581 usb_set_intfdata(usb_intf, NULL);
582 usb_put_dev(interface_to_usbdev(usb_intf));
583}
584EXPORT_SYMBOL_GPL(rt2x00usb_disconnect);
585
586#ifdef CONFIG_PM
587int rt2x00usb_suspend(struct usb_interface *usb_intf, pm_message_t state)
588{
589 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
590 struct rt2x00_dev *rt2x00dev = hw->priv;
591 int retval;
592
593 retval = rt2x00lib_suspend(rt2x00dev, state);
594 if (retval)
595 return retval;
596
597 rt2x00usb_free_reg(rt2x00dev);
598
599 /*
600 * Decrease usbdev refcount.
601 */
602 usb_put_dev(interface_to_usbdev(usb_intf));
603
604 return 0;
605}
606EXPORT_SYMBOL_GPL(rt2x00usb_suspend);
607
608int rt2x00usb_resume(struct usb_interface *usb_intf)
609{
610 struct ieee80211_hw *hw = usb_get_intfdata(usb_intf);
611 struct rt2x00_dev *rt2x00dev = hw->priv;
612 int retval;
613
614 usb_get_dev(interface_to_usbdev(usb_intf));
615
616 retval = rt2x00usb_alloc_reg(rt2x00dev);
617 if (retval)
618 return retval;
619
620 retval = rt2x00lib_resume(rt2x00dev);
621 if (retval)
622 goto exit_free_reg;
623
624 return 0;
625
626exit_free_reg:
627 rt2x00usb_free_reg(rt2x00dev);
628
629 return retval;
630}
631EXPORT_SYMBOL_GPL(rt2x00usb_resume);
632#endif /* CONFIG_PM */
633
634/*
181d6902 635 * rt2x00usb module information.
95ea3627
ID
636 */
637MODULE_AUTHOR(DRV_PROJECT);
638MODULE_VERSION(DRV_VERSION);
181d6902 639MODULE_DESCRIPTION("rt2x00 usb library");
95ea3627 640MODULE_LICENSE("GPL");