sierra.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  1. /*
  2. USB Driver for Sierra Wireless
  3. Copyright (C) 2006, 2007, 2008 Kevin Lloyd <klloyd@sierrawireless.com>,
  4. Copyright (C) 2008, 2009 Elina Pasheva, Matthew Safar, Rory Filer
  5. <linux@sierrawireless.com>
  6. IMPORTANT DISCLAIMER: This driver is not commercially supported by
  7. Sierra Wireless. Use at your own risk.
  8. This driver is free software; you can redistribute it and/or modify
  9. it under the terms of Version 2 of the GNU General Public License as
  10. published by the Free Software Foundation.
  11. Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
  12. Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
  13. */
  14. /* Uncomment to log function calls */
  15. /* #define DEBUG */
  16. #define DRIVER_VERSION "v.1.7.16"
  17. #define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer"
  18. #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
  19. #include <linux/kernel.h>
  20. #include <linux/jiffies.h>
  21. #include <linux/errno.h>
  22. #include <linux/tty.h>
  23. #include <linux/slab.h>
  24. #include <linux/tty_flip.h>
  25. #include <linux/module.h>
  26. #include <linux/usb.h>
  27. #include <linux/usb/serial.h>
  28. #define SWIMS_USB_REQUEST_SetPower 0x00
  29. #define SWIMS_USB_REQUEST_SetNmea 0x07
  30. #define N_IN_URB_HM 8
  31. #define N_OUT_URB_HM 64
  32. #define N_IN_URB 4
  33. #define N_OUT_URB 4
  34. #define IN_BUFLEN 4096
  35. #define MAX_TRANSFER (PAGE_SIZE - 512)
  36. /* MAX_TRANSFER is chosen so that the VM is not stressed by
  37. allocations > PAGE_SIZE and the number of packets in a page
  38. is an integer 512 is the largest possible packet on EHCI */
  39. static bool debug;
  40. static bool nmea;
  41. /* Used in interface blacklisting */
  42. struct sierra_iface_info {
  43. const u32 infolen; /* number of interface numbers on blacklist */
  44. const u8 *ifaceinfo; /* pointer to the array holding the numbers */
  45. };
  46. struct sierra_intf_private {
  47. spinlock_t susp_lock;
  48. unsigned int suspended:1;
  49. int in_flight;
  50. unsigned int open_ports;
  51. };
  52. static int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
  53. {
  54. int result;
  55. dev_dbg(&udev->dev, "%s\n", __func__);
  56. result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  57. SWIMS_USB_REQUEST_SetPower, /* __u8 request */
  58. USB_TYPE_VENDOR, /* __u8 request type */
  59. swiState, /* __u16 value */
  60. 0, /* __u16 index */
  61. NULL, /* void *data */
  62. 0, /* __u16 size */
  63. USB_CTRL_SET_TIMEOUT); /* int timeout */
  64. return result;
  65. }
  66. static int sierra_vsc_set_nmea(struct usb_device *udev, __u16 enable)
  67. {
  68. int result;
  69. dev_dbg(&udev->dev, "%s\n", __func__);
  70. result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
  71. SWIMS_USB_REQUEST_SetNmea, /* __u8 request */
  72. USB_TYPE_VENDOR, /* __u8 request type */
  73. enable, /* __u16 value */
  74. 0x0000, /* __u16 index */
  75. NULL, /* void *data */
  76. 0, /* __u16 size */
  77. USB_CTRL_SET_TIMEOUT); /* int timeout */
  78. return result;
  79. }
  80. static int sierra_calc_num_ports(struct usb_serial *serial)
  81. {
  82. int num_ports = 0;
  83. u8 ifnum, numendpoints;
  84. dev_dbg(&serial->dev->dev, "%s\n", __func__);
  85. ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber;
  86. numendpoints = serial->interface->cur_altsetting->desc.bNumEndpoints;
  87. /* Dummy interface present on some SKUs should be ignored */
  88. if (ifnum == 0x99)
  89. num_ports = 0;
  90. else if (numendpoints <= 3)
  91. num_ports = 1;
  92. else
  93. num_ports = (numendpoints-1)/2;
  94. return num_ports;
  95. }
  96. static int is_blacklisted(const u8 ifnum,
  97. const struct sierra_iface_info *blacklist)
  98. {
  99. const u8 *info;
  100. int i;
  101. if (blacklist) {
  102. info = blacklist->ifaceinfo;
  103. for (i = 0; i < blacklist->infolen; i++) {
  104. if (info[i] == ifnum)
  105. return 1;
  106. }
  107. }
  108. return 0;
  109. }
  110. static int is_himemory(const u8 ifnum,
  111. const struct sierra_iface_info *himemorylist)
  112. {
  113. const u8 *info;
  114. int i;
  115. if (himemorylist) {
  116. info = himemorylist->ifaceinfo;
  117. for (i=0; i < himemorylist->infolen; i++) {
  118. if (info[i] == ifnum)
  119. return 1;
  120. }
  121. }
  122. return 0;
  123. }
  124. static int sierra_calc_interface(struct usb_serial *serial)
  125. {
  126. int interface;
  127. struct usb_interface *p_interface;
  128. struct usb_host_interface *p_host_interface;
  129. dev_dbg(&serial->dev->dev, "%s\n", __func__);
  130. /* Get the interface structure pointer from the serial struct */
  131. p_interface = serial->interface;
  132. /* Get a pointer to the host interface structure */
  133. p_host_interface = p_interface->cur_altsetting;
  134. /* read the interface descriptor for this active altsetting
  135. * to find out the interface number we are on
  136. */
  137. interface = p_host_interface->desc.bInterfaceNumber;
  138. return interface;
  139. }
  140. static int sierra_probe(struct usb_serial *serial,
  141. const struct usb_device_id *id)
  142. {
  143. int result = 0;
  144. struct usb_device *udev;
  145. u8 ifnum;
  146. udev = serial->dev;
  147. dev_dbg(&udev->dev, "%s\n", __func__);
  148. ifnum = sierra_calc_interface(serial);
  149. /*
  150. * If this interface supports more than 1 alternate
  151. * select the 2nd one
  152. */
  153. if (serial->interface->num_altsetting == 2) {
  154. dev_dbg(&udev->dev, "Selecting alt setting for interface %d\n",
  155. ifnum);
  156. /* We know the alternate setting is 1 for the MC8785 */
  157. usb_set_interface(udev, ifnum, 1);
  158. }
  159. /* ifnum could have changed - by calling usb_set_interface */
  160. ifnum = sierra_calc_interface(serial);
  161. if (is_blacklisted(ifnum,
  162. (struct sierra_iface_info *)id->driver_info)) {
  163. dev_dbg(&serial->dev->dev,
  164. "Ignoring blacklisted interface #%d\n", ifnum);
  165. return -ENODEV;
  166. }
  167. return result;
  168. }
  169. /* interfaces with higher memory requirements */
  170. static const u8 hi_memory_typeA_ifaces[] = { 0, 2 };
  171. static const struct sierra_iface_info typeA_interface_list = {
  172. .infolen = ARRAY_SIZE(hi_memory_typeA_ifaces),
  173. .ifaceinfo = hi_memory_typeA_ifaces,
  174. };
  175. static const u8 hi_memory_typeB_ifaces[] = { 3, 4, 5, 6 };
  176. static const struct sierra_iface_info typeB_interface_list = {
  177. .infolen = ARRAY_SIZE(hi_memory_typeB_ifaces),
  178. .ifaceinfo = hi_memory_typeB_ifaces,
  179. };
  180. /* 'blacklist' of interfaces not served by this driver */
  181. static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 };
  182. static const struct sierra_iface_info direct_ip_interface_blacklist = {
  183. .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces),
  184. .ifaceinfo = direct_ip_non_serial_ifaces,
  185. };
  186. static const struct usb_device_id id_table[] = {
  187. { USB_DEVICE(0x0F3D, 0x0112) }, /* Airprime/Sierra PC 5220 */
  188. { USB_DEVICE(0x03F0, 0x1B1D) }, /* HP ev2200 a.k.a MC5720 */
  189. { USB_DEVICE(0x03F0, 0x211D) }, /* HP ev2210 a.k.a MC5725 */
  190. { USB_DEVICE(0x03F0, 0x1E1D) }, /* HP hs2300 a.k.a MC8775 */
  191. { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
  192. { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
  193. { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
  194. { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
  195. { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
  196. { USB_DEVICE(0x1199, 0x0022) }, /* Sierra Wireless EM5725 */
  197. { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */
  198. { USB_DEVICE(0x1199, 0x0224) }, /* Sierra Wireless MC5727 */
  199. { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
  200. { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
  201. { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
  202. { USB_DEVICE(0x1199, 0x0120) }, /* Sierra Wireless USB Dongle 595U */
  203. { USB_DEVICE(0x1199, 0x0301) }, /* Sierra Wireless USB Dongle 250U */
  204. /* Sierra Wireless C597 */
  205. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0023, 0xFF, 0xFF, 0xFF) },
  206. /* Sierra Wireless T598 */
  207. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) },
  208. { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless T11 */
  209. { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless AC402 */
  210. { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless MC5728 */
  211. { USB_DEVICE(0x1199, 0x0029) }, /* Sierra Wireless Device */
  212. { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
  213. { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
  214. { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
  215. { USB_DEVICE(0x1199, 0x6805) }, /* Sierra Wireless MC8765 */
  216. { USB_DEVICE(0x1199, 0x6808) }, /* Sierra Wireless MC8755 */
  217. { USB_DEVICE(0x1199, 0x6809) }, /* Sierra Wireless MC8765 */
  218. { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 & AC 875U */
  219. { USB_DEVICE(0x1199, 0x6813) }, /* Sierra Wireless MC8775 */
  220. { USB_DEVICE(0x1199, 0x6815) }, /* Sierra Wireless MC8775 */
  221. { USB_DEVICE(0x1199, 0x6816) }, /* Sierra Wireless MC8775 */
  222. { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
  223. { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */
  224. { USB_DEVICE(0x1199, 0x6822) }, /* Sierra Wireless AirCard 875E */
  225. { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */
  226. { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */
  227. { USB_DEVICE(0x1199, 0x6834) }, /* Sierra Wireless MC8780 */
  228. { USB_DEVICE(0x1199, 0x6835) }, /* Sierra Wireless MC8781 */
  229. { USB_DEVICE(0x1199, 0x6838) }, /* Sierra Wireless MC8780 */
  230. { USB_DEVICE(0x1199, 0x6839) }, /* Sierra Wireless MC8781 */
  231. { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */
  232. { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */
  233. /* Sierra Wireless MC8790, MC8791, MC8792 Composite */
  234. { USB_DEVICE(0x1199, 0x683C) },
  235. { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8791 Composite */
  236. /* Sierra Wireless MC8790, MC8791, MC8792 */
  237. { USB_DEVICE(0x1199, 0x683E) },
  238. { USB_DEVICE(0x1199, 0x6850) }, /* Sierra Wireless AirCard 880 */
  239. { USB_DEVICE(0x1199, 0x6851) }, /* Sierra Wireless AirCard 881 */
  240. { USB_DEVICE(0x1199, 0x6852) }, /* Sierra Wireless AirCard 880 E */
  241. { USB_DEVICE(0x1199, 0x6853) }, /* Sierra Wireless AirCard 881 E */
  242. { USB_DEVICE(0x1199, 0x6855) }, /* Sierra Wireless AirCard 880 U */
  243. { USB_DEVICE(0x1199, 0x6856) }, /* Sierra Wireless AirCard 881 U */
  244. { USB_DEVICE(0x1199, 0x6859) }, /* Sierra Wireless AirCard 885 E */
  245. { USB_DEVICE(0x1199, 0x685A) }, /* Sierra Wireless AirCard 885 E */
  246. /* Sierra Wireless C885 */
  247. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6880, 0xFF, 0xFF, 0xFF)},
  248. /* Sierra Wireless C888, Air Card 501, USB 303, USB 304 */
  249. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)},
  250. /* Sierra Wireless C22/C33 */
  251. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)},
  252. /* Sierra Wireless HSPA Non-Composite Device */
  253. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
  254. { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */
  255. { USB_DEVICE(0x1199, 0x68A2), /* Sierra Wireless MC77xx in QMI mode */
  256. .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
  257. },
  258. /* Sierra Wireless Direct IP modems */
  259. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68A3, 0xFF, 0xFF, 0xFF),
  260. .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
  261. },
  262. { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF),
  263. .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
  264. },
  265. { USB_DEVICE(0x1199, 0x68AB) }, /* Sierra Wireless AR8550 */
  266. /* AT&T Direct IP LTE modems */
  267. { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF),
  268. .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
  269. },
  270. /* Airprime/Sierra Wireless Direct IP modems */
  271. { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68A3, 0xFF, 0xFF, 0xFF),
  272. .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
  273. },
  274. { }
  275. };
  276. MODULE_DEVICE_TABLE(usb, id_table);
  277. struct sierra_port_private {
  278. spinlock_t lock; /* lock the structure */
  279. int outstanding_urbs; /* number of out urbs in flight */
  280. struct usb_anchor active;
  281. struct usb_anchor delayed;
  282. int num_out_urbs;
  283. int num_in_urbs;
  284. /* Input endpoints and buffers for this port */
  285. struct urb *in_urbs[N_IN_URB_HM];
  286. /* Settings for the port */
  287. int rts_state; /* Handshaking pins (outputs) */
  288. int dtr_state;
  289. int cts_state; /* Handshaking pins (inputs) */
  290. int dsr_state;
  291. int dcd_state;
  292. int ri_state;
  293. unsigned int opened:1;
  294. };
  295. static int sierra_send_setup(struct usb_serial_port *port)
  296. {
  297. struct usb_serial *serial = port->serial;
  298. struct sierra_port_private *portdata;
  299. __u16 interface = 0;
  300. int val = 0;
  301. int do_send = 0;
  302. int retval;
  303. dev_dbg(&port->dev, "%s\n", __func__);
  304. portdata = usb_get_serial_port_data(port);
  305. if (portdata->dtr_state)
  306. val |= 0x01;
  307. if (portdata->rts_state)
  308. val |= 0x02;
  309. /* If composite device then properly report interface */
  310. if (serial->num_ports == 1) {
  311. interface = sierra_calc_interface(serial);
  312. /* Control message is sent only to interfaces with
  313. * interrupt_in endpoints
  314. */
  315. if (port->interrupt_in_urb) {
  316. /* send control message */
  317. do_send = 1;
  318. }
  319. }
  320. /* Otherwise the need to do non-composite mapping */
  321. else {
  322. if (port->bulk_out_endpointAddress == 2)
  323. interface = 0;
  324. else if (port->bulk_out_endpointAddress == 4)
  325. interface = 1;
  326. else if (port->bulk_out_endpointAddress == 5)
  327. interface = 2;
  328. do_send = 1;
  329. }
  330. if (!do_send)
  331. return 0;
  332. retval = usb_autopm_get_interface(serial->interface);
  333. if (retval < 0)
  334. return retval;
  335. retval = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
  336. 0x22, 0x21, val, interface, NULL, 0, USB_CTRL_SET_TIMEOUT);
  337. usb_autopm_put_interface(serial->interface);
  338. return retval;
  339. }
  340. static void sierra_set_termios(struct tty_struct *tty,
  341. struct usb_serial_port *port, struct ktermios *old_termios)
  342. {
  343. dev_dbg(&port->dev, "%s\n", __func__);
  344. tty_termios_copy_hw(tty->termios, old_termios);
  345. sierra_send_setup(port);
  346. }
  347. static int sierra_tiocmget(struct tty_struct *tty)
  348. {
  349. struct usb_serial_port *port = tty->driver_data;
  350. unsigned int value;
  351. struct sierra_port_private *portdata;
  352. dev_dbg(&port->dev, "%s\n", __func__);
  353. portdata = usb_get_serial_port_data(port);
  354. value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
  355. ((portdata->dtr_state) ? TIOCM_DTR : 0) |
  356. ((portdata->cts_state) ? TIOCM_CTS : 0) |
  357. ((portdata->dsr_state) ? TIOCM_DSR : 0) |
  358. ((portdata->dcd_state) ? TIOCM_CAR : 0) |
  359. ((portdata->ri_state) ? TIOCM_RNG : 0);
  360. return value;
  361. }
  362. static int sierra_tiocmset(struct tty_struct *tty,
  363. unsigned int set, unsigned int clear)
  364. {
  365. struct usb_serial_port *port = tty->driver_data;
  366. struct sierra_port_private *portdata;
  367. portdata = usb_get_serial_port_data(port);
  368. if (set & TIOCM_RTS)
  369. portdata->rts_state = 1;
  370. if (set & TIOCM_DTR)
  371. portdata->dtr_state = 1;
  372. if (clear & TIOCM_RTS)
  373. portdata->rts_state = 0;
  374. if (clear & TIOCM_DTR)
  375. portdata->dtr_state = 0;
  376. return sierra_send_setup(port);
  377. }
  378. static void sierra_release_urb(struct urb *urb)
  379. {
  380. struct usb_serial_port *port;
  381. if (urb) {
  382. port = urb->context;
  383. dev_dbg(&port->dev, "%s: %pK\n", __func__, urb);
  384. kfree(urb->transfer_buffer);
  385. usb_free_urb(urb);
  386. }
  387. }
  388. static void sierra_outdat_callback(struct urb *urb)
  389. {
  390. struct usb_serial_port *port = urb->context;
  391. struct sierra_port_private *portdata = usb_get_serial_port_data(port);
  392. struct sierra_intf_private *intfdata;
  393. int status = urb->status;
  394. dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
  395. intfdata = port->serial->private;
  396. /* free up the transfer buffer, as usb_free_urb() does not do this */
  397. kfree(urb->transfer_buffer);
  398. usb_autopm_put_interface_async(port->serial->interface);
  399. if (status)
  400. dev_dbg(&port->dev, "%s - nonzero write bulk status "
  401. "received: %d\n", __func__, status);
  402. spin_lock(&portdata->lock);
  403. --portdata->outstanding_urbs;
  404. spin_unlock(&portdata->lock);
  405. spin_lock(&intfdata->susp_lock);
  406. --intfdata->in_flight;
  407. spin_unlock(&intfdata->susp_lock);
  408. usb_serial_port_softint(port);
  409. }
  410. /* Write */
  411. static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
  412. const unsigned char *buf, int count)
  413. {
  414. struct sierra_port_private *portdata;
  415. struct sierra_intf_private *intfdata;
  416. struct usb_serial *serial = port->serial;
  417. unsigned long flags;
  418. unsigned char *buffer;
  419. struct urb *urb;
  420. size_t writesize = min((size_t)count, (size_t)MAX_TRANSFER);
  421. int retval = 0;
  422. /* verify that we actually have some data to write */
  423. if (count == 0)
  424. return 0;
  425. portdata = usb_get_serial_port_data(port);
  426. intfdata = serial->private;
  427. dev_dbg(&port->dev, "%s: write (%zd bytes)\n", __func__, writesize);
  428. spin_lock_irqsave(&portdata->lock, flags);
  429. dev_dbg(&port->dev, "%s - outstanding_urbs: %d\n", __func__,
  430. portdata->outstanding_urbs);
  431. if (portdata->outstanding_urbs > portdata->num_out_urbs) {
  432. spin_unlock_irqrestore(&portdata->lock, flags);
  433. dev_dbg(&port->dev, "%s - write limit hit\n", __func__);
  434. return 0;
  435. }
  436. portdata->outstanding_urbs++;
  437. dev_dbg(&port->dev, "%s - 1, outstanding_urbs: %d\n", __func__,
  438. portdata->outstanding_urbs);
  439. spin_unlock_irqrestore(&portdata->lock, flags);
  440. retval = usb_autopm_get_interface_async(serial->interface);
  441. if (retval < 0) {
  442. spin_lock_irqsave(&portdata->lock, flags);
  443. portdata->outstanding_urbs--;
  444. spin_unlock_irqrestore(&portdata->lock, flags);
  445. goto error_simple;
  446. }
  447. buffer = kmalloc(writesize, GFP_ATOMIC);
  448. if (!buffer) {
  449. dev_err(&port->dev, "out of memory\n");
  450. retval = -ENOMEM;
  451. goto error_no_buffer;
  452. }
  453. urb = usb_alloc_urb(0, GFP_ATOMIC);
  454. if (!urb) {
  455. dev_err(&port->dev, "no more free urbs\n");
  456. retval = -ENOMEM;
  457. goto error_no_urb;
  458. }
  459. memcpy(buffer, buf, writesize);
  460. usb_serial_debug_data(debug, &port->dev, __func__, writesize, buffer);
  461. usb_fill_bulk_urb(urb, serial->dev,
  462. usb_sndbulkpipe(serial->dev,
  463. port->bulk_out_endpointAddress),
  464. buffer, writesize, sierra_outdat_callback, port);
  465. /* Handle the need to send a zero length packet */
  466. urb->transfer_flags |= URB_ZERO_PACKET;
  467. spin_lock_irqsave(&intfdata->susp_lock, flags);
  468. if (intfdata->suspended) {
  469. usb_anchor_urb(urb, &portdata->delayed);
  470. spin_unlock_irqrestore(&intfdata->susp_lock, flags);
  471. goto skip_power;
  472. } else {
  473. usb_anchor_urb(urb, &portdata->active);
  474. }
  475. /* send it down the pipe */
  476. retval = usb_submit_urb(urb, GFP_ATOMIC);
  477. if (retval) {
  478. usb_unanchor_urb(urb);
  479. spin_unlock_irqrestore(&intfdata->susp_lock, flags);
  480. dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed "
  481. "with status = %d\n", __func__, retval);
  482. goto error;
  483. } else {
  484. intfdata->in_flight++;
  485. spin_unlock_irqrestore(&intfdata->susp_lock, flags);
  486. }
  487. skip_power:
  488. /* we are done with this urb, so let the host driver
  489. * really free it when it is finished with it */
  490. usb_free_urb(urb);
  491. return writesize;
  492. error:
  493. usb_free_urb(urb);
  494. error_no_urb:
  495. kfree(buffer);
  496. error_no_buffer:
  497. spin_lock_irqsave(&portdata->lock, flags);
  498. --portdata->outstanding_urbs;
  499. dev_dbg(&port->dev, "%s - 2. outstanding_urbs: %d\n", __func__,
  500. portdata->outstanding_urbs);
  501. spin_unlock_irqrestore(&portdata->lock, flags);
  502. usb_autopm_put_interface_async(serial->interface);
  503. error_simple:
  504. return retval;
  505. }
  506. static void sierra_indat_callback(struct urb *urb)
  507. {
  508. int err;
  509. int endpoint;
  510. struct usb_serial_port *port;
  511. struct tty_struct *tty;
  512. unsigned char *data = urb->transfer_buffer;
  513. int status = urb->status;
  514. endpoint = usb_pipeendpoint(urb->pipe);
  515. port = urb->context;
  516. dev_dbg(&port->dev, "%s: %pK\n", __func__, urb);
  517. if (status) {
  518. dev_dbg(&port->dev, "%s: nonzero status: %d on"
  519. " endpoint %02x\n", __func__, status, endpoint);
  520. } else {
  521. if (urb->actual_length) {
  522. tty = tty_port_tty_get(&port->port);
  523. if (tty) {
  524. tty_insert_flip_string(tty, data,
  525. urb->actual_length);
  526. tty_flip_buffer_push(tty);
  527. tty_kref_put(tty);
  528. usb_serial_debug_data(debug, &port->dev,
  529. __func__, urb->actual_length, data);
  530. }
  531. } else {
  532. dev_dbg(&port->dev, "%s: empty read urb"
  533. " received\n", __func__);
  534. }
  535. }
  536. /* Resubmit urb so we continue receiving */
  537. if (status != -ESHUTDOWN && status != -EPERM) {
  538. usb_mark_last_busy(port->serial->dev);
  539. err = usb_submit_urb(urb, GFP_ATOMIC);
  540. if (err && err != -EPERM)
  541. dev_err(&port->dev, "resubmit read urb failed."
  542. "(%d)\n", err);
  543. }
  544. }
  545. static void sierra_instat_callback(struct urb *urb)
  546. {
  547. int err;
  548. int status = urb->status;
  549. struct usb_serial_port *port = urb->context;
  550. struct sierra_port_private *portdata = usb_get_serial_port_data(port);
  551. struct usb_serial *serial = port->serial;
  552. dev_dbg(&port->dev, "%s: urb %pK port %pK has data %pK\n", __func__,
  553. urb, port, portdata);
  554. if (status == 0) {
  555. struct usb_ctrlrequest *req_pkt =
  556. (struct usb_ctrlrequest *)urb->transfer_buffer;
  557. if (!req_pkt) {
  558. dev_dbg(&port->dev, "%s: NULL req_pkt\n",
  559. __func__);
  560. return;
  561. }
  562. if ((req_pkt->bRequestType == 0xA1) &&
  563. (req_pkt->bRequest == 0x20)) {
  564. int old_dcd_state;
  565. unsigned char signals = *((unsigned char *)
  566. urb->transfer_buffer +
  567. sizeof(struct usb_ctrlrequest));
  568. struct tty_struct *tty;
  569. dev_dbg(&port->dev, "%s: signal x%x\n", __func__,
  570. signals);
  571. old_dcd_state = portdata->dcd_state;
  572. portdata->cts_state = 1;
  573. portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
  574. portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
  575. portdata->ri_state = ((signals & 0x08) ? 1 : 0);
  576. tty = tty_port_tty_get(&port->port);
  577. if (tty && !C_CLOCAL(tty) &&
  578. old_dcd_state && !portdata->dcd_state)
  579. tty_hangup(tty);
  580. tty_kref_put(tty);
  581. } else {
  582. dev_dbg(&port->dev, "%s: type %x req %x\n",
  583. __func__, req_pkt->bRequestType,
  584. req_pkt->bRequest);
  585. }
  586. } else
  587. dev_dbg(&port->dev, "%s: error %d\n", __func__, status);
  588. /* Resubmit urb so we continue receiving IRQ data */
  589. if (status != -ESHUTDOWN && status != -ENOENT) {
  590. usb_mark_last_busy(serial->dev);
  591. err = usb_submit_urb(urb, GFP_ATOMIC);
  592. if (err && err != -EPERM)
  593. dev_err(&port->dev, "%s: resubmit intr urb "
  594. "failed. (%d)\n", __func__, err);
  595. }
  596. }
  597. static int sierra_write_room(struct tty_struct *tty)
  598. {
  599. struct usb_serial_port *port = tty->driver_data;
  600. struct sierra_port_private *portdata = usb_get_serial_port_data(port);
  601. unsigned long flags;
  602. dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
  603. /* try to give a good number back based on if we have any free urbs at
  604. * this point in time */
  605. spin_lock_irqsave(&portdata->lock, flags);
  606. if (portdata->outstanding_urbs > (portdata->num_out_urbs * 2) / 3) {
  607. spin_unlock_irqrestore(&portdata->lock, flags);
  608. dev_dbg(&port->dev, "%s - write limit hit\n", __func__);
  609. return 0;
  610. }
  611. spin_unlock_irqrestore(&portdata->lock, flags);
  612. return 2048;
  613. }
  614. static void sierra_stop_rx_urbs(struct usb_serial_port *port)
  615. {
  616. int i;
  617. struct sierra_port_private *portdata = usb_get_serial_port_data(port);
  618. for (i = 0; i < portdata->num_in_urbs; i++)
  619. usb_kill_urb(portdata->in_urbs[i]);
  620. usb_kill_urb(port->interrupt_in_urb);
  621. }
  622. static int sierra_submit_rx_urbs(struct usb_serial_port *port, gfp_t mem_flags)
  623. {
  624. int ok_cnt;
  625. int err = -EINVAL;
  626. int i;
  627. struct urb *urb;
  628. struct sierra_port_private *portdata = usb_get_serial_port_data(port);
  629. ok_cnt = 0;
  630. for (i = 0; i < portdata->num_in_urbs; i++) {
  631. urb = portdata->in_urbs[i];
  632. if (!urb)
  633. continue;
  634. err = usb_submit_urb(urb, mem_flags);
  635. if (err) {
  636. dev_err(&port->dev, "%s: submit urb failed: %d\n",
  637. __func__, err);
  638. } else {
  639. ok_cnt++;
  640. }
  641. }
  642. if (ok_cnt && port->interrupt_in_urb) {
  643. err = usb_submit_urb(port->interrupt_in_urb, mem_flags);
  644. if (err) {
  645. dev_err(&port->dev, "%s: submit intr urb failed: %d\n",
  646. __func__, err);
  647. }
  648. }
  649. if (ok_cnt > 0) /* at least one rx urb submitted */
  650. return 0;
  651. else
  652. return err;
  653. }
  654. static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
  655. int dir, void *ctx, int len,
  656. gfp_t mem_flags,
  657. usb_complete_t callback)
  658. {
  659. struct urb *urb;
  660. u8 *buf;
  661. if (endpoint == -1)
  662. return NULL;
  663. urb = usb_alloc_urb(0, mem_flags);
  664. if (urb == NULL) {
  665. dev_dbg(&serial->dev->dev, "%s: alloc for endpoint %d failed\n",
  666. __func__, endpoint);
  667. return NULL;
  668. }
  669. buf = kmalloc(len, mem_flags);
  670. if (buf) {
  671. /* Fill URB using supplied data */
  672. usb_fill_bulk_urb(urb, serial->dev,
  673. usb_sndbulkpipe(serial->dev, endpoint) | dir,
  674. buf, len, callback, ctx);
  675. /* debug */
  676. dev_dbg(&serial->dev->dev, "%s %c u : %pK d:%pK\n", __func__,
  677. dir == USB_DIR_IN ? 'i' : 'o', urb, buf);
  678. } else {
  679. dev_dbg(&serial->dev->dev, "%s %c u:%pK d:%pK\n", __func__,
  680. dir == USB_DIR_IN ? 'i' : 'o', urb, buf);
  681. sierra_release_urb(urb);
  682. urb = NULL;
  683. }
  684. return urb;
  685. }
  686. static void sierra_close(struct usb_serial_port *port)
  687. {
  688. int i;
  689. struct usb_serial *serial = port->serial;
  690. struct sierra_port_private *portdata;
  691. struct sierra_intf_private *intfdata = port->serial->private;
  692. struct urb *urb;
  693. dev_dbg(&port->dev, "%s\n", __func__);
  694. portdata = usb_get_serial_port_data(port);
  695. portdata->rts_state = 0;
  696. portdata->dtr_state = 0;
  697. if (serial->dev) {
  698. mutex_lock(&serial->disc_mutex);
  699. if (!serial->disconnected) {
  700. /* odd error handling due to pm counters */
  701. if (!usb_autopm_get_interface(serial->interface))
  702. sierra_send_setup(port);
  703. else
  704. usb_autopm_get_interface_no_resume(serial->interface);
  705. }
  706. mutex_unlock(&serial->disc_mutex);
  707. spin_lock_irq(&intfdata->susp_lock);
  708. portdata->opened = 0;
  709. if (--intfdata->open_ports == 0)
  710. serial->interface->needs_remote_wakeup = 0;
  711. spin_unlock_irq(&intfdata->susp_lock);
  712. for (;;) {
  713. urb = usb_get_from_anchor(&portdata->delayed);
  714. if (!urb)
  715. break;
  716. kfree(urb->transfer_buffer);
  717. usb_free_urb(urb);
  718. usb_autopm_put_interface_async(serial->interface);
  719. spin_lock(&portdata->lock);
  720. portdata->outstanding_urbs--;
  721. spin_unlock(&portdata->lock);
  722. }
  723. /* Stop reading urbs */
  724. sierra_stop_rx_urbs(port);
  725. /* .. and release them */
  726. for (i = 0; i < portdata->num_in_urbs; i++) {
  727. sierra_release_urb(portdata->in_urbs[i]);
  728. portdata->in_urbs[i] = NULL;
  729. }
  730. }
  731. }
  732. static int sierra_open(struct tty_struct *tty, struct usb_serial_port *port)
  733. {
  734. struct sierra_port_private *portdata;
  735. struct usb_serial *serial = port->serial;
  736. struct sierra_intf_private *intfdata = serial->private;
  737. int i;
  738. int err;
  739. int endpoint;
  740. struct urb *urb;
  741. portdata = usb_get_serial_port_data(port);
  742. dev_dbg(&port->dev, "%s\n", __func__);
  743. /* Set some sane defaults */
  744. portdata->rts_state = 1;
  745. portdata->dtr_state = 1;
  746. endpoint = port->bulk_in_endpointAddress;
  747. for (i = 0; i < portdata->num_in_urbs; i++) {
  748. urb = sierra_setup_urb(serial, endpoint, USB_DIR_IN, port,
  749. IN_BUFLEN, GFP_KERNEL,
  750. sierra_indat_callback);
  751. portdata->in_urbs[i] = urb;
  752. }
  753. /* clear halt condition */
  754. usb_clear_halt(serial->dev,
  755. usb_sndbulkpipe(serial->dev, endpoint) | USB_DIR_IN);
  756. err = sierra_submit_rx_urbs(port, GFP_KERNEL);
  757. if (err)
  758. goto err_submit;
  759. sierra_send_setup(port);
  760. spin_lock_irq(&intfdata->susp_lock);
  761. portdata->opened = 1;
  762. if (++intfdata->open_ports == 1)
  763. serial->interface->needs_remote_wakeup = 1;
  764. spin_unlock_irq(&intfdata->susp_lock);
  765. usb_autopm_put_interface(serial->interface);
  766. return 0;
  767. err_submit:
  768. sierra_stop_rx_urbs(port);
  769. for (i = 0; i < portdata->num_in_urbs; i++) {
  770. sierra_release_urb(portdata->in_urbs[i]);
  771. portdata->in_urbs[i] = NULL;
  772. }
  773. return err;
  774. }
  775. static void sierra_dtr_rts(struct usb_serial_port *port, int on)
  776. {
  777. struct sierra_port_private *portdata;
  778. portdata = usb_get_serial_port_data(port);
  779. portdata->rts_state = on;
  780. portdata->dtr_state = on;
  781. sierra_send_setup(port);
  782. }
  783. static int sierra_startup(struct usb_serial *serial)
  784. {
  785. struct usb_serial_port *port;
  786. struct sierra_intf_private *intfdata;
  787. struct sierra_port_private *portdata;
  788. struct sierra_iface_info *himemoryp = NULL;
  789. int i;
  790. u8 ifnum;
  791. dev_dbg(&serial->dev->dev, "%s\n", __func__);
  792. intfdata = kzalloc(sizeof(*intfdata), GFP_KERNEL);
  793. if (!intfdata)
  794. return -ENOMEM;
  795. spin_lock_init(&intfdata->susp_lock);
  796. usb_set_serial_data(serial, intfdata);
  797. /* Set Device mode to D0 */
  798. sierra_set_power_state(serial->dev, 0x0000);
  799. /* Check NMEA and set */
  800. if (nmea)
  801. sierra_vsc_set_nmea(serial->dev, 1);
  802. /* Now setup per port private data */
  803. for (i = 0; i < serial->num_ports; i++) {
  804. port = serial->port[i];
  805. portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
  806. if (!portdata) {
  807. dev_dbg(&port->dev, "%s: kmalloc for "
  808. "sierra_port_private (%d) failed!\n",
  809. __func__, i);
  810. goto err;
  811. }
  812. spin_lock_init(&portdata->lock);
  813. init_usb_anchor(&portdata->active);
  814. init_usb_anchor(&portdata->delayed);
  815. ifnum = i;
  816. /* Assume low memory requirements */
  817. portdata->num_out_urbs = N_OUT_URB;
  818. portdata->num_in_urbs = N_IN_URB;
  819. /* Determine actual memory requirements */
  820. if (serial->num_ports == 1) {
  821. /* Get interface number for composite device */
  822. ifnum = sierra_calc_interface(serial);
  823. himemoryp =
  824. (struct sierra_iface_info *)&typeB_interface_list;
  825. if (is_himemory(ifnum, himemoryp)) {
  826. portdata->num_out_urbs = N_OUT_URB_HM;
  827. portdata->num_in_urbs = N_IN_URB_HM;
  828. }
  829. }
  830. else {
  831. himemoryp =
  832. (struct sierra_iface_info *)&typeA_interface_list;
  833. if (is_himemory(i, himemoryp)) {
  834. portdata->num_out_urbs = N_OUT_URB_HM;
  835. portdata->num_in_urbs = N_IN_URB_HM;
  836. }
  837. }
  838. dev_dbg(&serial->dev->dev,
  839. "Memory usage (urbs) interface #%d, in=%d, out=%d\n",
  840. ifnum,portdata->num_in_urbs, portdata->num_out_urbs );
  841. /* Set the port private data pointer */
  842. usb_set_serial_port_data(port, portdata);
  843. }
  844. return 0;
  845. err:
  846. for (--i; i >= 0; --i) {
  847. portdata = usb_get_serial_port_data(serial->port[i]);
  848. kfree(portdata);
  849. }
  850. kfree(intfdata);
  851. return -ENOMEM;
  852. }
  853. static void sierra_release(struct usb_serial *serial)
  854. {
  855. int i;
  856. struct usb_serial_port *port;
  857. struct sierra_port_private *portdata;
  858. dev_dbg(&serial->dev->dev, "%s\n", __func__);
  859. for (i = 0; i < serial->num_ports; ++i) {
  860. port = serial->port[i];
  861. if (!port)
  862. continue;
  863. portdata = usb_get_serial_port_data(port);
  864. if (!portdata)
  865. continue;
  866. usb_set_serial_port_data(port, NULL);
  867. kfree(portdata);
  868. }
  869. kfree(serial->private);
  870. }
  871. #ifdef CONFIG_PM
  872. static void stop_read_write_urbs(struct usb_serial *serial)
  873. {
  874. int i;
  875. struct usb_serial_port *port;
  876. struct sierra_port_private *portdata;
  877. /* Stop reading/writing urbs */
  878. for (i = 0; i < serial->num_ports; ++i) {
  879. port = serial->port[i];
  880. portdata = usb_get_serial_port_data(port);
  881. if (!portdata)
  882. continue;
  883. sierra_stop_rx_urbs(port);
  884. usb_kill_anchored_urbs(&portdata->active);
  885. }
  886. }
  887. static int sierra_suspend(struct usb_serial *serial, pm_message_t message)
  888. {
  889. struct sierra_intf_private *intfdata;
  890. int b;
  891. if (PMSG_IS_AUTO(message)) {
  892. intfdata = serial->private;
  893. spin_lock_irq(&intfdata->susp_lock);
  894. b = intfdata->in_flight;
  895. if (b) {
  896. spin_unlock_irq(&intfdata->susp_lock);
  897. return -EBUSY;
  898. } else {
  899. intfdata->suspended = 1;
  900. spin_unlock_irq(&intfdata->susp_lock);
  901. }
  902. }
  903. stop_read_write_urbs(serial);
  904. return 0;
  905. }
  906. static int sierra_resume(struct usb_serial *serial)
  907. {
  908. struct usb_serial_port *port;
  909. struct sierra_intf_private *intfdata = serial->private;
  910. struct sierra_port_private *portdata;
  911. struct urb *urb;
  912. int ec = 0;
  913. int i, err;
  914. spin_lock_irq(&intfdata->susp_lock);
  915. for (i = 0; i < serial->num_ports; i++) {
  916. port = serial->port[i];
  917. portdata = usb_get_serial_port_data(port);
  918. if (!portdata)
  919. continue;
  920. while ((urb = usb_get_from_anchor(&portdata->delayed))) {
  921. usb_anchor_urb(urb, &portdata->active);
  922. intfdata->in_flight++;
  923. err = usb_submit_urb(urb, GFP_ATOMIC);
  924. if (err < 0) {
  925. intfdata->in_flight--;
  926. usb_unanchor_urb(urb);
  927. kfree(urb->transfer_buffer);
  928. usb_free_urb(urb);
  929. spin_lock(&portdata->lock);
  930. portdata->outstanding_urbs--;
  931. spin_unlock(&portdata->lock);
  932. continue;
  933. }
  934. }
  935. if (portdata->opened) {
  936. err = sierra_submit_rx_urbs(port, GFP_ATOMIC);
  937. if (err)
  938. ec++;
  939. }
  940. }
  941. intfdata->suspended = 0;
  942. spin_unlock_irq(&intfdata->susp_lock);
  943. return ec ? -EIO : 0;
  944. }
  945. static int sierra_reset_resume(struct usb_interface *intf)
  946. {
  947. struct usb_serial *serial = usb_get_intfdata(intf);
  948. dev_err(&serial->dev->dev, "%s\n", __func__);
  949. return usb_serial_resume(intf);
  950. }
  951. #else
  952. #define sierra_suspend NULL
  953. #define sierra_resume NULL
  954. #define sierra_reset_resume NULL
  955. #endif
  956. static struct usb_driver sierra_driver = {
  957. .name = "sierra",
  958. .probe = usb_serial_probe,
  959. .disconnect = usb_serial_disconnect,
  960. .suspend = usb_serial_suspend,
  961. .resume = usb_serial_resume,
  962. .reset_resume = sierra_reset_resume,
  963. .id_table = id_table,
  964. .supports_autosuspend = 1,
  965. };
  966. static struct usb_serial_driver sierra_device = {
  967. .driver = {
  968. .owner = THIS_MODULE,
  969. .name = "sierra",
  970. },
  971. .description = "Sierra USB modem",
  972. .id_table = id_table,
  973. .calc_num_ports = sierra_calc_num_ports,
  974. .probe = sierra_probe,
  975. .open = sierra_open,
  976. .close = sierra_close,
  977. .dtr_rts = sierra_dtr_rts,
  978. .write = sierra_write,
  979. .write_room = sierra_write_room,
  980. .set_termios = sierra_set_termios,
  981. .tiocmget = sierra_tiocmget,
  982. .tiocmset = sierra_tiocmset,
  983. .attach = sierra_startup,
  984. .release = sierra_release,
  985. .suspend = sierra_suspend,
  986. .resume = sierra_resume,
  987. .read_int_callback = sierra_instat_callback,
  988. };
  989. static struct usb_serial_driver * const serial_drivers[] = {
  990. &sierra_device, NULL
  991. };
  992. module_usb_serial_driver(sierra_driver, serial_drivers);
  993. MODULE_AUTHOR(DRIVER_AUTHOR);
  994. MODULE_DESCRIPTION(DRIVER_DESC);
  995. MODULE_VERSION(DRIVER_VERSION);
  996. MODULE_LICENSE("GPL");
  997. module_param(nmea, bool, S_IRUGO | S_IWUSR);
  998. MODULE_PARM_DESC(nmea, "NMEA streaming");
  999. module_param(debug, bool, S_IRUGO | S_IWUSR);
  1000. MODULE_PARM_DESC(debug, "Debug messages");