sierra.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /*
  2. USB Driver for Sierra Wireless
  3. Copyright (C) 2006 Kevin Lloyd <linux@sierrawireless.com>
  4. IMPORTANT DISCLAIMER: This driver is not commercially supported by
  5. Sierra Wireless. Use at your own risk.
  6. This driver is free software; you can redistribute it and/or modify
  7. it under the terms of Version 2 of the GNU General Public License as
  8. published by the Free Software Foundation.
  9. Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
  10. Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
  11. */
  12. #define DRIVER_VERSION "v.1.0.6"
  13. #define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
  14. #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
  15. #include <linux/kernel.h>
  16. #include <linux/jiffies.h>
  17. #include <linux/errno.h>
  18. #include <linux/tty.h>
  19. #include <linux/tty_flip.h>
  20. #include <linux/module.h>
  21. #include <linux/usb.h>
  22. #include <linux/usb/serial.h>
  23. static struct usb_device_id id_table [] = {
  24. { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
  25. { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
  26. { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
  27. { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
  28. { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
  29. { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
  30. { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
  31. { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
  32. { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
  33. { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
  34. { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
  35. { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
  36. { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
  37. { }
  38. };
  39. MODULE_DEVICE_TABLE(usb, id_table);
  40. static struct usb_device_id id_table_1port [] = {
  41. { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
  42. { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
  43. { }
  44. };
  45. static struct usb_device_id id_table_3port [] = {
  46. { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
  47. { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
  48. { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
  49. { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
  50. { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
  51. { USB_DEVICE(0x1199, 0x0021) }, /* Sierra Wireless AirCard 597E */
  52. { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
  53. { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
  54. { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
  55. { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
  56. { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
  57. { }
  58. };
  59. static struct usb_driver sierra_driver = {
  60. .name = "sierra",
  61. .probe = usb_serial_probe,
  62. .disconnect = usb_serial_disconnect,
  63. .id_table = id_table,
  64. .no_dynamic_id = 1,
  65. };
  66. static int debug;
  67. /* per port private data */
  68. #define N_IN_URB 4
  69. #define N_OUT_URB 4
  70. #define IN_BUFLEN 4096
  71. #define OUT_BUFLEN 128
  72. struct sierra_port_private {
  73. /* Input endpoints and buffer for this port */
  74. struct urb *in_urbs[N_IN_URB];
  75. char in_buffer[N_IN_URB][IN_BUFLEN];
  76. /* Output endpoints and buffer for this port */
  77. struct urb *out_urbs[N_OUT_URB];
  78. char out_buffer[N_OUT_URB][OUT_BUFLEN];
  79. /* Settings for the port */
  80. int rts_state; /* Handshaking pins (outputs) */
  81. int dtr_state;
  82. int cts_state; /* Handshaking pins (inputs) */
  83. int dsr_state;
  84. int dcd_state;
  85. int ri_state;
  86. unsigned long tx_start_time[N_OUT_URB];
  87. };
  88. static int sierra_send_setup(struct usb_serial_port *port)
  89. {
  90. struct usb_serial *serial = port->serial;
  91. struct sierra_port_private *portdata;
  92. dbg("%s", __FUNCTION__);
  93. portdata = usb_get_serial_port_data(port);
  94. if (port->tty) {
  95. int val = 0;
  96. if (portdata->dtr_state)
  97. val |= 0x01;
  98. if (portdata->rts_state)
  99. val |= 0x02;
  100. return usb_control_msg(serial->dev,
  101. usb_rcvctrlpipe(serial->dev, 0),
  102. 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
  103. }
  104. return 0;
  105. }
  106. static void sierra_rx_throttle(struct usb_serial_port *port)
  107. {
  108. dbg("%s", __FUNCTION__);
  109. }
  110. static void sierra_rx_unthrottle(struct usb_serial_port *port)
  111. {
  112. dbg("%s", __FUNCTION__);
  113. }
  114. static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
  115. {
  116. /* Unfortunately, I don't know how to send a break */
  117. dbg("%s", __FUNCTION__);
  118. }
  119. static void sierra_set_termios(struct usb_serial_port *port,
  120. struct ktermios *old_termios)
  121. {
  122. dbg("%s", __FUNCTION__);
  123. sierra_send_setup(port);
  124. }
  125. static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
  126. {
  127. unsigned int value;
  128. struct sierra_port_private *portdata;
  129. portdata = usb_get_serial_port_data(port);
  130. value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
  131. ((portdata->dtr_state) ? TIOCM_DTR : 0) |
  132. ((portdata->cts_state) ? TIOCM_CTS : 0) |
  133. ((portdata->dsr_state) ? TIOCM_DSR : 0) |
  134. ((portdata->dcd_state) ? TIOCM_CAR : 0) |
  135. ((portdata->ri_state) ? TIOCM_RNG : 0);
  136. return value;
  137. }
  138. static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
  139. unsigned int set, unsigned int clear)
  140. {
  141. struct sierra_port_private *portdata;
  142. portdata = usb_get_serial_port_data(port);
  143. if (set & TIOCM_RTS)
  144. portdata->rts_state = 1;
  145. if (set & TIOCM_DTR)
  146. portdata->dtr_state = 1;
  147. if (clear & TIOCM_RTS)
  148. portdata->rts_state = 0;
  149. if (clear & TIOCM_DTR)
  150. portdata->dtr_state = 0;
  151. return sierra_send_setup(port);
  152. }
  153. static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
  154. unsigned int cmd, unsigned long arg)
  155. {
  156. return -ENOIOCTLCMD;
  157. }
  158. /* Write */
  159. static int sierra_write(struct usb_serial_port *port,
  160. const unsigned char *buf, int count)
  161. {
  162. struct sierra_port_private *portdata;
  163. int i;
  164. int left, todo;
  165. struct urb *this_urb = NULL; /* spurious */
  166. int err;
  167. portdata = usb_get_serial_port_data(port);
  168. dbg("%s: write (%d chars)", __FUNCTION__, count);
  169. i = 0;
  170. left = count;
  171. for (i=0; left > 0 && i < N_OUT_URB; i++) {
  172. todo = left;
  173. if (todo > OUT_BUFLEN)
  174. todo = OUT_BUFLEN;
  175. this_urb = portdata->out_urbs[i];
  176. if (this_urb->status == -EINPROGRESS) {
  177. if (time_before(jiffies,
  178. portdata->tx_start_time[i] + 10 * HZ))
  179. continue;
  180. usb_unlink_urb(this_urb);
  181. continue;
  182. }
  183. if (this_urb->status != 0)
  184. dbg("usb_write %p failed (err=%d)",
  185. this_urb, this_urb->status);
  186. dbg("%s: endpoint %d buf %d", __FUNCTION__,
  187. usb_pipeendpoint(this_urb->pipe), i);
  188. /* send the data */
  189. memcpy (this_urb->transfer_buffer, buf, todo);
  190. this_urb->transfer_buffer_length = todo;
  191. this_urb->dev = port->serial->dev;
  192. err = usb_submit_urb(this_urb, GFP_ATOMIC);
  193. if (err) {
  194. dbg("usb_submit_urb %p (write bulk) failed "
  195. "(%d, has %d)", this_urb,
  196. err, this_urb->status);
  197. continue;
  198. }
  199. portdata->tx_start_time[i] = jiffies;
  200. buf += todo;
  201. left -= todo;
  202. }
  203. count -= left;
  204. dbg("%s: wrote (did %d)", __FUNCTION__, count);
  205. return count;
  206. }
  207. static void sierra_indat_callback(struct urb *urb)
  208. {
  209. int err;
  210. int endpoint;
  211. struct usb_serial_port *port;
  212. struct tty_struct *tty;
  213. unsigned char *data = urb->transfer_buffer;
  214. dbg("%s: %p", __FUNCTION__, urb);
  215. endpoint = usb_pipeendpoint(urb->pipe);
  216. port = (struct usb_serial_port *) urb->context;
  217. if (urb->status) {
  218. dbg("%s: nonzero status: %d on endpoint %02x.",
  219. __FUNCTION__, urb->status, endpoint);
  220. } else {
  221. tty = port->tty;
  222. if (urb->actual_length) {
  223. tty_buffer_request_room(tty, urb->actual_length);
  224. tty_insert_flip_string(tty, data, urb->actual_length);
  225. tty_flip_buffer_push(tty);
  226. } else {
  227. dbg("%s: empty read urb received", __FUNCTION__);
  228. }
  229. /* Resubmit urb so we continue receiving */
  230. if (port->open_count && urb->status != -ESHUTDOWN) {
  231. err = usb_submit_urb(urb, GFP_ATOMIC);
  232. if (err)
  233. printk(KERN_ERR "%s: resubmit read urb failed. "
  234. "(%d)", __FUNCTION__, err);
  235. }
  236. }
  237. return;
  238. }
  239. static void sierra_outdat_callback(struct urb *urb)
  240. {
  241. struct usb_serial_port *port;
  242. dbg("%s", __FUNCTION__);
  243. port = (struct usb_serial_port *) urb->context;
  244. usb_serial_port_softint(port);
  245. }
  246. static void sierra_instat_callback(struct urb *urb)
  247. {
  248. int err;
  249. struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
  250. struct sierra_port_private *portdata = usb_get_serial_port_data(port);
  251. struct usb_serial *serial = port->serial;
  252. dbg("%s", __FUNCTION__);
  253. dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata);
  254. if (urb->status == 0) {
  255. struct usb_ctrlrequest *req_pkt =
  256. (struct usb_ctrlrequest *)urb->transfer_buffer;
  257. if (!req_pkt) {
  258. dbg("%s: NULL req_pkt\n", __FUNCTION__);
  259. return;
  260. }
  261. if ((req_pkt->bRequestType == 0xA1) &&
  262. (req_pkt->bRequest == 0x20)) {
  263. int old_dcd_state;
  264. unsigned char signals = *((unsigned char *)
  265. urb->transfer_buffer +
  266. sizeof(struct usb_ctrlrequest));
  267. dbg("%s: signal x%x", __FUNCTION__, signals);
  268. old_dcd_state = portdata->dcd_state;
  269. portdata->cts_state = 1;
  270. portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
  271. portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
  272. portdata->ri_state = ((signals & 0x08) ? 1 : 0);
  273. if (port->tty && !C_CLOCAL(port->tty) &&
  274. old_dcd_state && !portdata->dcd_state)
  275. tty_hangup(port->tty);
  276. } else {
  277. dbg("%s: type %x req %x", __FUNCTION__,
  278. req_pkt->bRequestType,req_pkt->bRequest);
  279. }
  280. } else
  281. dbg("%s: error %d", __FUNCTION__, urb->status);
  282. /* Resubmit urb so we continue receiving IRQ data */
  283. if (urb->status != -ESHUTDOWN) {
  284. urb->dev = serial->dev;
  285. err = usb_submit_urb(urb, GFP_ATOMIC);
  286. if (err)
  287. dbg("%s: resubmit intr urb failed. (%d)",
  288. __FUNCTION__, err);
  289. }
  290. }
  291. static int sierra_write_room(struct usb_serial_port *port)
  292. {
  293. struct sierra_port_private *portdata;
  294. int i;
  295. int data_len = 0;
  296. struct urb *this_urb;
  297. portdata = usb_get_serial_port_data(port);
  298. for (i=0; i < N_OUT_URB; i++) {
  299. this_urb = portdata->out_urbs[i];
  300. if (this_urb && this_urb->status != -EINPROGRESS)
  301. data_len += OUT_BUFLEN;
  302. }
  303. dbg("%s: %d", __FUNCTION__, data_len);
  304. return data_len;
  305. }
  306. static int sierra_chars_in_buffer(struct usb_serial_port *port)
  307. {
  308. struct sierra_port_private *portdata;
  309. int i;
  310. int data_len = 0;
  311. struct urb *this_urb;
  312. portdata = usb_get_serial_port_data(port);
  313. for (i=0; i < N_OUT_URB; i++) {
  314. this_urb = portdata->out_urbs[i];
  315. if (this_urb && this_urb->status == -EINPROGRESS)
  316. data_len += this_urb->transfer_buffer_length;
  317. }
  318. dbg("%s: %d", __FUNCTION__, data_len);
  319. return data_len;
  320. }
  321. static int sierra_open(struct usb_serial_port *port, struct file *filp)
  322. {
  323. struct sierra_port_private *portdata;
  324. struct usb_serial *serial = port->serial;
  325. int i, err;
  326. struct urb *urb;
  327. int result;
  328. __u16 set_mode_dzero = 0x0000;
  329. portdata = usb_get_serial_port_data(port);
  330. dbg("%s", __FUNCTION__);
  331. /* Set some sane defaults */
  332. portdata->rts_state = 1;
  333. portdata->dtr_state = 1;
  334. /* Reset low level data toggle and start reading from endpoints */
  335. for (i = 0; i < N_IN_URB; i++) {
  336. urb = portdata->in_urbs[i];
  337. if (! urb)
  338. continue;
  339. if (urb->dev != serial->dev) {
  340. dbg("%s: dev %p != %p", __FUNCTION__,
  341. urb->dev, serial->dev);
  342. continue;
  343. }
  344. /*
  345. * make sure endpoint data toggle is synchronized with the
  346. * device
  347. */
  348. usb_clear_halt(urb->dev, urb->pipe);
  349. err = usb_submit_urb(urb, GFP_KERNEL);
  350. if (err) {
  351. dbg("%s: submit urb %d failed (%d) %d",
  352. __FUNCTION__, i, err,
  353. urb->transfer_buffer_length);
  354. }
  355. }
  356. /* Reset low level data toggle on out endpoints */
  357. for (i = 0; i < N_OUT_URB; i++) {
  358. urb = portdata->out_urbs[i];
  359. if (! urb)
  360. continue;
  361. urb->dev = serial->dev;
  362. /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
  363. usb_pipeout(urb->pipe), 0); */
  364. }
  365. port->tty->low_latency = 1;
  366. /* set mode to D0 */
  367. result = usb_control_msg(serial->dev,
  368. usb_rcvctrlpipe(serial->dev, 0),
  369. 0x00, 0x40, set_mode_dzero, 0, NULL,
  370. 0, USB_CTRL_SET_TIMEOUT);
  371. sierra_send_setup(port);
  372. return (0);
  373. }
  374. static inline void stop_urb(struct urb *urb)
  375. {
  376. if (urb && urb->status == -EINPROGRESS)
  377. usb_kill_urb(urb);
  378. }
  379. static void sierra_close(struct usb_serial_port *port, struct file *filp)
  380. {
  381. int i;
  382. struct usb_serial *serial = port->serial;
  383. struct sierra_port_private *portdata;
  384. dbg("%s", __FUNCTION__);
  385. portdata = usb_get_serial_port_data(port);
  386. portdata->rts_state = 0;
  387. portdata->dtr_state = 0;
  388. if (serial->dev) {
  389. sierra_send_setup(port);
  390. /* Stop reading/writing urbs */
  391. for (i = 0; i < N_IN_URB; i++)
  392. stop_urb(portdata->in_urbs[i]);
  393. for (i = 0; i < N_OUT_URB; i++)
  394. stop_urb(portdata->out_urbs[i]);
  395. }
  396. port->tty = NULL;
  397. }
  398. /* Helper functions used by sierra_setup_urbs */
  399. static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
  400. int dir, void *ctx, char *buf, int len,
  401. usb_complete_t callback)
  402. {
  403. struct urb *urb;
  404. if (endpoint == -1)
  405. return NULL; /* endpoint not needed */
  406. urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
  407. if (urb == NULL) {
  408. dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint);
  409. return NULL;
  410. }
  411. /* Fill URB using supplied data. */
  412. usb_fill_bulk_urb(urb, serial->dev,
  413. usb_sndbulkpipe(serial->dev, endpoint) | dir,
  414. buf, len, callback, ctx);
  415. return urb;
  416. }
  417. /* Setup urbs */
  418. static void sierra_setup_urbs(struct usb_serial *serial)
  419. {
  420. int i,j;
  421. struct usb_serial_port *port;
  422. struct sierra_port_private *portdata;
  423. dbg("%s", __FUNCTION__);
  424. for (i = 0; i < serial->num_ports; i++) {
  425. port = serial->port[i];
  426. portdata = usb_get_serial_port_data(port);
  427. /* Do indat endpoints first */
  428. for (j = 0; j < N_IN_URB; ++j) {
  429. portdata->in_urbs[j] = sierra_setup_urb (serial,
  430. port->bulk_in_endpointAddress, USB_DIR_IN, port,
  431. portdata->in_buffer[j], IN_BUFLEN, sierra_indat_callback);
  432. }
  433. /* outdat endpoints */
  434. for (j = 0; j < N_OUT_URB; ++j) {
  435. portdata->out_urbs[j] = sierra_setup_urb (serial,
  436. port->bulk_out_endpointAddress, USB_DIR_OUT, port,
  437. portdata->out_buffer[j], OUT_BUFLEN, sierra_outdat_callback);
  438. }
  439. }
  440. }
  441. static int sierra_startup(struct usb_serial *serial)
  442. {
  443. int i, err;
  444. struct usb_serial_port *port;
  445. struct sierra_port_private *portdata;
  446. dbg("%s", __FUNCTION__);
  447. /* Now setup per port private data */
  448. for (i = 0; i < serial->num_ports; i++) {
  449. port = serial->port[i];
  450. portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
  451. if (!portdata) {
  452. dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
  453. __FUNCTION__, i);
  454. return (1);
  455. }
  456. usb_set_serial_port_data(port, portdata);
  457. if (! port->interrupt_in_urb)
  458. continue;
  459. err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
  460. if (err)
  461. dbg("%s: submit irq_in urb failed %d",
  462. __FUNCTION__, err);
  463. }
  464. sierra_setup_urbs(serial);
  465. return (0);
  466. }
  467. static void sierra_shutdown(struct usb_serial *serial)
  468. {
  469. int i, j;
  470. struct usb_serial_port *port;
  471. struct sierra_port_private *portdata;
  472. dbg("%s", __FUNCTION__);
  473. /* Stop reading/writing urbs */
  474. for (i = 0; i < serial->num_ports; ++i) {
  475. port = serial->port[i];
  476. portdata = usb_get_serial_port_data(port);
  477. for (j = 0; j < N_IN_URB; j++)
  478. stop_urb(portdata->in_urbs[j]);
  479. for (j = 0; j < N_OUT_URB; j++)
  480. stop_urb(portdata->out_urbs[j]);
  481. }
  482. /* Now free them */
  483. for (i = 0; i < serial->num_ports; ++i) {
  484. port = serial->port[i];
  485. portdata = usb_get_serial_port_data(port);
  486. for (j = 0; j < N_IN_URB; j++) {
  487. if (portdata->in_urbs[j]) {
  488. usb_free_urb(portdata->in_urbs[j]);
  489. portdata->in_urbs[j] = NULL;
  490. }
  491. }
  492. for (j = 0; j < N_OUT_URB; j++) {
  493. if (portdata->out_urbs[j]) {
  494. usb_free_urb(portdata->out_urbs[j]);
  495. portdata->out_urbs[j] = NULL;
  496. }
  497. }
  498. }
  499. /* Now free per port private data */
  500. for (i = 0; i < serial->num_ports; i++) {
  501. port = serial->port[i];
  502. kfree(usb_get_serial_port_data(port));
  503. }
  504. }
  505. static struct usb_serial_driver sierra_1port_device = {
  506. .driver = {
  507. .owner = THIS_MODULE,
  508. .name = "sierra1",
  509. },
  510. .description = "Sierra USB modem (1 port)",
  511. .id_table = id_table_1port,
  512. .usb_driver = &sierra_driver,
  513. .num_interrupt_in = NUM_DONT_CARE,
  514. .num_bulk_in = 1,
  515. .num_bulk_out = 1,
  516. .num_ports = 1,
  517. .open = sierra_open,
  518. .close = sierra_close,
  519. .write = sierra_write,
  520. .write_room = sierra_write_room,
  521. .chars_in_buffer = sierra_chars_in_buffer,
  522. .throttle = sierra_rx_throttle,
  523. .unthrottle = sierra_rx_unthrottle,
  524. .ioctl = sierra_ioctl,
  525. .set_termios = sierra_set_termios,
  526. .break_ctl = sierra_break_ctl,
  527. .tiocmget = sierra_tiocmget,
  528. .tiocmset = sierra_tiocmset,
  529. .attach = sierra_startup,
  530. .shutdown = sierra_shutdown,
  531. .read_int_callback = sierra_instat_callback,
  532. };
  533. static struct usb_serial_driver sierra_3port_device = {
  534. .driver = {
  535. .owner = THIS_MODULE,
  536. .name = "sierra3",
  537. },
  538. .description = "Sierra USB modem (3 port)",
  539. .id_table = id_table_3port,
  540. .usb_driver = &sierra_driver,
  541. .num_interrupt_in = NUM_DONT_CARE,
  542. .num_bulk_in = 3,
  543. .num_bulk_out = 3,
  544. .num_ports = 3,
  545. .open = sierra_open,
  546. .close = sierra_close,
  547. .write = sierra_write,
  548. .write_room = sierra_write_room,
  549. .chars_in_buffer = sierra_chars_in_buffer,
  550. .throttle = sierra_rx_throttle,
  551. .unthrottle = sierra_rx_unthrottle,
  552. .ioctl = sierra_ioctl,
  553. .set_termios = sierra_set_termios,
  554. .break_ctl = sierra_break_ctl,
  555. .tiocmget = sierra_tiocmget,
  556. .tiocmset = sierra_tiocmset,
  557. .attach = sierra_startup,
  558. .shutdown = sierra_shutdown,
  559. .read_int_callback = sierra_instat_callback,
  560. };
  561. /* Functions used by new usb-serial code. */
  562. static int __init sierra_init(void)
  563. {
  564. int retval;
  565. retval = usb_serial_register(&sierra_1port_device);
  566. if (retval)
  567. goto failed_1port_device_register;
  568. retval = usb_serial_register(&sierra_3port_device);
  569. if (retval)
  570. goto failed_3port_device_register;
  571. retval = usb_register(&sierra_driver);
  572. if (retval)
  573. goto failed_driver_register;
  574. info(DRIVER_DESC ": " DRIVER_VERSION);
  575. return 0;
  576. failed_driver_register:
  577. usb_serial_deregister(&sierra_3port_device);
  578. failed_3port_device_register:
  579. usb_serial_deregister(&sierra_1port_device);
  580. failed_1port_device_register:
  581. return retval;
  582. }
  583. static void __exit sierra_exit(void)
  584. {
  585. usb_deregister (&sierra_driver);
  586. usb_serial_deregister(&sierra_1port_device);
  587. usb_serial_deregister(&sierra_3port_device);
  588. }
  589. module_init(sierra_init);
  590. module_exit(sierra_exit);
  591. MODULE_AUTHOR(DRIVER_AUTHOR);
  592. MODULE_DESCRIPTION(DRIVER_DESC);
  593. MODULE_VERSION(DRIVER_VERSION);
  594. MODULE_LICENSE("GPL");
  595. #ifdef CONFIG_USB_DEBUG
  596. module_param(debug, bool, S_IRUGO | S_IWUSR);
  597. MODULE_PARM_DESC(debug, "Debug messages");
  598. #endif