orinoco_usb.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768
  1. /*
  2. * USB Orinoco driver
  3. *
  4. * Copyright (c) 2003 Manuel Estrada Sainz
  5. *
  6. * The contents of this file are subject to the Mozilla Public License
  7. * Version 1.1 (the "License"); you may not use this file except in
  8. * compliance with the License. You may obtain a copy of the License
  9. * at http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS"
  12. * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  13. * the License for the specific language governing rights and
  14. * limitations under the License.
  15. *
  16. * Alternatively, the contents of this file may be used under the
  17. * terms of the GNU General Public License version 2 (the "GPL"), in
  18. * which case the provisions of the GPL are applicable instead of the
  19. * above. If you wish to allow the use of your version of this file
  20. * only under the terms of the GPL and not to allow others to use your
  21. * version of this file under the MPL, indicate your decision by
  22. * deleting the provisions above and replace them with the notice and
  23. * other provisions required by the GPL. If you do not delete the
  24. * provisions above, a recipient may use your version of this file
  25. * under either the MPL or the GPL.
  26. *
  27. * Queueing code based on linux-wlan-ng 0.2.1-pre5
  28. *
  29. * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
  30. *
  31. * The license is the same as above.
  32. *
  33. * Initialy based on USB Skeleton driver - 0.7
  34. *
  35. * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
  36. *
  37. * This program is free software; you can redistribute it and/or
  38. * modify it under the terms of the GNU General Public License as
  39. * published by the Free Software Foundation; either version 2 of
  40. * the License, or (at your option) any later version.
  41. *
  42. * NOTE: The original USB Skeleton driver is GPL, but all that code is
  43. * gone so MPL/GPL applies.
  44. */
  45. #define DRIVER_NAME "orinoco_usb"
  46. #define PFX DRIVER_NAME ": "
  47. #include <linux/module.h>
  48. #include <linux/kernel.h>
  49. #include <linux/sched.h>
  50. #include <linux/signal.h>
  51. #include <linux/errno.h>
  52. #include <linux/poll.h>
  53. #include <linux/slab.h>
  54. #include <linux/fcntl.h>
  55. #include <linux/spinlock.h>
  56. #include <linux/list.h>
  57. #include <linux/usb.h>
  58. #include <linux/timer.h>
  59. #include <linux/netdevice.h>
  60. #include <linux/if_arp.h>
  61. #include <linux/etherdevice.h>
  62. #include <linux/wireless.h>
  63. #include <linux/firmware.h>
  64. #include "mic.h"
  65. #include "orinoco.h"
  66. #ifndef URB_ASYNC_UNLINK
  67. #define URB_ASYNC_UNLINK 0
  68. #endif
  69. /* 802.2 LLC/SNAP header used for Ethernet encapsulation over 802.11 */
  70. static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
  71. #define ENCAPS_OVERHEAD (sizeof(encaps_hdr) + 2)
  72. struct header_struct {
  73. /* 802.3 */
  74. u8 dest[ETH_ALEN];
  75. u8 src[ETH_ALEN];
  76. __be16 len;
  77. /* 802.2 */
  78. u8 dsap;
  79. u8 ssap;
  80. u8 ctrl;
  81. /* SNAP */
  82. u8 oui[3];
  83. __be16 ethertype;
  84. } __packed;
  85. struct ez_usb_fw {
  86. u16 size;
  87. const u8 *code;
  88. };
  89. static struct ez_usb_fw firmware = {
  90. .size = 0,
  91. .code = NULL,
  92. };
  93. #ifdef CONFIG_USB_DEBUG
  94. static int debug = 1;
  95. #else
  96. static int debug;
  97. #endif
  98. /* Debugging macros */
  99. #undef dbg
  100. #define dbg(format, arg...) \
  101. do { if (debug) printk(KERN_DEBUG PFX "%s: " format "\n", \
  102. __func__ , ## arg); } while (0)
  103. #undef err
  104. #define err(format, arg...) \
  105. do { printk(KERN_ERR PFX format "\n", ## arg); } while (0)
  106. /* Module paramaters */
  107. module_param(debug, int, 0644);
  108. MODULE_PARM_DESC(debug, "Debug enabled or not");
  109. MODULE_FIRMWARE("orinoco_ezusb_fw");
  110. /*
  111. * Under some conditions, the card gets stuck and stops paying attention
  112. * to the world (i.e. data communication stalls) until we do something to
  113. * it. Sending an INQ_TALLIES command seems to be enough and should be
  114. * harmless otherwise. This behaviour has been observed when using the
  115. * driver on a systemimager client during installation. In the past a
  116. * timer was used to send INQ_TALLIES commands when there was no other
  117. * activity, but it was troublesome and was removed.
  118. */
  119. #define USB_COMPAQ_VENDOR_ID 0x049f /* Compaq Computer Corp. */
  120. #define USB_COMPAQ_WL215_ID 0x001f /* Compaq WL215 USB Adapter */
  121. #define USB_COMPAQ_W200_ID 0x0076 /* Compaq W200 USB Adapter */
  122. #define USB_HP_WL215_ID 0x0082 /* Compaq WL215 USB Adapter */
  123. #define USB_MELCO_VENDOR_ID 0x0411
  124. #define USB_BUFFALO_L11_ID 0x0006 /* BUFFALO WLI-USB-L11 */
  125. #define USB_BUFFALO_L11G_WR_ID 0x000B /* BUFFALO WLI-USB-L11G-WR */
  126. #define USB_BUFFALO_L11G_ID 0x000D /* BUFFALO WLI-USB-L11G */
  127. #define USB_LUCENT_VENDOR_ID 0x047E /* Lucent Technologies */
  128. #define USB_LUCENT_ORINOCO_ID 0x0300 /* Lucent/Agere Orinoco USB Client */
  129. #define USB_AVAYA8_VENDOR_ID 0x0D98
  130. #define USB_AVAYAE_VENDOR_ID 0x0D9E
  131. #define USB_AVAYA_WIRELESS_ID 0x0300 /* Avaya Wireless USB Card */
  132. #define USB_AGERE_VENDOR_ID 0x0D4E /* Agere Systems */
  133. #define USB_AGERE_MODEL0801_ID 0x1000 /* Wireless USB Card Model 0801 */
  134. #define USB_AGERE_MODEL0802_ID 0x1001 /* Wireless USB Card Model 0802 */
  135. #define USB_AGERE_REBRANDED_ID 0x047A /* WLAN USB Card */
  136. #define USB_ELSA_VENDOR_ID 0x05CC
  137. #define USB_ELSA_AIRLANCER_ID 0x3100 /* ELSA AirLancer USB-11 */
  138. #define USB_LEGEND_VENDOR_ID 0x0E7C
  139. #define USB_LEGEND_JOYNET_ID 0x0300 /* Joynet WLAN USB Card */
  140. #define USB_SAMSUNG_VENDOR_ID 0x04E8
  141. #define USB_SAMSUNG_SEW2001U1_ID 0x5002 /* Samsung SEW-2001u Card */
  142. #define USB_SAMSUNG_SEW2001U2_ID 0x5B11 /* Samsung SEW-2001u Card */
  143. #define USB_SAMSUNG_SEW2003U_ID 0x7011 /* Samsung SEW-2003U Card */
  144. #define USB_IGATE_VENDOR_ID 0x0681
  145. #define USB_IGATE_IGATE_11M_ID 0x0012 /* I-GATE 11M USB Card */
  146. #define USB_FUJITSU_VENDOR_ID 0x0BF8
  147. #define USB_FUJITSU_E1100_ID 0x1002 /* connect2AIR WLAN E-1100 USB */
  148. #define USB_2WIRE_VENDOR_ID 0x1630
  149. #define USB_2WIRE_WIRELESS_ID 0xff81 /* 2Wire Wireless USB adapter */
  150. #define EZUSB_REQUEST_FW_TRANS 0xA0
  151. #define EZUSB_REQUEST_TRIGER 0xAA
  152. #define EZUSB_REQUEST_TRIG_AC 0xAC
  153. #define EZUSB_CPUCS_REG 0x7F92
  154. #define EZUSB_RID_TX 0x0700
  155. #define EZUSB_RID_RX 0x0701
  156. #define EZUSB_RID_INIT1 0x0702
  157. #define EZUSB_RID_ACK 0x0710
  158. #define EZUSB_RID_READ_PDA 0x0800
  159. #define EZUSB_RID_PROG_INIT 0x0852
  160. #define EZUSB_RID_PROG_SET_ADDR 0x0853
  161. #define EZUSB_RID_PROG_BYTES 0x0854
  162. #define EZUSB_RID_PROG_END 0x0855
  163. #define EZUSB_RID_DOCMD 0x0860
  164. /* Recognize info frames */
  165. #define EZUSB_IS_INFO(id) ((id >= 0xF000) && (id <= 0xF2FF))
  166. #define EZUSB_MAGIC 0x0210
  167. #define EZUSB_FRAME_DATA 1
  168. #define EZUSB_FRAME_CONTROL 2
  169. #define DEF_TIMEOUT (3 * HZ)
  170. #define BULK_BUF_SIZE 2048
  171. #define MAX_DL_SIZE (BULK_BUF_SIZE - sizeof(struct ezusb_packet))
  172. #define FW_BUF_SIZE 64
  173. #define FW_VAR_OFFSET_PTR 0x359
  174. #define FW_VAR_VALUE 0
  175. #define FW_HOLE_START 0x100
  176. #define FW_HOLE_END 0x300
  177. struct ezusb_packet {
  178. __le16 magic; /* 0x0210 */
  179. u8 req_reply_count;
  180. u8 ans_reply_count;
  181. __le16 frame_type; /* 0x01 for data frames, 0x02 otherwise */
  182. __le16 size; /* transport size */
  183. __le16 crc; /* CRC up to here */
  184. __le16 hermes_len;
  185. __le16 hermes_rid;
  186. u8 data[0];
  187. } __packed;
  188. /* Table of devices that work or may work with this driver */
  189. static struct usb_device_id ezusb_table[] = {
  190. {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_WL215_ID)},
  191. {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_HP_WL215_ID)},
  192. {USB_DEVICE(USB_COMPAQ_VENDOR_ID, USB_COMPAQ_W200_ID)},
  193. {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11_ID)},
  194. {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_WR_ID)},
  195. {USB_DEVICE(USB_MELCO_VENDOR_ID, USB_BUFFALO_L11G_ID)},
  196. {USB_DEVICE(USB_LUCENT_VENDOR_ID, USB_LUCENT_ORINOCO_ID)},
  197. {USB_DEVICE(USB_AVAYA8_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
  198. {USB_DEVICE(USB_AVAYAE_VENDOR_ID, USB_AVAYA_WIRELESS_ID)},
  199. {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0801_ID)},
  200. {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_MODEL0802_ID)},
  201. {USB_DEVICE(USB_ELSA_VENDOR_ID, USB_ELSA_AIRLANCER_ID)},
  202. {USB_DEVICE(USB_LEGEND_VENDOR_ID, USB_LEGEND_JOYNET_ID)},
  203. {USB_DEVICE_VER(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U1_ID,
  204. 0, 0)},
  205. {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2001U2_ID)},
  206. {USB_DEVICE(USB_SAMSUNG_VENDOR_ID, USB_SAMSUNG_SEW2003U_ID)},
  207. {USB_DEVICE(USB_IGATE_VENDOR_ID, USB_IGATE_IGATE_11M_ID)},
  208. {USB_DEVICE(USB_FUJITSU_VENDOR_ID, USB_FUJITSU_E1100_ID)},
  209. {USB_DEVICE(USB_2WIRE_VENDOR_ID, USB_2WIRE_WIRELESS_ID)},
  210. {USB_DEVICE(USB_AGERE_VENDOR_ID, USB_AGERE_REBRANDED_ID)},
  211. {} /* Terminating entry */
  212. };
  213. MODULE_DEVICE_TABLE(usb, ezusb_table);
  214. /* Structure to hold all of our device specific stuff */
  215. struct ezusb_priv {
  216. struct usb_device *udev;
  217. struct net_device *dev;
  218. struct mutex mtx;
  219. spinlock_t req_lock;
  220. struct list_head req_pending;
  221. struct list_head req_active;
  222. spinlock_t reply_count_lock;
  223. u16 hermes_reg_fake[0x40];
  224. u8 *bap_buf;
  225. struct urb *read_urb;
  226. int read_pipe;
  227. int write_pipe;
  228. u8 reply_count;
  229. };
  230. enum ezusb_state {
  231. EZUSB_CTX_START,
  232. EZUSB_CTX_QUEUED,
  233. EZUSB_CTX_REQ_SUBMITTED,
  234. EZUSB_CTX_REQ_COMPLETE,
  235. EZUSB_CTX_RESP_RECEIVED,
  236. EZUSB_CTX_REQ_TIMEOUT,
  237. EZUSB_CTX_REQ_FAILED,
  238. EZUSB_CTX_RESP_TIMEOUT,
  239. EZUSB_CTX_REQSUBMIT_FAIL,
  240. EZUSB_CTX_COMPLETE,
  241. };
  242. struct request_context {
  243. struct list_head list;
  244. atomic_t refcount;
  245. struct completion done; /* Signals that CTX is dead */
  246. int killed;
  247. struct urb *outurb; /* OUT for req pkt */
  248. struct ezusb_priv *upriv;
  249. struct ezusb_packet *buf;
  250. int buf_length;
  251. struct timer_list timer; /* Timeout handling */
  252. enum ezusb_state state; /* Current state */
  253. /* the RID that we will wait for */
  254. u16 out_rid;
  255. u16 in_rid;
  256. };
  257. /* Forward declarations */
  258. static void ezusb_ctx_complete(struct request_context *ctx);
  259. static void ezusb_req_queue_run(struct ezusb_priv *upriv);
  260. static void ezusb_bulk_in_callback(struct urb *urb);
  261. static inline u8 ezusb_reply_inc(u8 count)
  262. {
  263. if (count < 0x7F)
  264. return count + 1;
  265. else
  266. return 1;
  267. }
  268. static void ezusb_request_context_put(struct request_context *ctx)
  269. {
  270. if (!atomic_dec_and_test(&ctx->refcount))
  271. return;
  272. WARN_ON(!ctx->done.done);
  273. BUG_ON(ctx->outurb->status == -EINPROGRESS);
  274. BUG_ON(timer_pending(&ctx->timer));
  275. usb_free_urb(ctx->outurb);
  276. kfree(ctx->buf);
  277. kfree(ctx);
  278. }
  279. static inline void ezusb_mod_timer(struct ezusb_priv *upriv,
  280. struct timer_list *timer,
  281. unsigned long expire)
  282. {
  283. if (!upriv->udev)
  284. return;
  285. mod_timer(timer, expire);
  286. }
  287. static void ezusb_request_timerfn(u_long _ctx)
  288. {
  289. struct request_context *ctx = (void *) _ctx;
  290. ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
  291. if (usb_unlink_urb(ctx->outurb) == -EINPROGRESS) {
  292. ctx->state = EZUSB_CTX_REQ_TIMEOUT;
  293. } else {
  294. ctx->state = EZUSB_CTX_RESP_TIMEOUT;
  295. dbg("couldn't unlink");
  296. atomic_inc(&ctx->refcount);
  297. ctx->killed = 1;
  298. ezusb_ctx_complete(ctx);
  299. ezusb_request_context_put(ctx);
  300. }
  301. };
  302. static struct request_context *ezusb_alloc_ctx(struct ezusb_priv *upriv,
  303. u16 out_rid, u16 in_rid)
  304. {
  305. struct request_context *ctx;
  306. ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC);
  307. if (!ctx)
  308. return NULL;
  309. ctx->buf = kmalloc(BULK_BUF_SIZE, GFP_ATOMIC);
  310. if (!ctx->buf) {
  311. kfree(ctx);
  312. return NULL;
  313. }
  314. ctx->outurb = usb_alloc_urb(0, GFP_ATOMIC);
  315. if (!ctx->outurb) {
  316. kfree(ctx->buf);
  317. kfree(ctx);
  318. return NULL;
  319. }
  320. ctx->upriv = upriv;
  321. ctx->state = EZUSB_CTX_START;
  322. ctx->out_rid = out_rid;
  323. ctx->in_rid = in_rid;
  324. atomic_set(&ctx->refcount, 1);
  325. init_completion(&ctx->done);
  326. init_timer(&ctx->timer);
  327. ctx->timer.function = ezusb_request_timerfn;
  328. ctx->timer.data = (u_long) ctx;
  329. return ctx;
  330. }
  331. /* Hopefully the real complete_all will soon be exported, in the mean
  332. * while this should work. */
  333. static inline void ezusb_complete_all(struct completion *comp)
  334. {
  335. complete(comp);
  336. complete(comp);
  337. complete(comp);
  338. complete(comp);
  339. }
  340. static void ezusb_ctx_complete(struct request_context *ctx)
  341. {
  342. struct ezusb_priv *upriv = ctx->upriv;
  343. unsigned long flags;
  344. spin_lock_irqsave(&upriv->req_lock, flags);
  345. list_del_init(&ctx->list);
  346. if (upriv->udev) {
  347. spin_unlock_irqrestore(&upriv->req_lock, flags);
  348. ezusb_req_queue_run(upriv);
  349. spin_lock_irqsave(&upriv->req_lock, flags);
  350. }
  351. switch (ctx->state) {
  352. case EZUSB_CTX_COMPLETE:
  353. case EZUSB_CTX_REQSUBMIT_FAIL:
  354. case EZUSB_CTX_REQ_FAILED:
  355. case EZUSB_CTX_REQ_TIMEOUT:
  356. case EZUSB_CTX_RESP_TIMEOUT:
  357. spin_unlock_irqrestore(&upriv->req_lock, flags);
  358. if ((ctx->out_rid == EZUSB_RID_TX) && upriv->dev) {
  359. struct net_device *dev = upriv->dev;
  360. struct orinoco_private *priv = ndev_priv(dev);
  361. struct net_device_stats *stats = &priv->stats;
  362. if (ctx->state != EZUSB_CTX_COMPLETE)
  363. stats->tx_errors++;
  364. else
  365. stats->tx_packets++;
  366. netif_wake_queue(dev);
  367. }
  368. ezusb_complete_all(&ctx->done);
  369. ezusb_request_context_put(ctx);
  370. break;
  371. default:
  372. spin_unlock_irqrestore(&upriv->req_lock, flags);
  373. if (!upriv->udev) {
  374. /* This is normal, as all request contexts get flushed
  375. * when the device is disconnected */
  376. err("Called, CTX not terminating, but device gone");
  377. ezusb_complete_all(&ctx->done);
  378. ezusb_request_context_put(ctx);
  379. break;
  380. }
  381. err("Called, CTX not in terminating state.");
  382. /* Things are really bad if this happens. Just leak
  383. * the CTX because it may still be linked to the
  384. * queue or the OUT urb may still be active.
  385. * Just leaking at least prevents an Oops or Panic.
  386. */
  387. break;
  388. }
  389. }
  390. /**
  391. * ezusb_req_queue_run:
  392. * Description:
  393. * Note: Only one active CTX at any one time, because there's no
  394. * other (reliable) way to match the response URB to the correct
  395. * CTX.
  396. **/
  397. static void ezusb_req_queue_run(struct ezusb_priv *upriv)
  398. {
  399. unsigned long flags;
  400. struct request_context *ctx;
  401. int result;
  402. spin_lock_irqsave(&upriv->req_lock, flags);
  403. if (!list_empty(&upriv->req_active))
  404. goto unlock;
  405. if (list_empty(&upriv->req_pending))
  406. goto unlock;
  407. ctx =
  408. list_entry(upriv->req_pending.next, struct request_context,
  409. list);
  410. if (!ctx->upriv->udev)
  411. goto unlock;
  412. /* We need to split this off to avoid a race condition */
  413. list_move_tail(&ctx->list, &upriv->req_active);
  414. if (ctx->state == EZUSB_CTX_QUEUED) {
  415. atomic_inc(&ctx->refcount);
  416. result = usb_submit_urb(ctx->outurb, GFP_ATOMIC);
  417. if (result) {
  418. ctx->state = EZUSB_CTX_REQSUBMIT_FAIL;
  419. spin_unlock_irqrestore(&upriv->req_lock, flags);
  420. err("Fatal, failed to submit command urb."
  421. " error=%d\n", result);
  422. ezusb_ctx_complete(ctx);
  423. ezusb_request_context_put(ctx);
  424. goto done;
  425. }
  426. ctx->state = EZUSB_CTX_REQ_SUBMITTED;
  427. ezusb_mod_timer(ctx->upriv, &ctx->timer,
  428. jiffies + DEF_TIMEOUT);
  429. }
  430. unlock:
  431. spin_unlock_irqrestore(&upriv->req_lock, flags);
  432. done:
  433. return;
  434. }
  435. static void ezusb_req_enqueue_run(struct ezusb_priv *upriv,
  436. struct request_context *ctx)
  437. {
  438. unsigned long flags;
  439. spin_lock_irqsave(&upriv->req_lock, flags);
  440. if (!ctx->upriv->udev) {
  441. spin_unlock_irqrestore(&upriv->req_lock, flags);
  442. goto done;
  443. }
  444. atomic_inc(&ctx->refcount);
  445. list_add_tail(&ctx->list, &upriv->req_pending);
  446. spin_unlock_irqrestore(&upriv->req_lock, flags);
  447. ctx->state = EZUSB_CTX_QUEUED;
  448. ezusb_req_queue_run(upriv);
  449. done:
  450. return;
  451. }
  452. static void ezusb_request_out_callback(struct urb *urb)
  453. {
  454. unsigned long flags;
  455. enum ezusb_state state;
  456. struct request_context *ctx = urb->context;
  457. struct ezusb_priv *upriv = ctx->upriv;
  458. spin_lock_irqsave(&upriv->req_lock, flags);
  459. del_timer(&ctx->timer);
  460. if (ctx->killed) {
  461. spin_unlock_irqrestore(&upriv->req_lock, flags);
  462. pr_warning("interrupt called with dead ctx");
  463. goto out;
  464. }
  465. state = ctx->state;
  466. if (urb->status == 0) {
  467. switch (state) {
  468. case EZUSB_CTX_REQ_SUBMITTED:
  469. if (ctx->in_rid) {
  470. ctx->state = EZUSB_CTX_REQ_COMPLETE;
  471. /* reply URB still pending */
  472. ezusb_mod_timer(upriv, &ctx->timer,
  473. jiffies + DEF_TIMEOUT);
  474. spin_unlock_irqrestore(&upriv->req_lock,
  475. flags);
  476. break;
  477. }
  478. /* fall through */
  479. case EZUSB_CTX_RESP_RECEIVED:
  480. /* IN already received before this OUT-ACK */
  481. ctx->state = EZUSB_CTX_COMPLETE;
  482. spin_unlock_irqrestore(&upriv->req_lock, flags);
  483. ezusb_ctx_complete(ctx);
  484. break;
  485. default:
  486. spin_unlock_irqrestore(&upriv->req_lock, flags);
  487. err("Unexpected state(0x%x, %d) in OUT URB",
  488. state, urb->status);
  489. break;
  490. }
  491. } else {
  492. /* If someone cancels the OUT URB then its status
  493. * should be either -ECONNRESET or -ENOENT.
  494. */
  495. switch (state) {
  496. case EZUSB_CTX_REQ_SUBMITTED:
  497. case EZUSB_CTX_RESP_RECEIVED:
  498. ctx->state = EZUSB_CTX_REQ_FAILED;
  499. /* fall through */
  500. case EZUSB_CTX_REQ_FAILED:
  501. case EZUSB_CTX_REQ_TIMEOUT:
  502. spin_unlock_irqrestore(&upriv->req_lock, flags);
  503. ezusb_ctx_complete(ctx);
  504. break;
  505. default:
  506. spin_unlock_irqrestore(&upriv->req_lock, flags);
  507. err("Unexpected state(0x%x, %d) in OUT URB",
  508. state, urb->status);
  509. break;
  510. }
  511. }
  512. out:
  513. ezusb_request_context_put(ctx);
  514. }
  515. static void ezusb_request_in_callback(struct ezusb_priv *upriv,
  516. struct urb *urb)
  517. {
  518. struct ezusb_packet *ans = urb->transfer_buffer;
  519. struct request_context *ctx = NULL;
  520. enum ezusb_state state;
  521. unsigned long flags;
  522. /* Find the CTX on the active queue that requested this URB */
  523. spin_lock_irqsave(&upriv->req_lock, flags);
  524. if (upriv->udev) {
  525. struct list_head *item;
  526. list_for_each(item, &upriv->req_active) {
  527. struct request_context *c;
  528. int reply_count;
  529. c = list_entry(item, struct request_context, list);
  530. reply_count =
  531. ezusb_reply_inc(c->buf->req_reply_count);
  532. if ((ans->ans_reply_count == reply_count)
  533. && (le16_to_cpu(ans->hermes_rid) == c->in_rid)) {
  534. ctx = c;
  535. break;
  536. }
  537. dbg("Skipped (0x%x/0x%x) (%d/%d)",
  538. le16_to_cpu(ans->hermes_rid),
  539. c->in_rid, ans->ans_reply_count, reply_count);
  540. }
  541. }
  542. if (ctx == NULL) {
  543. spin_unlock_irqrestore(&upriv->req_lock, flags);
  544. err("%s: got unexpected RID: 0x%04X", __func__,
  545. le16_to_cpu(ans->hermes_rid));
  546. ezusb_req_queue_run(upriv);
  547. return;
  548. }
  549. /* The data we want is in the in buffer, exchange */
  550. urb->transfer_buffer = ctx->buf;
  551. ctx->buf = (void *) ans;
  552. ctx->buf_length = urb->actual_length;
  553. state = ctx->state;
  554. switch (state) {
  555. case EZUSB_CTX_REQ_SUBMITTED:
  556. /* We have received our response URB before
  557. * our request has been acknowledged. Do NOT
  558. * destroy our CTX yet, because our OUT URB
  559. * is still alive ...
  560. */
  561. ctx->state = EZUSB_CTX_RESP_RECEIVED;
  562. spin_unlock_irqrestore(&upriv->req_lock, flags);
  563. /* Let the machine continue running. */
  564. break;
  565. case EZUSB_CTX_REQ_COMPLETE:
  566. /* This is the usual path: our request
  567. * has already been acknowledged, and
  568. * we have now received the reply.
  569. */
  570. ctx->state = EZUSB_CTX_COMPLETE;
  571. /* Stop the intimer */
  572. del_timer(&ctx->timer);
  573. spin_unlock_irqrestore(&upriv->req_lock, flags);
  574. /* Call the completion handler */
  575. ezusb_ctx_complete(ctx);
  576. break;
  577. default:
  578. spin_unlock_irqrestore(&upriv->req_lock, flags);
  579. pr_warning("Matched IN URB, unexpected context state(0x%x)",
  580. state);
  581. /* Throw this CTX away and try submitting another */
  582. del_timer(&ctx->timer);
  583. ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
  584. usb_unlink_urb(ctx->outurb);
  585. ezusb_req_queue_run(upriv);
  586. break;
  587. } /* switch */
  588. }
  589. static void ezusb_req_ctx_wait(struct ezusb_priv *upriv,
  590. struct request_context *ctx)
  591. {
  592. switch (ctx->state) {
  593. case EZUSB_CTX_QUEUED:
  594. case EZUSB_CTX_REQ_SUBMITTED:
  595. case EZUSB_CTX_REQ_COMPLETE:
  596. case EZUSB_CTX_RESP_RECEIVED:
  597. if (in_softirq()) {
  598. /* If we get called from a timer, timeout timers don't
  599. * get the chance to run themselves. So we make sure
  600. * that we don't sleep for ever */
  601. int msecs = DEF_TIMEOUT * (1000 / HZ);
  602. while (!ctx->done.done && msecs--)
  603. udelay(1000);
  604. } else {
  605. wait_event_interruptible(ctx->done.wait,
  606. ctx->done.done);
  607. }
  608. break;
  609. default:
  610. /* Done or failed - nothing to wait for */
  611. break;
  612. }
  613. }
  614. static inline u16 build_crc(struct ezusb_packet *data)
  615. {
  616. u16 crc = 0;
  617. u8 *bytes = (u8 *)data;
  618. int i;
  619. for (i = 0; i < 8; i++)
  620. crc = (crc << 1) + bytes[i];
  621. return crc;
  622. }
  623. /**
  624. * ezusb_fill_req:
  625. *
  626. * if data == NULL and length > 0 the data is assumed to be already in
  627. * the target buffer and only the header is filled.
  628. *
  629. */
  630. static int ezusb_fill_req(struct ezusb_packet *req, u16 length, u16 rid,
  631. const void *data, u16 frame_type, u8 reply_count)
  632. {
  633. int total_size = sizeof(*req) + length;
  634. BUG_ON(total_size > BULK_BUF_SIZE);
  635. req->magic = cpu_to_le16(EZUSB_MAGIC);
  636. req->req_reply_count = reply_count;
  637. req->ans_reply_count = 0;
  638. req->frame_type = cpu_to_le16(frame_type);
  639. req->size = cpu_to_le16(length + 4);
  640. req->crc = cpu_to_le16(build_crc(req));
  641. req->hermes_len = cpu_to_le16(HERMES_BYTES_TO_RECLEN(length));
  642. req->hermes_rid = cpu_to_le16(rid);
  643. if (data)
  644. memcpy(req->data, data, length);
  645. return total_size;
  646. }
  647. static int ezusb_submit_in_urb(struct ezusb_priv *upriv)
  648. {
  649. int retval = 0;
  650. void *cur_buf = upriv->read_urb->transfer_buffer;
  651. if (upriv->read_urb->status == -EINPROGRESS) {
  652. dbg("urb busy, not resubmiting");
  653. retval = -EBUSY;
  654. goto exit;
  655. }
  656. usb_fill_bulk_urb(upriv->read_urb, upriv->udev, upriv->read_pipe,
  657. cur_buf, BULK_BUF_SIZE,
  658. ezusb_bulk_in_callback, upriv);
  659. upriv->read_urb->transfer_flags = 0;
  660. retval = usb_submit_urb(upriv->read_urb, GFP_ATOMIC);
  661. if (retval)
  662. err("%s submit failed %d", __func__, retval);
  663. exit:
  664. return retval;
  665. }
  666. static inline int ezusb_8051_cpucs(struct ezusb_priv *upriv, int reset)
  667. {
  668. u8 res_val = reset; /* avoid argument promotion */
  669. if (!upriv->udev) {
  670. err("%s: !upriv->udev", __func__);
  671. return -EFAULT;
  672. }
  673. return usb_control_msg(upriv->udev,
  674. usb_sndctrlpipe(upriv->udev, 0),
  675. EZUSB_REQUEST_FW_TRANS,
  676. USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  677. USB_DIR_OUT, EZUSB_CPUCS_REG, 0, &res_val,
  678. sizeof(res_val), DEF_TIMEOUT);
  679. }
  680. static int ezusb_firmware_download(struct ezusb_priv *upriv,
  681. struct ez_usb_fw *fw)
  682. {
  683. u8 *fw_buffer;
  684. int retval, addr;
  685. int variant_offset;
  686. fw_buffer = kmalloc(FW_BUF_SIZE, GFP_KERNEL);
  687. if (!fw_buffer) {
  688. printk(KERN_ERR PFX "Out of memory for firmware buffer.\n");
  689. return -ENOMEM;
  690. }
  691. /*
  692. * This byte is 1 and should be replaced with 0. The offset is
  693. * 0x10AD in version 0.0.6. The byte in question should follow
  694. * the end of the code pointed to by the jump in the beginning
  695. * of the firmware. Also, it is read by code located at 0x358.
  696. */
  697. variant_offset = be16_to_cpup((__be16 *) &fw->code[FW_VAR_OFFSET_PTR]);
  698. if (variant_offset >= fw->size) {
  699. printk(KERN_ERR PFX "Invalid firmware variant offset: "
  700. "0x%04x\n", variant_offset);
  701. retval = -EINVAL;
  702. goto fail;
  703. }
  704. retval = ezusb_8051_cpucs(upriv, 1);
  705. if (retval < 0)
  706. goto fail;
  707. for (addr = 0; addr < fw->size; addr += FW_BUF_SIZE) {
  708. /* 0x100-0x300 should be left alone, it contains card
  709. * specific data, like USB enumeration information */
  710. if ((addr >= FW_HOLE_START) && (addr < FW_HOLE_END))
  711. continue;
  712. memcpy(fw_buffer, &fw->code[addr], FW_BUF_SIZE);
  713. if (variant_offset >= addr &&
  714. variant_offset < addr + FW_BUF_SIZE) {
  715. dbg("Patching card_variant byte at 0x%04X",
  716. variant_offset);
  717. fw_buffer[variant_offset - addr] = FW_VAR_VALUE;
  718. }
  719. retval = usb_control_msg(upriv->udev,
  720. usb_sndctrlpipe(upriv->udev, 0),
  721. EZUSB_REQUEST_FW_TRANS,
  722. USB_TYPE_VENDOR | USB_RECIP_DEVICE
  723. | USB_DIR_OUT,
  724. addr, 0x0,
  725. fw_buffer, FW_BUF_SIZE,
  726. DEF_TIMEOUT);
  727. if (retval < 0)
  728. goto fail;
  729. }
  730. retval = ezusb_8051_cpucs(upriv, 0);
  731. if (retval < 0)
  732. goto fail;
  733. goto exit;
  734. fail:
  735. printk(KERN_ERR PFX "Firmware download failed, error %d\n",
  736. retval);
  737. exit:
  738. kfree(fw_buffer);
  739. return retval;
  740. }
  741. static int ezusb_access_ltv(struct ezusb_priv *upriv,
  742. struct request_context *ctx,
  743. u16 length, const void *data, u16 frame_type,
  744. void *ans_buff, unsigned ans_size, u16 *ans_length)
  745. {
  746. int req_size;
  747. int retval = 0;
  748. enum ezusb_state state;
  749. BUG_ON(in_irq());
  750. if (!upriv->udev) {
  751. dbg("Device disconnected");
  752. retval = -ENODEV;
  753. goto exit;
  754. }
  755. if (upriv->read_urb->status != -EINPROGRESS)
  756. err("%s: in urb not pending", __func__);
  757. /* protect upriv->reply_count, guarantee sequential numbers */
  758. spin_lock_bh(&upriv->reply_count_lock);
  759. req_size = ezusb_fill_req(ctx->buf, length, ctx->out_rid, data,
  760. frame_type, upriv->reply_count);
  761. usb_fill_bulk_urb(ctx->outurb, upriv->udev, upriv->write_pipe,
  762. ctx->buf, req_size,
  763. ezusb_request_out_callback, ctx);
  764. if (ctx->in_rid)
  765. upriv->reply_count = ezusb_reply_inc(upriv->reply_count);
  766. ezusb_req_enqueue_run(upriv, ctx);
  767. spin_unlock_bh(&upriv->reply_count_lock);
  768. if (ctx->in_rid)
  769. ezusb_req_ctx_wait(upriv, ctx);
  770. state = ctx->state;
  771. switch (state) {
  772. case EZUSB_CTX_COMPLETE:
  773. retval = ctx->outurb->status;
  774. break;
  775. case EZUSB_CTX_QUEUED:
  776. case EZUSB_CTX_REQ_SUBMITTED:
  777. if (!ctx->in_rid)
  778. break;
  779. default:
  780. err("%s: Unexpected context state %d", __func__,
  781. state);
  782. /* fall though */
  783. case EZUSB_CTX_REQ_TIMEOUT:
  784. case EZUSB_CTX_REQ_FAILED:
  785. case EZUSB_CTX_RESP_TIMEOUT:
  786. case EZUSB_CTX_REQSUBMIT_FAIL:
  787. printk(KERN_ERR PFX "Access failed, resetting (state %d,"
  788. " reply_count %d)\n", state, upriv->reply_count);
  789. upriv->reply_count = 0;
  790. if (state == EZUSB_CTX_REQ_TIMEOUT
  791. || state == EZUSB_CTX_RESP_TIMEOUT) {
  792. printk(KERN_ERR PFX "ctx timed out\n");
  793. retval = -ETIMEDOUT;
  794. } else {
  795. printk(KERN_ERR PFX "ctx failed\n");
  796. retval = -EFAULT;
  797. }
  798. goto exit;
  799. break;
  800. }
  801. if (ctx->in_rid) {
  802. struct ezusb_packet *ans = ctx->buf;
  803. unsigned exp_len;
  804. if (ans->hermes_len != 0)
  805. exp_len = le16_to_cpu(ans->hermes_len) * 2 + 12;
  806. else
  807. exp_len = 14;
  808. if (exp_len != ctx->buf_length) {
  809. err("%s: length mismatch for RID 0x%04x: "
  810. "expected %d, got %d", __func__,
  811. ctx->in_rid, exp_len, ctx->buf_length);
  812. retval = -EIO;
  813. goto exit;
  814. }
  815. if (ans_buff)
  816. memcpy(ans_buff, ans->data, min(exp_len, ans_size));
  817. if (ans_length)
  818. *ans_length = le16_to_cpu(ans->hermes_len);
  819. }
  820. exit:
  821. ezusb_request_context_put(ctx);
  822. return retval;
  823. }
  824. static int ezusb_write_ltv(struct hermes *hw, int bap, u16 rid,
  825. u16 length, const void *data)
  826. {
  827. struct ezusb_priv *upriv = hw->priv;
  828. u16 frame_type;
  829. struct request_context *ctx;
  830. if (length == 0)
  831. return -EINVAL;
  832. length = HERMES_RECLEN_TO_BYTES(length);
  833. /* On memory mapped devices HERMES_RID_CNFGROUPADDRESSES can be
  834. * set to be empty, but the USB bridge doesn't like it */
  835. if (length == 0)
  836. return 0;
  837. ctx = ezusb_alloc_ctx(upriv, rid, EZUSB_RID_ACK);
  838. if (!ctx)
  839. return -ENOMEM;
  840. if (rid == EZUSB_RID_TX)
  841. frame_type = EZUSB_FRAME_DATA;
  842. else
  843. frame_type = EZUSB_FRAME_CONTROL;
  844. return ezusb_access_ltv(upriv, ctx, length, data, frame_type,
  845. NULL, 0, NULL);
  846. }
  847. static int ezusb_read_ltv(struct hermes *hw, int bap, u16 rid,
  848. unsigned bufsize, u16 *length, void *buf)
  849. {
  850. struct ezusb_priv *upriv = hw->priv;
  851. struct request_context *ctx;
  852. if (bufsize % 2)
  853. return -EINVAL;
  854. ctx = ezusb_alloc_ctx(upriv, rid, rid);
  855. if (!ctx)
  856. return -ENOMEM;
  857. return ezusb_access_ltv(upriv, ctx, 0, NULL, EZUSB_FRAME_CONTROL,
  858. buf, bufsize, length);
  859. }
  860. static int ezusb_doicmd_wait(struct hermes *hw, u16 cmd, u16 parm0, u16 parm1,
  861. u16 parm2, struct hermes_response *resp)
  862. {
  863. struct ezusb_priv *upriv = hw->priv;
  864. struct request_context *ctx;
  865. __le16 data[4] = {
  866. cpu_to_le16(cmd),
  867. cpu_to_le16(parm0),
  868. cpu_to_le16(parm1),
  869. cpu_to_le16(parm2),
  870. };
  871. dbg("0x%04X, parm0 0x%04X, parm1 0x%04X, parm2 0x%04X",
  872. cmd, parm0, parm1, parm2);
  873. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK);
  874. if (!ctx)
  875. return -ENOMEM;
  876. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  877. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  878. }
  879. static int ezusb_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
  880. struct hermes_response *resp)
  881. {
  882. struct ezusb_priv *upriv = hw->priv;
  883. struct request_context *ctx;
  884. __le16 data[4] = {
  885. cpu_to_le16(cmd),
  886. cpu_to_le16(parm0),
  887. 0,
  888. 0,
  889. };
  890. dbg("0x%04X, parm0 0x%04X", cmd, parm0);
  891. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_DOCMD, EZUSB_RID_ACK);
  892. if (!ctx)
  893. return -ENOMEM;
  894. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  895. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  896. }
  897. static int ezusb_bap_pread(struct hermes *hw, int bap,
  898. void *buf, int len, u16 id, u16 offset)
  899. {
  900. struct ezusb_priv *upriv = hw->priv;
  901. struct ezusb_packet *ans = (void *) upriv->read_urb->transfer_buffer;
  902. int actual_length = upriv->read_urb->actual_length;
  903. if (id == EZUSB_RID_RX) {
  904. if ((sizeof(*ans) + offset + len) > actual_length) {
  905. printk(KERN_ERR PFX "BAP read beyond buffer end "
  906. "in rx frame\n");
  907. return -EINVAL;
  908. }
  909. memcpy(buf, ans->data + offset, len);
  910. return 0;
  911. }
  912. if (EZUSB_IS_INFO(id)) {
  913. /* Include 4 bytes for length/type */
  914. if ((sizeof(*ans) + offset + len - 4) > actual_length) {
  915. printk(KERN_ERR PFX "BAP read beyond buffer end "
  916. "in info frame\n");
  917. return -EFAULT;
  918. }
  919. memcpy(buf, ans->data + offset - 4, len);
  920. } else {
  921. printk(KERN_ERR PFX "Unexpected fid 0x%04x\n", id);
  922. return -EINVAL;
  923. }
  924. return 0;
  925. }
  926. static int ezusb_read_pda(struct hermes *hw, __le16 *pda,
  927. u32 pda_addr, u16 pda_len)
  928. {
  929. struct ezusb_priv *upriv = hw->priv;
  930. struct request_context *ctx;
  931. __le16 data[] = {
  932. cpu_to_le16(pda_addr & 0xffff),
  933. cpu_to_le16(pda_len - 4)
  934. };
  935. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_READ_PDA, EZUSB_RID_READ_PDA);
  936. if (!ctx)
  937. return -ENOMEM;
  938. /* wl_lkm does not include PDA size in the PDA area.
  939. * We will pad the information into pda, so other routines
  940. * don't have to be modified */
  941. pda[0] = cpu_to_le16(pda_len - 2);
  942. /* Includes CFG_PROD_DATA but not itself */
  943. pda[1] = cpu_to_le16(0x0800); /* CFG_PROD_DATA */
  944. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  945. EZUSB_FRAME_CONTROL, &pda[2], pda_len - 4,
  946. NULL);
  947. }
  948. static int ezusb_program_init(struct hermes *hw, u32 entry_point)
  949. {
  950. struct ezusb_priv *upriv = hw->priv;
  951. struct request_context *ctx;
  952. __le32 data = cpu_to_le32(entry_point);
  953. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_INIT, EZUSB_RID_ACK);
  954. if (!ctx)
  955. return -ENOMEM;
  956. return ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  957. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  958. }
  959. static int ezusb_program_end(struct hermes *hw)
  960. {
  961. struct ezusb_priv *upriv = hw->priv;
  962. struct request_context *ctx;
  963. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_END, EZUSB_RID_ACK);
  964. if (!ctx)
  965. return -ENOMEM;
  966. return ezusb_access_ltv(upriv, ctx, 0, NULL,
  967. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  968. }
  969. static int ezusb_program_bytes(struct hermes *hw, const char *buf,
  970. u32 addr, u32 len)
  971. {
  972. struct ezusb_priv *upriv = hw->priv;
  973. struct request_context *ctx;
  974. __le32 data = cpu_to_le32(addr);
  975. int err;
  976. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_SET_ADDR, EZUSB_RID_ACK);
  977. if (!ctx)
  978. return -ENOMEM;
  979. err = ezusb_access_ltv(upriv, ctx, sizeof(data), &data,
  980. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  981. if (err)
  982. return err;
  983. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_PROG_BYTES, EZUSB_RID_ACK);
  984. if (!ctx)
  985. return -ENOMEM;
  986. return ezusb_access_ltv(upriv, ctx, len, buf,
  987. EZUSB_FRAME_CONTROL, NULL, 0, NULL);
  988. }
  989. static int ezusb_program(struct hermes *hw, const char *buf,
  990. u32 addr, u32 len)
  991. {
  992. u32 ch_addr;
  993. u32 ch_len;
  994. int err = 0;
  995. /* We can only send 2048 bytes out of the bulk xmit at a time,
  996. * so we have to split any programming into chunks of <2048
  997. * bytes. */
  998. ch_len = (len < MAX_DL_SIZE) ? len : MAX_DL_SIZE;
  999. ch_addr = addr;
  1000. while (ch_addr < (addr + len)) {
  1001. pr_debug("Programming subblock of length %d "
  1002. "to address 0x%08x. Data @ %p\n",
  1003. ch_len, ch_addr, &buf[ch_addr - addr]);
  1004. err = ezusb_program_bytes(hw, &buf[ch_addr - addr],
  1005. ch_addr, ch_len);
  1006. if (err)
  1007. break;
  1008. ch_addr += ch_len;
  1009. ch_len = ((addr + len - ch_addr) < MAX_DL_SIZE) ?
  1010. (addr + len - ch_addr) : MAX_DL_SIZE;
  1011. }
  1012. return err;
  1013. }
  1014. static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
  1015. {
  1016. struct orinoco_private *priv = ndev_priv(dev);
  1017. struct net_device_stats *stats = &priv->stats;
  1018. struct ezusb_priv *upriv = priv->card;
  1019. u8 mic[MICHAEL_MIC_LEN + 1];
  1020. int err = 0;
  1021. int tx_control;
  1022. unsigned long flags;
  1023. struct request_context *ctx;
  1024. u8 *buf;
  1025. int tx_size;
  1026. if (!netif_running(dev)) {
  1027. printk(KERN_ERR "%s: Tx on stopped device!\n",
  1028. dev->name);
  1029. return NETDEV_TX_BUSY;
  1030. }
  1031. if (netif_queue_stopped(dev)) {
  1032. printk(KERN_DEBUG "%s: Tx while transmitter busy!\n",
  1033. dev->name);
  1034. return NETDEV_TX_BUSY;
  1035. }
  1036. if (orinoco_lock(priv, &flags) != 0) {
  1037. printk(KERN_ERR
  1038. "%s: ezusb_xmit() called while hw_unavailable\n",
  1039. dev->name);
  1040. return NETDEV_TX_BUSY;
  1041. }
  1042. if (!netif_carrier_ok(dev) ||
  1043. (priv->iw_mode == NL80211_IFTYPE_MONITOR)) {
  1044. /* Oops, the firmware hasn't established a connection,
  1045. silently drop the packet (this seems to be the
  1046. safest approach). */
  1047. goto drop;
  1048. }
  1049. /* Check packet length */
  1050. if (skb->len < ETH_HLEN)
  1051. goto drop;
  1052. ctx = ezusb_alloc_ctx(upriv, EZUSB_RID_TX, 0);
  1053. if (!ctx)
  1054. goto busy;
  1055. memset(ctx->buf, 0, BULK_BUF_SIZE);
  1056. buf = ctx->buf->data;
  1057. tx_control = 0;
  1058. err = orinoco_process_xmit_skb(skb, dev, priv, &tx_control,
  1059. &mic[0]);
  1060. if (err)
  1061. goto drop;
  1062. {
  1063. __le16 *tx_cntl = (__le16 *)buf;
  1064. *tx_cntl = cpu_to_le16(tx_control);
  1065. buf += sizeof(*tx_cntl);
  1066. }
  1067. memcpy(buf, skb->data, skb->len);
  1068. buf += skb->len;
  1069. if (tx_control & HERMES_TXCTRL_MIC) {
  1070. u8 *m = mic;
  1071. /* Mic has been offset so it can be copied to an even
  1072. * address. We're copying eveything anyway, so we
  1073. * don't need to copy that first byte. */
  1074. if (skb->len % 2)
  1075. m++;
  1076. memcpy(buf, m, MICHAEL_MIC_LEN);
  1077. buf += MICHAEL_MIC_LEN;
  1078. }
  1079. /* Finally, we actually initiate the send */
  1080. netif_stop_queue(dev);
  1081. /* The card may behave better if we send evenly sized usb transfers */
  1082. tx_size = ALIGN(buf - ctx->buf->data, 2);
  1083. err = ezusb_access_ltv(upriv, ctx, tx_size, NULL,
  1084. EZUSB_FRAME_DATA, NULL, 0, NULL);
  1085. if (err) {
  1086. netif_start_queue(dev);
  1087. if (net_ratelimit())
  1088. printk(KERN_ERR "%s: Error %d transmitting packet\n",
  1089. dev->name, err);
  1090. goto busy;
  1091. }
  1092. dev->trans_start = jiffies;
  1093. stats->tx_bytes += skb->len;
  1094. goto ok;
  1095. drop:
  1096. stats->tx_errors++;
  1097. stats->tx_dropped++;
  1098. ok:
  1099. orinoco_unlock(priv, &flags);
  1100. dev_kfree_skb(skb);
  1101. return NETDEV_TX_OK;
  1102. busy:
  1103. orinoco_unlock(priv, &flags);
  1104. return NETDEV_TX_BUSY;
  1105. }
  1106. static int ezusb_allocate(struct hermes *hw, u16 size, u16 *fid)
  1107. {
  1108. *fid = EZUSB_RID_TX;
  1109. return 0;
  1110. }
  1111. static int ezusb_hard_reset(struct orinoco_private *priv)
  1112. {
  1113. struct ezusb_priv *upriv = priv->card;
  1114. int retval = ezusb_8051_cpucs(upriv, 1);
  1115. if (retval < 0) {
  1116. err("Failed to reset");
  1117. return retval;
  1118. }
  1119. retval = ezusb_8051_cpucs(upriv, 0);
  1120. if (retval < 0) {
  1121. err("Failed to unreset");
  1122. return retval;
  1123. }
  1124. dbg("sending control message");
  1125. retval = usb_control_msg(upriv->udev,
  1126. usb_sndctrlpipe(upriv->udev, 0),
  1127. EZUSB_REQUEST_TRIGER,
  1128. USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  1129. USB_DIR_OUT, 0x0, 0x0, NULL, 0,
  1130. DEF_TIMEOUT);
  1131. if (retval < 0) {
  1132. err("EZUSB_REQUEST_TRIGER failed retval %d", retval);
  1133. return retval;
  1134. }
  1135. #if 0
  1136. dbg("Sending EZUSB_REQUEST_TRIG_AC");
  1137. retval = usb_control_msg(upriv->udev,
  1138. usb_sndctrlpipe(upriv->udev, 0),
  1139. EZUSB_REQUEST_TRIG_AC,
  1140. USB_TYPE_VENDOR | USB_RECIP_DEVICE |
  1141. USB_DIR_OUT, 0x00FA, 0x0, NULL, 0,
  1142. DEF_TIMEOUT);
  1143. if (retval < 0) {
  1144. err("EZUSB_REQUEST_TRIG_AC failed retval %d", retval);
  1145. return retval;
  1146. }
  1147. #endif
  1148. return 0;
  1149. }
  1150. static int ezusb_init(struct hermes *hw)
  1151. {
  1152. struct ezusb_priv *upriv = hw->priv;
  1153. int retval;
  1154. BUG_ON(in_interrupt());
  1155. BUG_ON(!upriv);
  1156. upriv->reply_count = 0;
  1157. /* Write the MAGIC number on the simulated registers to keep
  1158. * orinoco.c happy */
  1159. hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC);
  1160. hermes_write_regn(hw, RXFID, EZUSB_RID_RX);
  1161. usb_kill_urb(upriv->read_urb);
  1162. ezusb_submit_in_urb(upriv);
  1163. retval = ezusb_write_ltv(hw, 0, EZUSB_RID_INIT1,
  1164. HERMES_BYTES_TO_RECLEN(2), "\x10\x00");
  1165. if (retval < 0) {
  1166. printk(KERN_ERR PFX "EZUSB_RID_INIT1 error %d\n", retval);
  1167. return retval;
  1168. }
  1169. retval = ezusb_docmd_wait(hw, HERMES_CMD_INIT, 0, NULL);
  1170. if (retval < 0) {
  1171. printk(KERN_ERR PFX "HERMES_CMD_INIT error %d\n", retval);
  1172. return retval;
  1173. }
  1174. return 0;
  1175. }
  1176. static void ezusb_bulk_in_callback(struct urb *urb)
  1177. {
  1178. struct ezusb_priv *upriv = (struct ezusb_priv *) urb->context;
  1179. struct ezusb_packet *ans = urb->transfer_buffer;
  1180. u16 crc;
  1181. u16 hermes_rid;
  1182. if (upriv->udev == NULL) {
  1183. dbg("disconnected");
  1184. return;
  1185. }
  1186. if (urb->status == -ETIMEDOUT) {
  1187. /* When a device gets unplugged we get this every time
  1188. * we resubmit, flooding the logs. Since we don't use
  1189. * USB timeouts, it shouldn't happen any other time*/
  1190. pr_warning("%s: urb timed out, not resubmiting", __func__);
  1191. return;
  1192. }
  1193. if (urb->status == -ECONNABORTED) {
  1194. pr_warning("%s: connection abort, resubmiting urb",
  1195. __func__);
  1196. goto resubmit;
  1197. }
  1198. if ((urb->status == -EILSEQ)
  1199. || (urb->status == -ENOENT)
  1200. || (urb->status == -ECONNRESET)) {
  1201. dbg("status %d, not resubmiting", urb->status);
  1202. return;
  1203. }
  1204. if (urb->status)
  1205. dbg("status: %d length: %d",
  1206. urb->status, urb->actual_length);
  1207. if (urb->actual_length < sizeof(*ans)) {
  1208. err("%s: short read, ignoring", __func__);
  1209. goto resubmit;
  1210. }
  1211. crc = build_crc(ans);
  1212. if (le16_to_cpu(ans->crc) != crc) {
  1213. err("CRC error, ignoring packet");
  1214. goto resubmit;
  1215. }
  1216. hermes_rid = le16_to_cpu(ans->hermes_rid);
  1217. if ((hermes_rid != EZUSB_RID_RX) && !EZUSB_IS_INFO(hermes_rid)) {
  1218. ezusb_request_in_callback(upriv, urb);
  1219. } else if (upriv->dev) {
  1220. struct net_device *dev = upriv->dev;
  1221. struct orinoco_private *priv = ndev_priv(dev);
  1222. struct hermes *hw = &priv->hw;
  1223. if (hermes_rid == EZUSB_RID_RX) {
  1224. __orinoco_ev_rx(dev, hw);
  1225. } else {
  1226. hermes_write_regn(hw, INFOFID,
  1227. le16_to_cpu(ans->hermes_rid));
  1228. __orinoco_ev_info(dev, hw);
  1229. }
  1230. }
  1231. resubmit:
  1232. if (upriv->udev)
  1233. ezusb_submit_in_urb(upriv);
  1234. }
  1235. static inline void ezusb_delete(struct ezusb_priv *upriv)
  1236. {
  1237. struct net_device *dev;
  1238. struct list_head *item;
  1239. struct list_head *tmp_item;
  1240. unsigned long flags;
  1241. BUG_ON(in_interrupt());
  1242. BUG_ON(!upriv);
  1243. dev = upriv->dev;
  1244. mutex_lock(&upriv->mtx);
  1245. upriv->udev = NULL; /* No timer will be rearmed from here */
  1246. usb_kill_urb(upriv->read_urb);
  1247. spin_lock_irqsave(&upriv->req_lock, flags);
  1248. list_for_each_safe(item, tmp_item, &upriv->req_active) {
  1249. struct request_context *ctx;
  1250. int err;
  1251. ctx = list_entry(item, struct request_context, list);
  1252. atomic_inc(&ctx->refcount);
  1253. ctx->outurb->transfer_flags |= URB_ASYNC_UNLINK;
  1254. err = usb_unlink_urb(ctx->outurb);
  1255. spin_unlock_irqrestore(&upriv->req_lock, flags);
  1256. if (err == -EINPROGRESS)
  1257. wait_for_completion(&ctx->done);
  1258. del_timer_sync(&ctx->timer);
  1259. /* FIXME: there is an slight chance for the irq handler to
  1260. * be running */
  1261. if (!list_empty(&ctx->list))
  1262. ezusb_ctx_complete(ctx);
  1263. ezusb_request_context_put(ctx);
  1264. spin_lock_irqsave(&upriv->req_lock, flags);
  1265. }
  1266. spin_unlock_irqrestore(&upriv->req_lock, flags);
  1267. list_for_each_safe(item, tmp_item, &upriv->req_pending)
  1268. ezusb_ctx_complete(list_entry(item,
  1269. struct request_context, list));
  1270. if (upriv->read_urb && upriv->read_urb->status == -EINPROGRESS)
  1271. printk(KERN_ERR PFX "Some URB in progress\n");
  1272. mutex_unlock(&upriv->mtx);
  1273. if (upriv->read_urb) {
  1274. kfree(upriv->read_urb->transfer_buffer);
  1275. usb_free_urb(upriv->read_urb);
  1276. }
  1277. kfree(upriv->bap_buf);
  1278. if (upriv->dev) {
  1279. struct orinoco_private *priv = ndev_priv(upriv->dev);
  1280. orinoco_if_del(priv);
  1281. free_orinocodev(priv);
  1282. }
  1283. }
  1284. static void ezusb_lock_irqsave(spinlock_t *lock,
  1285. unsigned long *flags) __acquires(lock)
  1286. {
  1287. spin_lock_bh(lock);
  1288. }
  1289. static void ezusb_unlock_irqrestore(spinlock_t *lock,
  1290. unsigned long *flags) __releases(lock)
  1291. {
  1292. spin_unlock_bh(lock);
  1293. }
  1294. static void ezusb_lock_irq(spinlock_t *lock) __acquires(lock)
  1295. {
  1296. spin_lock_bh(lock);
  1297. }
  1298. static void ezusb_unlock_irq(spinlock_t *lock) __releases(lock)
  1299. {
  1300. spin_unlock_bh(lock);
  1301. }
  1302. static const struct hermes_ops ezusb_ops = {
  1303. .init = ezusb_init,
  1304. .cmd_wait = ezusb_docmd_wait,
  1305. .init_cmd_wait = ezusb_doicmd_wait,
  1306. .allocate = ezusb_allocate,
  1307. .read_ltv = ezusb_read_ltv,
  1308. .write_ltv = ezusb_write_ltv,
  1309. .bap_pread = ezusb_bap_pread,
  1310. .read_pda = ezusb_read_pda,
  1311. .program_init = ezusb_program_init,
  1312. .program_end = ezusb_program_end,
  1313. .program = ezusb_program,
  1314. .lock_irqsave = ezusb_lock_irqsave,
  1315. .unlock_irqrestore = ezusb_unlock_irqrestore,
  1316. .lock_irq = ezusb_lock_irq,
  1317. .unlock_irq = ezusb_unlock_irq,
  1318. };
  1319. static const struct net_device_ops ezusb_netdev_ops = {
  1320. .ndo_open = orinoco_open,
  1321. .ndo_stop = orinoco_stop,
  1322. .ndo_start_xmit = ezusb_xmit,
  1323. .ndo_set_rx_mode = orinoco_set_multicast_list,
  1324. .ndo_change_mtu = orinoco_change_mtu,
  1325. .ndo_set_mac_address = eth_mac_addr,
  1326. .ndo_validate_addr = eth_validate_addr,
  1327. .ndo_tx_timeout = orinoco_tx_timeout,
  1328. .ndo_get_stats = orinoco_get_stats,
  1329. };
  1330. static int ezusb_probe(struct usb_interface *interface,
  1331. const struct usb_device_id *id)
  1332. {
  1333. struct usb_device *udev = interface_to_usbdev(interface);
  1334. struct orinoco_private *priv;
  1335. struct hermes *hw;
  1336. struct ezusb_priv *upriv = NULL;
  1337. struct usb_interface_descriptor *iface_desc;
  1338. struct usb_endpoint_descriptor *ep;
  1339. const struct firmware *fw_entry = NULL;
  1340. int retval = 0;
  1341. int i;
  1342. priv = alloc_orinocodev(sizeof(*upriv), &udev->dev,
  1343. ezusb_hard_reset, NULL);
  1344. if (!priv) {
  1345. err("Couldn't allocate orinocodev");
  1346. goto exit;
  1347. }
  1348. hw = &priv->hw;
  1349. upriv = priv->card;
  1350. mutex_init(&upriv->mtx);
  1351. spin_lock_init(&upriv->reply_count_lock);
  1352. spin_lock_init(&upriv->req_lock);
  1353. INIT_LIST_HEAD(&upriv->req_pending);
  1354. INIT_LIST_HEAD(&upriv->req_active);
  1355. upriv->udev = udev;
  1356. hw->iobase = (void __force __iomem *) &upriv->hermes_reg_fake;
  1357. hw->reg_spacing = HERMES_16BIT_REGSPACING;
  1358. hw->priv = upriv;
  1359. hw->ops = &ezusb_ops;
  1360. /* set up the endpoint information */
  1361. /* check out the endpoints */
  1362. iface_desc = &interface->altsetting[0].desc;
  1363. for (i = 0; i < iface_desc->bNumEndpoints; ++i) {
  1364. ep = &interface->altsetting[0].endpoint[i].desc;
  1365. if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
  1366. == USB_DIR_IN) &&
  1367. ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
  1368. == USB_ENDPOINT_XFER_BULK)) {
  1369. /* we found a bulk in endpoint */
  1370. if (upriv->read_urb != NULL) {
  1371. pr_warning("Found a second bulk in ep, ignored");
  1372. continue;
  1373. }
  1374. upriv->read_urb = usb_alloc_urb(0, GFP_KERNEL);
  1375. if (!upriv->read_urb) {
  1376. err("No free urbs available");
  1377. goto error;
  1378. }
  1379. if (le16_to_cpu(ep->wMaxPacketSize) != 64)
  1380. pr_warning("bulk in: wMaxPacketSize!= 64");
  1381. if (ep->bEndpointAddress != (2 | USB_DIR_IN))
  1382. pr_warning("bulk in: bEndpointAddress: %d",
  1383. ep->bEndpointAddress);
  1384. upriv->read_pipe = usb_rcvbulkpipe(udev,
  1385. ep->
  1386. bEndpointAddress);
  1387. upriv->read_urb->transfer_buffer =
  1388. kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
  1389. if (!upriv->read_urb->transfer_buffer) {
  1390. err("Couldn't allocate IN buffer");
  1391. goto error;
  1392. }
  1393. }
  1394. if (((ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
  1395. == USB_DIR_OUT) &&
  1396. ((ep->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
  1397. == USB_ENDPOINT_XFER_BULK)) {
  1398. /* we found a bulk out endpoint */
  1399. if (upriv->bap_buf != NULL) {
  1400. pr_warning("Found a second bulk out ep, ignored");
  1401. continue;
  1402. }
  1403. if (le16_to_cpu(ep->wMaxPacketSize) != 64)
  1404. pr_warning("bulk out: wMaxPacketSize != 64");
  1405. if (ep->bEndpointAddress != 2)
  1406. pr_warning("bulk out: bEndpointAddress: %d",
  1407. ep->bEndpointAddress);
  1408. upriv->write_pipe = usb_sndbulkpipe(udev,
  1409. ep->
  1410. bEndpointAddress);
  1411. upriv->bap_buf = kmalloc(BULK_BUF_SIZE, GFP_KERNEL);
  1412. if (!upriv->bap_buf) {
  1413. err("Couldn't allocate bulk_out_buffer");
  1414. goto error;
  1415. }
  1416. }
  1417. }
  1418. if (!upriv->bap_buf || !upriv->read_urb) {
  1419. err("Didn't find the required bulk endpoints");
  1420. goto error;
  1421. }
  1422. if (request_firmware(&fw_entry, "orinoco_ezusb_fw",
  1423. &interface->dev) == 0) {
  1424. firmware.size = fw_entry->size;
  1425. firmware.code = fw_entry->data;
  1426. }
  1427. if (firmware.size && firmware.code) {
  1428. if (ezusb_firmware_download(upriv, &firmware) < 0)
  1429. goto error;
  1430. } else {
  1431. err("No firmware to download");
  1432. goto error;
  1433. }
  1434. if (ezusb_hard_reset(priv) < 0) {
  1435. err("Cannot reset the device");
  1436. goto error;
  1437. }
  1438. /* If the firmware is already downloaded orinoco.c will call
  1439. * ezusb_init but if the firmware is not already there, that will make
  1440. * the kernel very unstable, so we try initializing here and quit in
  1441. * case of error */
  1442. if (ezusb_init(hw) < 0) {
  1443. err("Couldn't initialize the device");
  1444. err("Firmware may not be downloaded or may be wrong.");
  1445. goto error;
  1446. }
  1447. /* Initialise the main driver */
  1448. if (orinoco_init(priv) != 0) {
  1449. err("orinoco_init() failed\n");
  1450. goto error;
  1451. }
  1452. if (orinoco_if_add(priv, 0, 0, &ezusb_netdev_ops) != 0) {
  1453. upriv->dev = NULL;
  1454. err("%s: orinoco_if_add() failed", __func__);
  1455. goto error;
  1456. }
  1457. upriv->dev = priv->ndev;
  1458. goto exit;
  1459. error:
  1460. ezusb_delete(upriv);
  1461. if (upriv->dev) {
  1462. /* upriv->dev was 0, so ezusb_delete() didn't free it */
  1463. free_orinocodev(priv);
  1464. }
  1465. upriv = NULL;
  1466. retval = -EFAULT;
  1467. exit:
  1468. if (fw_entry) {
  1469. firmware.code = NULL;
  1470. firmware.size = 0;
  1471. release_firmware(fw_entry);
  1472. }
  1473. usb_set_intfdata(interface, upriv);
  1474. return retval;
  1475. }
  1476. static void ezusb_disconnect(struct usb_interface *intf)
  1477. {
  1478. struct ezusb_priv *upriv = usb_get_intfdata(intf);
  1479. usb_set_intfdata(intf, NULL);
  1480. ezusb_delete(upriv);
  1481. printk(KERN_INFO PFX "Disconnected\n");
  1482. }
  1483. /* usb specific object needed to register this driver with the usb subsystem */
  1484. static struct usb_driver orinoco_driver = {
  1485. .name = DRIVER_NAME,
  1486. .probe = ezusb_probe,
  1487. .disconnect = ezusb_disconnect,
  1488. .id_table = ezusb_table,
  1489. .disable_hub_initiated_lpm = 1,
  1490. };
  1491. module_usb_driver(orinoco_driver);
  1492. MODULE_AUTHOR("Manuel Estrada Sainz");
  1493. MODULE_DESCRIPTION("Driver for Orinoco wireless LAN cards using EZUSB bridge");
  1494. MODULE_LICENSE("Dual MPL/GPL");