]>
Commit | Line | Data |
---|---|---|
ca97b838 BZ |
1 | /* |
2 | ************************************************************************* | |
3 | * Ralink Tech Inc. | |
4 | * 5F., No.36, Taiyuan St., Jhubei City, | |
5 | * Hsinchu County 302, | |
6 | * Taiwan, R.O.C. | |
7 | * | |
8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify * | |
11 | * it under the terms of the GNU General Public License as published by * | |
12 | * the Free Software Foundation; either version 2 of the License, or * | |
13 | * (at your option) any later version. * | |
14 | * * | |
15 | * This program is distributed in the hope that it will be useful, * | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
18 | * GNU General Public License for more details. * | |
19 | * * | |
20 | * You should have received a copy of the GNU General Public License * | |
21 | * along with this program; if not, write to the * | |
22 | * Free Software Foundation, Inc., * | |
23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | |
24 | * * | |
25 | *************************************************************************/ | |
26 | ||
27 | #include "rt_config.h" | |
28 | ||
9f548a2a BZ |
29 | /* Following information will be show when you run 'modinfo' */ |
30 | /* *** If you have a solution for the bug in current version of driver, please mail to me. */ | |
31 | /* Otherwise post to forum in ralinktech's web site(www.ralinktech.com) and let all users help you. *** */ | |
ca97b838 BZ |
32 | MODULE_AUTHOR("Paul Lin <paul_lin@ralinktech.com>"); |
33 | MODULE_DESCRIPTION("RT2870/RT3070 Wireless Lan Linux Driver"); | |
34 | MODULE_LICENSE("GPL"); | |
35 | #ifdef MODULE_VERSION | |
36 | MODULE_VERSION(STA_DRIVER_VERSION); | |
37 | #endif | |
38 | ||
ca97b838 BZ |
39 | /* module table */ |
40 | struct usb_device_id rtusb_usb_id[] = { | |
41 | #ifdef RT2870 | |
66cd8d6e BZ |
42 | {USB_DEVICE(0x148F, 0x2770)}, /* Ralink */ |
43 | {USB_DEVICE(0x148F, 0x2870)}, /* Ralink */ | |
44 | {USB_DEVICE(0x07B8, 0x2870)}, /* AboCom */ | |
45 | {USB_DEVICE(0x07B8, 0x2770)}, /* AboCom */ | |
46 | {USB_DEVICE(0x0DF6, 0x0039)}, /* Sitecom 2770 */ | |
47 | {USB_DEVICE(0x083A, 0x7512)}, /* Arcadyan 2770 */ | |
48 | {USB_DEVICE(0x0789, 0x0162)}, /* Logitec 2870 */ | |
49 | {USB_DEVICE(0x0789, 0x0163)}, /* Logitec 2870 */ | |
50 | {USB_DEVICE(0x0789, 0x0164)}, /* Logitec 2870 */ | |
51 | {USB_DEVICE(0x177f, 0x0302)}, /* lsusb */ | |
52 | {USB_DEVICE(0x0B05, 0x1731)}, /* Asus */ | |
53 | {USB_DEVICE(0x0B05, 0x1732)}, /* Asus */ | |
54 | {USB_DEVICE(0x0B05, 0x1742)}, /* Asus */ | |
55 | {USB_DEVICE(0x0DF6, 0x0017)}, /* Sitecom */ | |
56 | {USB_DEVICE(0x0DF6, 0x002B)}, /* Sitecom */ | |
57 | {USB_DEVICE(0x0DF6, 0x002C)}, /* Sitecom */ | |
58 | {USB_DEVICE(0x0DF6, 0x002D)}, /* Sitecom */ | |
59 | {USB_DEVICE(0x14B2, 0x3C06)}, /* Conceptronic */ | |
60 | {USB_DEVICE(0x14B2, 0x3C28)}, /* Conceptronic */ | |
61 | {USB_DEVICE(0x2019, 0xED06)}, /* Planex Communications, Inc. */ | |
62 | {USB_DEVICE(0x07D1, 0x3C09)}, /* D-Link */ | |
63 | {USB_DEVICE(0x07D1, 0x3C11)}, /* D-Link */ | |
64 | {USB_DEVICE(0x14B2, 0x3C07)}, /* AL */ | |
65 | {USB_DEVICE(0x050D, 0x8053)}, /* Belkin */ | |
66 | {USB_DEVICE(0x14B2, 0x3C23)}, /* Airlink */ | |
67 | {USB_DEVICE(0x14B2, 0x3C27)}, /* Airlink */ | |
68 | {USB_DEVICE(0x07AA, 0x002F)}, /* Corega */ | |
69 | {USB_DEVICE(0x07AA, 0x003C)}, /* Corega */ | |
70 | {USB_DEVICE(0x07AA, 0x003F)}, /* Corega */ | |
71 | {USB_DEVICE(0x1044, 0x800B)}, /* Gigabyte */ | |
72 | {USB_DEVICE(0x15A9, 0x0006)}, /* Sparklan */ | |
73 | {USB_DEVICE(0x083A, 0xB522)}, /* SMC */ | |
74 | {USB_DEVICE(0x083A, 0xA618)}, /* SMC */ | |
75 | {USB_DEVICE(0x083A, 0x8522)}, /* Arcadyan */ | |
76 | {USB_DEVICE(0x083A, 0x7522)}, /* Arcadyan */ | |
77 | {USB_DEVICE(0x0CDE, 0x0022)}, /* ZCOM */ | |
78 | {USB_DEVICE(0x0586, 0x3416)}, /* Zyxel */ | |
79 | {USB_DEVICE(0x0CDE, 0x0025)}, /* Zyxel */ | |
80 | {USB_DEVICE(0x1740, 0x9701)}, /* EnGenius */ | |
81 | {USB_DEVICE(0x1740, 0x9702)}, /* EnGenius */ | |
82 | {USB_DEVICE(0x0471, 0x200f)}, /* Philips */ | |
83 | {USB_DEVICE(0x14B2, 0x3C25)}, /* Draytek */ | |
84 | {USB_DEVICE(0x13D3, 0x3247)}, /* AzureWave */ | |
85 | {USB_DEVICE(0x083A, 0x6618)}, /* Accton */ | |
86 | {USB_DEVICE(0x15c5, 0x0008)}, /* Amit */ | |
87 | {USB_DEVICE(0x0E66, 0x0001)}, /* Hawking */ | |
88 | {USB_DEVICE(0x0E66, 0x0003)}, /* Hawking */ | |
89 | {USB_DEVICE(0x129B, 0x1828)}, /* Siemens */ | |
90 | {USB_DEVICE(0x157E, 0x300E)}, /* U-Media */ | |
91 | {USB_DEVICE(0x050d, 0x805c)}, | |
92 | {USB_DEVICE(0x050d, 0x815c)}, | |
93 | {USB_DEVICE(0x1482, 0x3C09)}, /* Abocom */ | |
94 | {USB_DEVICE(0x14B2, 0x3C09)}, /* Alpha */ | |
95 | {USB_DEVICE(0x04E8, 0x2018)}, /* samsung */ | |
96 | {USB_DEVICE(0x5A57, 0x0280)}, /* Zinwell */ | |
97 | {USB_DEVICE(0x5A57, 0x0282)}, /* Zinwell */ | |
98 | {USB_DEVICE(0x7392, 0x7718)}, | |
99 | {USB_DEVICE(0x7392, 0x7717)}, | |
100 | {USB_DEVICE(0x1737, 0x0070)}, /* Linksys WUSB100 */ | |
101 | {USB_DEVICE(0x1737, 0x0071)}, /* Linksys WUSB600N */ | |
102 | {USB_DEVICE(0x0411, 0x00e8)}, /* Buffalo WLI-UC-G300N */ | |
103 | {USB_DEVICE(0x050d, 0x815c)}, /* Belkin F5D8053 */ | |
9f548a2a | 104 | #endif /* RT2870 // */ |
ca97b838 | 105 | #ifdef RT3070 |
66cd8d6e BZ |
106 | {USB_DEVICE(0x148F, 0x3070)}, /* Ralink 3070 */ |
107 | {USB_DEVICE(0x148F, 0x3071)}, /* Ralink 3071 */ | |
108 | {USB_DEVICE(0x148F, 0x3072)}, /* Ralink 3072 */ | |
109 | {USB_DEVICE(0x0DB0, 0x3820)}, /* Ralink 3070 */ | |
110 | {USB_DEVICE(0x0DF6, 0x003E)}, /* Sitecom 3070 */ | |
111 | {USB_DEVICE(0x0DF6, 0x0042)}, /* Sitecom 3072 */ | |
112 | {USB_DEVICE(0x14B2, 0x3C12)}, /* AL 3070 */ | |
113 | {USB_DEVICE(0x18C5, 0x0012)}, /* Corega 3070 */ | |
114 | {USB_DEVICE(0x083A, 0x7511)}, /* Arcadyan 3070 */ | |
115 | {USB_DEVICE(0x1740, 0x9703)}, /* EnGenius 3070 */ | |
116 | {USB_DEVICE(0x1740, 0x9705)}, /* EnGenius 3071 */ | |
117 | {USB_DEVICE(0x1740, 0x9706)}, /* EnGenius 3072 */ | |
118 | {USB_DEVICE(0x13D3, 0x3273)}, /* AzureWave 3070 */ | |
119 | {USB_DEVICE(0x1044, 0x800D)}, /* Gigabyte GN-WB32L 3070 */ | |
120 | {USB_DEVICE(0x2019, 0xAB25)}, /* Planex Communications, Inc. RT3070 */ | |
121 | {USB_DEVICE(0x07B8, 0x3070)}, /* AboCom 3070 */ | |
122 | {USB_DEVICE(0x07B8, 0x3071)}, /* AboCom 3071 */ | |
123 | {USB_DEVICE(0x07B8, 0x3072)}, /* Abocom 3072 */ | |
124 | {USB_DEVICE(0x7392, 0x7711)}, /* Edimax 3070 */ | |
125 | {USB_DEVICE(0x1A32, 0x0304)}, /* Quanta 3070 */ | |
126 | {USB_DEVICE(0x1EDA, 0x2310)}, /* AirTies 3070 */ | |
127 | {USB_DEVICE(0x07D1, 0x3C0A)}, /* D-Link 3072 */ | |
128 | {USB_DEVICE(0x07D1, 0x3C0D)}, /* D-Link 3070 */ | |
129 | {USB_DEVICE(0x07D1, 0x3C0E)}, /* D-Link 3070 */ | |
130 | {USB_DEVICE(0x07D1, 0x3C0F)}, /* D-Link 3070 */ | |
131 | {USB_DEVICE(0x1D4D, 0x000C)}, /* Pegatron Corporation 3070 */ | |
132 | {USB_DEVICE(0x1D4D, 0x000E)}, /* Pegatron Corporation 3070 */ | |
133 | {USB_DEVICE(0x5A57, 0x5257)}, /* Zinwell 3070 */ | |
134 | {USB_DEVICE(0x5A57, 0x0283)}, /* Zinwell 3072 */ | |
135 | {USB_DEVICE(0x04BB, 0x0945)}, /* I-O DATA 3072 */ | |
136 | {USB_DEVICE(0x203D, 0x1480)}, /* Encore 3070 */ | |
9f548a2a | 137 | #endif /* RT3070 // */ |
66cd8d6e BZ |
138 | {USB_DEVICE(0x0DF6, 0x003F)}, /* Sitecom WL-608 */ |
139 | {USB_DEVICE(0x1737, 0x0077)}, /* Linksys WUSB54GC-EU v3 */ | |
140 | {USB_DEVICE(0x2001, 0x3C09)}, /* D-Link */ | |
141 | {USB_DEVICE(0x2001, 0x3C0A)}, /* D-Link 3072 */ | |
142 | {USB_DEVICE(0x2019, 0xED14)}, /* Planex Communications, Inc. */ | |
143 | {} /* Terminating entry */ | |
ca97b838 BZ |
144 | }; |
145 | ||
51126deb | 146 | int const rtusb_usb_id_len = |
66cd8d6e | 147 | sizeof(rtusb_usb_id) / sizeof(struct usb_device_id); |
ca97b838 BZ |
148 | |
149 | MODULE_DEVICE_TABLE(usb, rtusb_usb_id); | |
150 | ||
66cd8d6e | 151 | static void rt2870_disconnect(IN struct usb_device *dev, IN PRTMP_ADAPTER pAd); |
ca97b838 | 152 | |
66cd8d6e BZ |
153 | static int __devinit rt2870_probe(IN struct usb_interface *intf, |
154 | IN struct usb_device *usb_dev, | |
155 | IN const struct usb_device_id *dev_id, | |
156 | IN RTMP_ADAPTER ** ppAd); | |
ca97b838 BZ |
157 | |
158 | #ifndef PF_NOFREEZE | |
159 | #define PF_NOFREEZE 0 | |
160 | #endif | |
161 | ||
ca97b838 BZ |
162 | extern int rt28xx_close(IN struct net_device *net_dev); |
163 | extern int rt28xx_open(struct net_device *net_dev); | |
164 | ||
66cd8d6e BZ |
165 | static BOOLEAN USBDevConfigInit(IN struct usb_device *dev, |
166 | IN struct usb_interface *intf, | |
167 | IN RTMP_ADAPTER * pAd); | |
ca97b838 BZ |
168 | |
169 | /* | |
170 | ======================================================================== | |
171 | Routine Description: | |
172 | Check the chipset vendor/product ID. | |
173 | ||
174 | Arguments: | |
175 | _dev_p Point to the PCI or USB device | |
176 | ||
177 | Return Value: | |
178 | TRUE Check ok | |
179 | FALSE Check fail | |
180 | ||
181 | Note: | |
182 | ======================================================================== | |
183 | */ | |
66cd8d6e | 184 | BOOLEAN RT28XXChipsetCheck(IN void *_dev_p) |
ca97b838 BZ |
185 | { |
186 | struct usb_interface *intf = (struct usb_interface *)_dev_p; | |
187 | struct usb_device *dev_p = interface_to_usbdev(intf); | |
51126deb | 188 | u32 i; |
ca97b838 | 189 | |
66cd8d6e | 190 | for (i = 0; i < rtusb_usb_id_len; i++) { |
ca97b838 | 191 | if (dev_p->descriptor.idVendor == rtusb_usb_id[i].idVendor && |
66cd8d6e | 192 | dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) { |
ca97b838 | 193 | printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n", |
66cd8d6e BZ |
194 | dev_p->descriptor.idVendor, |
195 | dev_p->descriptor.idProduct); | |
ca97b838 BZ |
196 | break; |
197 | } | |
198 | } | |
199 | ||
66cd8d6e | 200 | if (i == rtusb_usb_id_len) { |
ca97b838 BZ |
201 | printk("rt2870: Error! Device Descriptor not matching!\n"); |
202 | return FALSE; | |
203 | } | |
204 | ||
205 | return TRUE; | |
206 | } | |
207 | ||
208 | /**************************************************************************/ | |
209 | /**************************************************************************/ | |
9f548a2a | 210 | /*tested for kernel 2.6series */ |
ca97b838 BZ |
211 | /**************************************************************************/ |
212 | /**************************************************************************/ | |
213 | ||
214 | #ifdef CONFIG_PM | |
215 | static int rt2870_suspend(struct usb_interface *intf, pm_message_t state); | |
216 | static int rt2870_resume(struct usb_interface *intf); | |
9f548a2a | 217 | #endif /* CONFIG_PM // */ |
ca97b838 | 218 | |
66cd8d6e BZ |
219 | static int rtusb_probe(struct usb_interface *intf, |
220 | const struct usb_device_id *id); | |
ca97b838 BZ |
221 | static void rtusb_disconnect(struct usb_interface *intf); |
222 | ||
66cd8d6e BZ |
223 | static BOOLEAN USBDevConfigInit(IN struct usb_device *dev, |
224 | IN struct usb_interface *intf, | |
225 | IN RTMP_ADAPTER * pAd) | |
ca97b838 BZ |
226 | { |
227 | struct usb_host_interface *iface_desc; | |
51126deb BZ |
228 | unsigned long BulkOutIdx; |
229 | u32 i; | |
ca97b838 | 230 | |
ca97b838 BZ |
231 | /* get the active interface descriptor */ |
232 | iface_desc = intf->cur_altsetting; | |
233 | ||
234 | /* get # of enpoints */ | |
235 | pAd->NumberOfPipes = iface_desc->desc.bNumEndpoints; | |
66cd8d6e BZ |
236 | DBGPRINT(RT_DEBUG_TRACE, |
237 | ("NumEndpoints=%d\n", iface_desc->desc.bNumEndpoints)); | |
ca97b838 BZ |
238 | |
239 | /* Configure Pipes */ | |
240 | BulkOutIdx = 0; | |
241 | ||
66cd8d6e | 242 | for (i = 0; i < pAd->NumberOfPipes; i++) { |
ca97b838 | 243 | if ((iface_desc->endpoint[i].desc.bmAttributes == |
66cd8d6e BZ |
244 | USB_ENDPOINT_XFER_BULK) && |
245 | ((iface_desc->endpoint[i].desc.bEndpointAddress & | |
246 | USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)) { | |
247 | pAd->BulkInEpAddr = | |
248 | iface_desc->endpoint[i].desc.bEndpointAddress; | |
249 | pAd->BulkInMaxPacketSize = | |
250 | le2cpu16(iface_desc->endpoint[i].desc. | |
251 | wMaxPacketSize); | |
252 | ||
253 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
254 | ("BULK IN MaxPacketSize = %d\n", | |
255 | pAd->BulkInMaxPacketSize)); | |
256 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
257 | ("EP address = 0x%2x\n", | |
258 | iface_desc->endpoint[i].desc. | |
259 | bEndpointAddress)); | |
260 | } else | |
261 | if ((iface_desc->endpoint[i].desc.bmAttributes == | |
262 | USB_ENDPOINT_XFER_BULK) | |
263 | && | |
264 | ((iface_desc->endpoint[i].desc. | |
265 | bEndpointAddress & USB_ENDPOINT_DIR_MASK) == | |
266 | USB_DIR_OUT)) { | |
9f548a2a BZ |
267 | /* there are 6 bulk out EP. EP6 highest priority. */ |
268 | /* EP1-4 is EDCA. EP5 is HCCA. */ | |
66cd8d6e BZ |
269 | pAd->BulkOutEpAddr[BulkOutIdx++] = |
270 | iface_desc->endpoint[i].desc.bEndpointAddress; | |
271 | pAd->BulkOutMaxPacketSize = | |
272 | le2cpu16(iface_desc->endpoint[i].desc. | |
273 | wMaxPacketSize); | |
274 | ||
275 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
276 | ("BULK OUT MaxPacketSize = %d\n", | |
277 | pAd->BulkOutMaxPacketSize)); | |
278 | DBGPRINT_RAW(RT_DEBUG_TRACE, | |
279 | ("EP address = 0x%2x \n", | |
280 | iface_desc->endpoint[i].desc. | |
281 | bEndpointAddress)); | |
ca97b838 BZ |
282 | } |
283 | } | |
284 | ||
66cd8d6e BZ |
285 | if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0])) { |
286 | printk | |
287 | ("%s: Could not find both bulk-in and bulk-out endpoints\n", | |
288 | __FUNCTION__); | |
ca97b838 BZ |
289 | return FALSE; |
290 | } | |
291 | ||
292 | pAd->config = &dev->config->desc; | |
293 | usb_set_intfdata(intf, pAd); | |
294 | ||
295 | return TRUE; | |
296 | ||
297 | } | |
298 | ||
66cd8d6e BZ |
299 | static int rtusb_probe(struct usb_interface *intf, |
300 | const struct usb_device_id *id) | |
ca97b838 BZ |
301 | { |
302 | RTMP_ADAPTER *pAd; | |
303 | struct usb_device *dev; | |
304 | int rv; | |
305 | ||
306 | dev = interface_to_usbdev(intf); | |
307 | dev = usb_get_dev(dev); | |
308 | ||
309 | rv = rt2870_probe(intf, dev, id, &pAd); | |
310 | if (rv != 0) | |
311 | usb_put_dev(dev); | |
312 | ||
313 | return rv; | |
314 | } | |
315 | ||
ca97b838 BZ |
316 | static void rtusb_disconnect(struct usb_interface *intf) |
317 | { | |
66cd8d6e BZ |
318 | struct usb_device *dev = interface_to_usbdev(intf); |
319 | PRTMP_ADAPTER pAd; | |
ca97b838 BZ |
320 | |
321 | pAd = usb_get_intfdata(intf); | |
322 | usb_set_intfdata(intf, NULL); | |
323 | ||
324 | rt2870_disconnect(dev, pAd); | |
325 | } | |
326 | ||
ca97b838 | 327 | struct usb_driver rtusb_driver = { |
66cd8d6e BZ |
328 | .name = "rt2870", |
329 | .probe = rtusb_probe, | |
330 | .disconnect = rtusb_disconnect, | |
331 | .id_table = rtusb_usb_id, | |
ca97b838 BZ |
332 | |
333 | #ifdef CONFIG_PM | |
66cd8d6e BZ |
334 | suspend:rt2870_suspend, |
335 | resume:rt2870_resume, | |
ca97b838 | 336 | #endif |
66cd8d6e | 337 | }; |
ca97b838 BZ |
338 | |
339 | #ifdef CONFIG_PM | |
340 | ||
51126deb | 341 | void RT2870RejectPendingPackets(IN PRTMP_ADAPTER pAd) |
ca97b838 | 342 | { |
9f548a2a BZ |
343 | /* clear PS packets */ |
344 | /* clear TxSw packets */ | |
ca97b838 BZ |
345 | } |
346 | ||
66cd8d6e | 347 | static int rt2870_suspend(struct usb_interface *intf, pm_message_t state) |
ca97b838 BZ |
348 | { |
349 | struct net_device *net_dev; | |
350 | PRTMP_ADAPTER pAd = usb_get_intfdata(intf); | |
351 | ||
ca97b838 BZ |
352 | DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_suspend()\n")); |
353 | net_dev = pAd->net_dev; | |
354 | netif_device_detach(net_dev); | |
355 | ||
356 | pAd->PM_FlgSuspend = 1; | |
357 | if (netif_running(net_dev)) { | |
358 | RTUSBCancelPendingBulkInIRP(pAd); | |
359 | RTUSBCancelPendingBulkOutIRP(pAd); | |
360 | } | |
361 | DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_suspend()\n")); | |
362 | return 0; | |
363 | } | |
364 | ||
66cd8d6e | 365 | static int rt2870_resume(struct usb_interface *intf) |
ca97b838 BZ |
366 | { |
367 | struct net_device *net_dev; | |
368 | PRTMP_ADAPTER pAd = usb_get_intfdata(intf); | |
369 | ||
ca97b838 BZ |
370 | DBGPRINT(RT_DEBUG_TRACE, ("===> rt2870_resume()\n")); |
371 | ||
372 | pAd->PM_FlgSuspend = 0; | |
373 | net_dev = pAd->net_dev; | |
374 | netif_device_attach(net_dev); | |
375 | netif_start_queue(net_dev); | |
376 | netif_carrier_on(net_dev); | |
377 | netif_wake_queue(net_dev); | |
378 | ||
379 | DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2870_resume()\n")); | |
380 | return 0; | |
381 | } | |
9f548a2a | 382 | #endif /* CONFIG_PM // */ |
ca97b838 | 383 | |
9f548a2a | 384 | /* Init driver module */ |
51126deb | 385 | int __init rtusb_init(void) |
ca97b838 BZ |
386 | { |
387 | printk("rtusb init --->\n"); | |
388 | return usb_register(&rtusb_driver); | |
389 | } | |
390 | ||
9f548a2a | 391 | /* Deinit driver module */ |
51126deb | 392 | void __exit rtusb_exit(void) |
ca97b838 BZ |
393 | { |
394 | usb_deregister(&rtusb_driver); | |
395 | printk("<--- rtusb exit\n"); | |
396 | } | |
397 | ||
398 | module_init(rtusb_init); | |
399 | module_exit(rtusb_exit); | |
400 | ||
ca97b838 BZ |
401 | /*--------------------------------------------------------------------- */ |
402 | /* function declarations */ | |
403 | /*--------------------------------------------------------------------- */ | |
404 | ||
405 | /* | |
406 | ======================================================================== | |
407 | Routine Description: | |
408 | MLME kernel thread. | |
409 | ||
410 | Arguments: | |
411 | *Context the pAd, driver control block pointer | |
412 | ||
413 | Return Value: | |
414 | 0 close the thread | |
415 | ||
416 | Note: | |
417 | ======================================================================== | |
418 | */ | |
51126deb | 419 | int MlmeThread(IN void *Context) |
ca97b838 BZ |
420 | { |
421 | RTMP_ADAPTER *pAd; | |
422 | RTMP_OS_TASK *pTask; | |
423 | int status; | |
424 | status = 0; | |
425 | ||
66cd8d6e BZ |
426 | pTask = (RTMP_OS_TASK *) Context; |
427 | pAd = (PRTMP_ADAPTER) pTask->priv; | |
ca97b838 BZ |
428 | |
429 | RtmpOSTaskCustomize(pTask); | |
430 | ||
66cd8d6e | 431 | while (!pTask->task_killed) { |
ca97b838 BZ |
432 | #ifdef KTHREAD_SUPPORT |
433 | RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask); | |
434 | #else | |
435 | RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status); | |
436 | ||
437 | /* unlock the device pointers */ | |
66cd8d6e | 438 | if (status != 0) { |
ca97b838 BZ |
439 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); |
440 | break; | |
441 | } | |
442 | #endif | |
443 | ||
66cd8d6e | 444 | /* lock the device pointers , need to check if required */ |
9f548a2a | 445 | /*down(&(pAd->usbdev_semaphore)); */ |
ca97b838 BZ |
446 | |
447 | if (!pAd->PM_FlgSuspend) | |
448 | MlmeHandler(pAd); | |
449 | } | |
450 | ||
451 | /* notify the exit routine that we're actually exiting now | |
452 | * | |
453 | * complete()/wait_for_completion() is similar to up()/down(), | |
454 | * except that complete() is safe in the case where the structure | |
455 | * is getting deleted in a parallel mode of execution (i.e. just | |
456 | * after the down() -- that's necessary for the thread-shutdown | |
457 | * case. | |
458 | * | |
459 | * complete_and_exit() goes even further than this -- it is safe in | |
460 | * the case that the thread of the caller is going away (not just | |
461 | * the structure) -- this is necessary for the module-remove case. | |
462 | * This is important in preemption kernels, which transfer the flow | |
463 | * of execution immediately upon a complete(). | |
464 | */ | |
66cd8d6e | 465 | DBGPRINT(RT_DEBUG_TRACE, ("<---%s\n", __FUNCTION__)); |
ca97b838 BZ |
466 | #ifndef KTHREAD_SUPPORT |
467 | pTask->taskPID = THREAD_PID_INIT_VALUE; | |
66cd8d6e | 468 | complete_and_exit(&pTask->taskComplete, 0); |
ca97b838 BZ |
469 | #endif |
470 | return 0; | |
471 | ||
472 | } | |
473 | ||
ca97b838 BZ |
474 | /* |
475 | ======================================================================== | |
476 | Routine Description: | |
477 | USB command kernel thread. | |
478 | ||
479 | Arguments: | |
480 | *Context the pAd, driver control block pointer | |
481 | ||
482 | Return Value: | |
483 | 0 close the thread | |
484 | ||
485 | Note: | |
486 | ======================================================================== | |
487 | */ | |
51126deb | 488 | int RTUSBCmdThread(IN void *Context) |
ca97b838 BZ |
489 | { |
490 | RTMP_ADAPTER *pAd; | |
491 | RTMP_OS_TASK *pTask; | |
492 | int status; | |
493 | status = 0; | |
494 | ||
66cd8d6e BZ |
495 | pTask = (RTMP_OS_TASK *) Context; |
496 | pAd = (PRTMP_ADAPTER) pTask->priv; | |
ca97b838 BZ |
497 | |
498 | RtmpOSTaskCustomize(pTask); | |
499 | ||
500 | NdisAcquireSpinLock(&pAd->CmdQLock); | |
501 | pAd->CmdQ.CmdQState = RTMP_TASK_STAT_RUNNING; | |
502 | NdisReleaseSpinLock(&pAd->CmdQLock); | |
503 | ||
66cd8d6e | 504 | while (pAd && pAd->CmdQ.CmdQState == RTMP_TASK_STAT_RUNNING) { |
ca97b838 BZ |
505 | #ifdef KTHREAD_SUPPORT |
506 | RTMP_WAIT_EVENT_INTERRUPTIBLE(pAd, pTask); | |
507 | #else | |
508 | /* lock the device pointers */ | |
509 | RTMP_SEM_EVENT_WAIT(&(pTask->taskSema), status); | |
510 | ||
66cd8d6e | 511 | if (status != 0) { |
ca97b838 BZ |
512 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); |
513 | break; | |
514 | } | |
515 | #endif | |
516 | ||
517 | if (pAd->CmdQ.CmdQState == RTMP_TASK_STAT_STOPED) | |
518 | break; | |
519 | ||
520 | if (!pAd->PM_FlgSuspend) | |
521 | CMDHandler(pAd); | |
522 | } | |
523 | ||
9f548a2a | 524 | if (pAd && !pAd->PM_FlgSuspend) { /* Clear the CmdQElements. */ |
66cd8d6e | 525 | CmdQElmt *pCmdQElmt = NULL; |
ca97b838 BZ |
526 | |
527 | NdisAcquireSpinLock(&pAd->CmdQLock); | |
528 | pAd->CmdQ.CmdQState = RTMP_TASK_STAT_STOPED; | |
66cd8d6e | 529 | while (pAd->CmdQ.size) { |
ca97b838 | 530 | RTUSBDequeueCmd(&pAd->CmdQ, &pCmdQElmt); |
66cd8d6e BZ |
531 | if (pCmdQElmt) { |
532 | if (pCmdQElmt->CmdFromNdis == TRUE) { | |
ca97b838 | 533 | if (pCmdQElmt->buffer != NULL) |
66cd8d6e BZ |
534 | os_free_mem(pAd, |
535 | pCmdQElmt->buffer); | |
51126deb | 536 | os_free_mem(pAd, (u8 *)pCmdQElmt); |
66cd8d6e BZ |
537 | } else { |
538 | if ((pCmdQElmt->buffer != NULL) | |
539 | && (pCmdQElmt->bufferlength != 0)) | |
540 | os_free_mem(pAd, | |
541 | pCmdQElmt->buffer); | |
51126deb | 542 | os_free_mem(pAd, (u8 *)pCmdQElmt); |
ca97b838 BZ |
543 | } |
544 | } | |
545 | } | |
546 | ||
547 | NdisReleaseSpinLock(&pAd->CmdQLock); | |
548 | } | |
549 | /* notify the exit routine that we're actually exiting now | |
550 | * | |
551 | * complete()/wait_for_completion() is similar to up()/down(), | |
552 | * except that complete() is safe in the case where the structure | |
553 | * is getting deleted in a parallel mode of execution (i.e. just | |
554 | * after the down() -- that's necessary for the thread-shutdown | |
555 | * case. | |
556 | * | |
557 | * complete_and_exit() goes even further than this -- it is safe in | |
558 | * the case that the thread of the caller is going away (not just | |
559 | * the structure) -- this is necessary for the module-remove case. | |
560 | * This is important in preemption kernels, which transfer the flow | |
561 | * of execution immediately upon a complete(). | |
562 | */ | |
66cd8d6e | 563 | DBGPRINT(RT_DEBUG_TRACE, ("<---RTUSBCmdThread\n")); |
ca97b838 BZ |
564 | |
565 | #ifndef KTHREAD_SUPPORT | |
566 | pTask->taskPID = THREAD_PID_INIT_VALUE; | |
66cd8d6e | 567 | complete_and_exit(&pTask->taskComplete, 0); |
ca97b838 BZ |
568 | #endif |
569 | return 0; | |
570 | ||
571 | } | |
572 | ||
51126deb | 573 | void RTUSBWatchDog(IN RTMP_ADAPTER * pAd) |
ca97b838 | 574 | { |
66cd8d6e BZ |
575 | PHT_TX_CONTEXT pHTTXContext; |
576 | int idx; | |
51126deb | 577 | unsigned long irqFlags; |
66cd8d6e BZ |
578 | PURB pUrb; |
579 | BOOLEAN needDumpSeq = FALSE; | |
51126deb BZ |
580 | u32 MACValue; |
581 | u32 TxRxQ_Pcnt; | |
ca97b838 BZ |
582 | |
583 | idx = 0; | |
584 | RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue); | |
66cd8d6e BZ |
585 | if ((MACValue & 0xff) != 0) { |
586 | DBGPRINT(RT_DEBUG_TRACE, | |
587 | ("TX QUEUE 0 Not EMPTY(Value=0x%0x). !!!!!!!!!!!!!!!\n", | |
588 | MACValue)); | |
ca97b838 | 589 | RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40012); |
66cd8d6e BZ |
590 | while ((MACValue & 0xff) != 0 && (idx++ < 10)) { |
591 | RTMP_IO_READ32(pAd, TXRXQ_PCNT, &MACValue); | |
592 | RTMPusecDelay(1); | |
ca97b838 BZ |
593 | } |
594 | RTMP_IO_WRITE32(pAd, PBF_CFG, 0xf40006); | |
595 | } | |
596 | ||
66cd8d6e BZ |
597 | if (pAd->watchDogRxOverFlowCnt >= 2) { |
598 | DBGPRINT(RT_DEBUG_TRACE, | |
599 | ("Maybe the Rx Bulk-In hanged! Cancel the pending Rx bulks request!\n")); | |
600 | if ((!RTMP_TEST_FLAG | |
601 | (pAd, | |
602 | (fRTMP_ADAPTER_RESET_IN_PROGRESS | | |
603 | fRTMP_ADAPTER_BULKIN_RESET | | |
604 | fRTMP_ADAPTER_HALT_IN_PROGRESS | | |
605 | fRTMP_ADAPTER_NIC_NOT_EXIST)))) { | |
606 | DBGPRINT(RT_DEBUG_TRACE, | |
607 | ("Call CMDTHREAD_RESET_BULK_IN to cancel the pending Rx Bulk!\n")); | |
ca97b838 | 608 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_BULKIN_RESET); |
66cd8d6e BZ |
609 | RTUSBEnqueueInternalCmd(pAd, CMDTHREAD_RESET_BULK_IN, |
610 | NULL, 0); | |
ca97b838 BZ |
611 | needDumpSeq = TRUE; |
612 | } | |
613 | pAd->watchDogRxOverFlowCnt = 0; | |
614 | } | |
615 | ||
616 | RTUSBReadMACRegister(pAd, 0x438, &TxRxQ_Pcnt); | |
617 | ||
66cd8d6e | 618 | for (idx = 0; idx < NUM_OF_TX_RING; idx++) { |
ca97b838 BZ |
619 | pUrb = NULL; |
620 | ||
621 | RTMP_IRQ_LOCK(&pAd->BulkOutLock[idx], irqFlags); | |
66cd8d6e BZ |
622 | if ((pAd->BulkOutPending[idx] == TRUE) |
623 | && pAd->watchDogTxPendingCnt) { | |
51126deb | 624 | int actual_length = 0, transfer_buffer_length = 0; |
66cd8d6e | 625 | BOOLEAN isDataPacket = FALSE; |
ca97b838 BZ |
626 | pAd->watchDogTxPendingCnt[idx]++; |
627 | ||
628 | if ((pAd->watchDogTxPendingCnt[idx] > 2) && | |
66cd8d6e BZ |
629 | (!RTMP_TEST_FLAG |
630 | (pAd, | |
631 | (fRTMP_ADAPTER_RESET_IN_PROGRESS | | |
632 | fRTMP_ADAPTER_HALT_IN_PROGRESS | | |
633 | fRTMP_ADAPTER_NIC_NOT_EXIST | | |
634 | fRTMP_ADAPTER_BULKOUT_RESET))) | |
635 | ) { | |
9f548a2a | 636 | /* FIXME: Following code just support single bulk out. If you wanna support multiple bulk out. Modify it! */ |
66cd8d6e BZ |
637 | pHTTXContext = |
638 | (PHT_TX_CONTEXT) (&pAd->TxContext[idx]); | |
9f548a2a | 639 | if (pHTTXContext->IRPPending) { /* Check TxContext. */ |
ca97b838 BZ |
640 | pUrb = pHTTXContext->pUrb; |
641 | ||
66cd8d6e BZ |
642 | actual_length = pUrb->actual_length; |
643 | transfer_buffer_length = | |
644 | pUrb->transfer_buffer_length; | |
645 | isDataPacket = TRUE; | |
646 | } else if (idx == MGMTPIPEIDX) { | |
647 | PTX_CONTEXT pMLMEContext, pNULLContext, | |
648 | pPsPollContext; | |
ca97b838 | 649 | |
9f548a2a | 650 | /*Check MgmtContext. */ |
66cd8d6e BZ |
651 | pMLMEContext = |
652 | (PTX_CONTEXT) (pAd->MgmtRing. | |
653 | Cell[pAd->MgmtRing. | |
654 | TxDmaIdx]. | |
655 | AllocVa); | |
656 | pPsPollContext = | |
657 | (PTX_CONTEXT) (&pAd->PsPollContext); | |
658 | pNULLContext = | |
659 | (PTX_CONTEXT) (&pAd->NullContext); | |
660 | ||
661 | if (pMLMEContext->IRPPending) { | |
662 | ASSERT(pMLMEContext-> | |
663 | IRPPending); | |
ca97b838 | 664 | pUrb = pMLMEContext->pUrb; |
66cd8d6e BZ |
665 | } else if (pNULLContext->IRPPending) { |
666 | ASSERT(pNULLContext-> | |
667 | IRPPending); | |
ca97b838 | 668 | pUrb = pNULLContext->pUrb; |
66cd8d6e BZ |
669 | } else if (pPsPollContext->IRPPending) { |
670 | ASSERT(pPsPollContext-> | |
671 | IRPPending); | |
ca97b838 BZ |
672 | pUrb = pPsPollContext->pUrb; |
673 | } | |
674 | } | |
675 | ||
66cd8d6e BZ |
676 | RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], |
677 | irqFlags); | |
ca97b838 | 678 | |
ca58fb30 BZ |
679 | printk(KERN_INFO "%d:%lu LTL=%d , TL=%d L:%d\n", |
680 | idx, pAd->watchDogTxPendingCnt[idx], | |
681 | pAd->TransferedLength[idx], | |
682 | actual_length, transfer_buffer_length); | |
ca97b838 | 683 | |
66cd8d6e | 684 | if (pUrb) { |
ca97b838 | 685 | if ((isDataPacket |
66cd8d6e BZ |
686 | && pAd->TransferedLength[idx] == |
687 | actual_length | |
688 | && pAd->TransferedLength[idx] < | |
689 | transfer_buffer_length | |
690 | && actual_length != 0 | |
9f548a2a | 691 | /* && TxRxQ_Pcnt==0 */ |
66cd8d6e BZ |
692 | && pAd->watchDogTxPendingCnt[idx] > |
693 | 3) | |
694 | || isDataPacket == FALSE | |
695 | || pAd->watchDogTxPendingCnt[idx] > | |
696 | 6) { | |
697 | DBGPRINT(RT_DEBUG_TRACE, | |
698 | ("Maybe the Tx Bulk-Out hanged! Cancel the pending Tx bulks request of idx(%d)!\n", | |
699 | idx)); | |
700 | DBGPRINT(RT_DEBUG_TRACE, | |
701 | ("Unlink the pending URB!\n")); | |
9f548a2a | 702 | /* unlink it now */ |
66cd8d6e | 703 | RTUSB_UNLINK_URB(pUrb); |
9f548a2a BZ |
704 | /* Sleep 200 microseconds to give cancellation time to work */ |
705 | /*RTMPusecDelay(200); */ | |
66cd8d6e | 706 | needDumpSeq = TRUE; |
ca97b838 | 707 | } |
66cd8d6e BZ |
708 | } else { |
709 | DBGPRINT(RT_DEBUG_ERROR, | |
710 | ("Unkonw bulkOut URB maybe hanged!!!!!!!!!!!!\n")); | |
ca97b838 | 711 | } |
66cd8d6e BZ |
712 | } else { |
713 | RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], | |
714 | irqFlags); | |
ca97b838 BZ |
715 | } |
716 | ||
66cd8d6e BZ |
717 | if (isDataPacket == TRUE) |
718 | pAd->TransferedLength[idx] = actual_length; | |
719 | } else { | |
ca97b838 BZ |
720 | RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[idx], irqFlags); |
721 | } | |
722 | } | |
723 | ||
9f548a2a | 724 | /* For Sigma debug, dump the ba_reordering sequence. */ |
66cd8d6e | 725 | if ((needDumpSeq == TRUE) && (pAd->CommonCfg.bDisableReordering == 0)) { |
51126deb | 726 | u16 Idx; |
66cd8d6e | 727 | PBA_REC_ENTRY pBAEntry = NULL; |
51126deb | 728 | u8 count = 0; |
ca97b838 BZ |
729 | struct reordering_mpdu *mpdu_blk; |
730 | ||
731 | Idx = pAd->MacTab.Content[BSSID_WCID].BARecWcidArray[0]; | |
732 | ||
733 | pBAEntry = &pAd->BATable.BARecEntry[Idx]; | |
66cd8d6e BZ |
734 | if ((pBAEntry->list.qlen > 0) && (pBAEntry->list.next != NULL)) { |
735 | DBGPRINT(RT_DEBUG_TRACE, | |
736 | ("NICUpdateRawCounters():The Queueing pkt in reordering buffer:\n")); | |
ca97b838 BZ |
737 | NdisAcquireSpinLock(&pBAEntry->RxReRingLock); |
738 | mpdu_blk = pBAEntry->list.next; | |
66cd8d6e BZ |
739 | while (mpdu_blk) { |
740 | DBGPRINT(RT_DEBUG_TRACE, | |
741 | ("\t%d:Seq-%d, bAMSDU-%d!\n", count, | |
742 | mpdu_blk->Sequence, | |
743 | mpdu_blk->bAMSDU)); | |
ca97b838 BZ |
744 | mpdu_blk = mpdu_blk->next; |
745 | count++; | |
746 | } | |
747 | ||
66cd8d6e BZ |
748 | DBGPRINT(RT_DEBUG_TRACE, |
749 | ("\npBAEntry->LastIndSeq=%d!\n", | |
750 | pBAEntry->LastIndSeq)); | |
ca97b838 BZ |
751 | NdisReleaseSpinLock(&pBAEntry->RxReRingLock); |
752 | } | |
753 | } | |
754 | } | |
755 | ||
756 | /* | |
757 | ======================================================================== | |
758 | Routine Description: | |
759 | Release allocated resources. | |
760 | ||
761 | Arguments: | |
762 | *dev Point to the PCI or USB device | |
763 | pAd driver control block pointer | |
764 | ||
765 | Return Value: | |
766 | None | |
767 | ||
768 | Note: | |
769 | ======================================================================== | |
770 | */ | |
771 | static void rt2870_disconnect(struct usb_device *dev, PRTMP_ADAPTER pAd) | |
772 | { | |
66cd8d6e BZ |
773 | DBGPRINT(RT_DEBUG_ERROR, |
774 | ("rtusb_disconnect: unregister usbnet usb-%s-%s\n", | |
775 | dev->bus->bus_name, dev->devpath)); | |
776 | if (!pAd) { | |
ca97b838 BZ |
777 | usb_put_dev(dev); |
778 | printk("rtusb_disconnect: pAd == NULL!\n"); | |
779 | return; | |
780 | } | |
781 | RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST); | |
782 | ||
9f548a2a | 783 | /* for debug, wait to show some messages to /proc system */ |
ca97b838 BZ |
784 | udelay(1); |
785 | ||
ca97b838 BZ |
786 | RtmpPhyNetDevExit(pAd, pAd->net_dev); |
787 | ||
9f548a2a | 788 | /* FIXME: Shall we need following delay and flush the schedule?? */ |
ca97b838 BZ |
789 | udelay(1); |
790 | flush_scheduled_work(); | |
791 | udelay(1); | |
792 | ||
9f548a2a | 793 | /* free the root net_device */ |
ca97b838 BZ |
794 | RtmpOSNetDevFree(pAd->net_dev); |
795 | ||
796 | RtmpRaDevCtrlExit(pAd); | |
797 | ||
9f548a2a | 798 | /* release a use of the usb device structure */ |
ca97b838 BZ |
799 | usb_put_dev(dev); |
800 | udelay(1); | |
801 | ||
802 | DBGPRINT(RT_DEBUG_ERROR, (" RTUSB disconnect successfully\n")); | |
803 | } | |
804 | ||
66cd8d6e BZ |
805 | static int __devinit rt2870_probe(IN struct usb_interface *intf, |
806 | IN struct usb_device *usb_dev, | |
807 | IN const struct usb_device_id *dev_id, | |
808 | IN RTMP_ADAPTER ** ppAd) | |
ca97b838 | 809 | { |
66cd8d6e BZ |
810 | struct net_device *net_dev = NULL; |
811 | RTMP_ADAPTER *pAd = (RTMP_ADAPTER *) NULL; | |
51126deb BZ |
812 | int status, rv; |
813 | void *handle; | |
66cd8d6e | 814 | RTMP_OS_NETDEV_OP_HOOK netDevHook; |
ca97b838 BZ |
815 | |
816 | DBGPRINT(RT_DEBUG_TRACE, ("===>rt2870_probe()!\n")); | |
817 | ||
9f548a2a BZ |
818 | /* Check chipset vendor/product ID */ |
819 | /*if (RT28XXChipsetCheck(_dev_p) == FALSE) */ | |
820 | /* goto err_out; */ | |
ca97b838 | 821 | |
9f548a2a BZ |
822 | /*RtmpDevInit============================================= */ |
823 | /* Allocate RTMP_ADAPTER adapter structure */ | |
ca97b838 | 824 | handle = kmalloc(sizeof(struct os_cookie), GFP_KERNEL); |
66cd8d6e BZ |
825 | if (handle == NULL) { |
826 | printk | |
827 | ("rt2870_probe(): Allocate memory for os handle failed!\n"); | |
ca97b838 BZ |
828 | return -ENOMEM; |
829 | } | |
66cd8d6e | 830 | ((POS_COOKIE) handle)->pUsb_Dev = usb_dev; |
ca97b838 BZ |
831 | |
832 | rv = RTMPAllocAdapterBlock(handle, &pAd); | |
66cd8d6e | 833 | if (rv != NDIS_STATUS_SUCCESS) { |
ca97b838 BZ |
834 | kfree(handle); |
835 | goto err_out; | |
836 | } | |
9f548a2a | 837 | /*USBDevInit============================================== */ |
ca97b838 BZ |
838 | if (USBDevConfigInit(usb_dev, intf, pAd) == FALSE) |
839 | goto err_out_free_radev; | |
840 | ||
841 | RtmpRaDevCtrlInit(pAd, RTMP_DEV_INF_USB); | |
842 | ||
9f548a2a | 843 | /*NetDevInit============================================== */ |
ca97b838 BZ |
844 | net_dev = RtmpPhyNetDevInit(pAd, &netDevHook); |
845 | if (net_dev == NULL) | |
846 | goto err_out_free_radev; | |
847 | ||
9f548a2a | 848 | /* Here are the net_device structure with usb specific parameters. */ |
ca97b838 | 849 | /* for supporting Network Manager. |
66cd8d6e BZ |
850 | * Set the sysfs physical device reference for the network logical device if set prior to registration will |
851 | * cause a symlink during initialization. | |
ca97b838 BZ |
852 | */ |
853 | SET_NETDEV_DEV(net_dev, &(usb_dev->dev)); | |
854 | ||
66cd8d6e | 855 | pAd->StaCfg.OriDevType = net_dev->type; |
ca97b838 | 856 | |
9f548a2a BZ |
857 | /*All done, it's time to register the net device to linux kernel. */ |
858 | /* Register this device */ | |
ca97b838 BZ |
859 | status = RtmpOSNetDevAttach(net_dev, &netDevHook); |
860 | if (status != 0) | |
861 | goto err_out_free_netdev; | |
862 | ||
863 | #ifdef KTHREAD_SUPPORT | |
864 | init_waitqueue_head(&pAd->mlmeTask.kthread_q); | |
865 | init_waitqueue_head(&pAd->timerTask.kthread_q); | |
866 | init_waitqueue_head(&pAd->cmdQTask.kthread_q); | |
867 | #endif | |
868 | ||
869 | *ppAd = pAd; | |
870 | ||
871 | DBGPRINT(RT_DEBUG_TRACE, ("<===rt2870_probe()!\n")); | |
872 | ||
873 | return 0; | |
874 | ||
875 | /* --------------------------- ERROR HANDLE --------------------------- */ | |
876 | err_out_free_netdev: | |
877 | RtmpOSNetDevFree(net_dev); | |
878 | ||
879 | err_out_free_radev: | |
880 | RTMPFreeAdapter(pAd); | |
881 | ||
882 | err_out: | |
883 | *ppAd = NULL; | |
884 | ||
885 | return -1; | |
886 | ||
887 | } |