belkin_sa.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*
  2. * Belkin USB Serial Adapter Driver
  3. *
  4. * Copyright (C) 2000 William Greathouse (wgreathouse@smva.com)
  5. * Copyright (C) 2000-2001 Greg Kroah-Hartman (greg@kroah.com)
  6. *
  7. * This program is largely derived from work by the linux-usb group
  8. * and associated source files. Please see the usb/serial files for
  9. * individual credits and copyrights.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * See Documentation/usb/usb-serial.txt for more information on using this driver
  17. *
  18. * TODO:
  19. * -- Add true modem contol line query capability. Currently we track the
  20. * states reported by the interrupt and the states we request.
  21. * -- Add error reporting back to application for UART error conditions.
  22. * Just point me at how to implement this and I'll do it. I've put the
  23. * framework in, but haven't analyzed the "tty_flip" interface yet.
  24. * -- Add support for flush commands
  25. * -- Add everything that is missing :)
  26. *
  27. * 27-Nov-2001 gkh
  28. * compressed all the differnent device entries into 1.
  29. *
  30. * 30-May-2001 gkh
  31. * switched from using spinlock to a semaphore, which fixes lots of problems.
  32. *
  33. * 08-Apr-2001 gb
  34. * - Identify version on module load.
  35. *
  36. * 12-Mar-2001 gkh
  37. * - Added support for the GoHubs GO-COM232 device which is the same as the
  38. * Peracom device.
  39. *
  40. * 06-Nov-2000 gkh
  41. * - Added support for the old Belkin and Peracom devices.
  42. * - Made the port able to be opened multiple times.
  43. * - Added some defaults incase the line settings are things these devices
  44. * can't support.
  45. *
  46. * 18-Oct-2000 William Greathouse
  47. * Released into the wild (linux-usb-devel)
  48. *
  49. * 17-Oct-2000 William Greathouse
  50. * Add code to recognize firmware version and set hardware flow control
  51. * appropriately. Belkin states that firmware prior to 3.05 does not
  52. * operate correctly in hardware handshake mode. I have verified this
  53. * on firmware 2.05 -- for both RTS and DTR input flow control, the control
  54. * line is not reset. The test performed by the Belkin Win* driver is
  55. * to enable hardware flow control for firmware 2.06 or greater and
  56. * for 1.00 or prior. I am only enabling for 2.06 or greater.
  57. *
  58. * 12-Oct-2000 William Greathouse
  59. * First cut at supporting Belkin USB Serial Adapter F5U103
  60. * I did not have a copy of the original work to support this
  61. * adapter, so pardon any stupid mistakes. All of the information
  62. * I am using to write this driver was acquired by using a modified
  63. * UsbSnoop on Windows2000 and from examining the other USB drivers.
  64. */
  65. #include <linux/config.h>
  66. #include <linux/kernel.h>
  67. #include <linux/errno.h>
  68. #include <linux/init.h>
  69. #include <linux/slab.h>
  70. #include <linux/tty.h>
  71. #include <linux/tty_driver.h>
  72. #include <linux/tty_flip.h>
  73. #include <linux/module.h>
  74. #include <linux/spinlock.h>
  75. #include <asm/uaccess.h>
  76. #include <linux/usb.h>
  77. #include "usb-serial.h"
  78. #include "belkin_sa.h"
  79. static int debug;
  80. /*
  81. * Version Information
  82. */
  83. #define DRIVER_VERSION "v1.2"
  84. #define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>"
  85. #define DRIVER_DESC "USB Belkin Serial converter driver"
  86. /* function prototypes for a Belkin USB Serial Adapter F5U103 */
  87. static int belkin_sa_startup (struct usb_serial *serial);
  88. static void belkin_sa_shutdown (struct usb_serial *serial);
  89. static int belkin_sa_open (struct usb_serial_port *port, struct file *filp);
  90. static void belkin_sa_close (struct usb_serial_port *port, struct file *filp);
  91. static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs);
  92. static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios * old);
  93. static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
  94. static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state );
  95. static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file);
  96. static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
  97. static struct usb_device_id id_table_combined [] = {
  98. { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) },
  99. { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) },
  100. { USB_DEVICE(PERACOM_VID, PERACOM_PID) },
  101. { USB_DEVICE(GOHUBS_VID, GOHUBS_PID) },
  102. { USB_DEVICE(GOHUBS_VID, HANDYLINK_PID) },
  103. { USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) },
  104. { } /* Terminating entry */
  105. };
  106. MODULE_DEVICE_TABLE (usb, id_table_combined);
  107. static struct usb_driver belkin_driver = {
  108. .owner = THIS_MODULE,
  109. .name = "belkin",
  110. .probe = usb_serial_probe,
  111. .disconnect = usb_serial_disconnect,
  112. .id_table = id_table_combined,
  113. .no_dynamic_id = 1,
  114. };
  115. /* All of the device info needed for the serial converters */
  116. static struct usb_serial_driver belkin_device = {
  117. .driver = {
  118. .owner = THIS_MODULE,
  119. .name = "belkin",
  120. },
  121. .description = "Belkin / Peracom / GoHubs USB Serial Adapter",
  122. .id_table = id_table_combined,
  123. .num_interrupt_in = 1,
  124. .num_bulk_in = 1,
  125. .num_bulk_out = 1,
  126. .num_ports = 1,
  127. .open = belkin_sa_open,
  128. .close = belkin_sa_close,
  129. .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */
  130. .ioctl = belkin_sa_ioctl,
  131. .set_termios = belkin_sa_set_termios,
  132. .break_ctl = belkin_sa_break_ctl,
  133. .tiocmget = belkin_sa_tiocmget,
  134. .tiocmset = belkin_sa_tiocmset,
  135. .attach = belkin_sa_startup,
  136. .shutdown = belkin_sa_shutdown,
  137. };
  138. struct belkin_sa_private {
  139. spinlock_t lock;
  140. unsigned long control_state;
  141. unsigned char last_lsr;
  142. unsigned char last_msr;
  143. int bad_flow_control;
  144. };
  145. /*
  146. * ***************************************************************************
  147. * Belkin USB Serial Adapter F5U103 specific driver functions
  148. * ***************************************************************************
  149. */
  150. #define WDR_TIMEOUT 5000 /* default urb timeout */
  151. /* assumes that struct usb_serial *serial is available */
  152. #define BSA_USB_CMD(c,v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
  153. (c), BELKIN_SA_SET_REQUEST_TYPE, \
  154. (v), 0, NULL, 0, WDR_TIMEOUT)
  155. /* do some startup allocations not currently performed by usb_serial_probe() */
  156. static int belkin_sa_startup (struct usb_serial *serial)
  157. {
  158. struct usb_device *dev = serial->dev;
  159. struct belkin_sa_private *priv;
  160. /* allocate the private data structure */
  161. priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
  162. if (!priv)
  163. return (-1); /* error */
  164. /* set initial values for control structures */
  165. spin_lock_init(&priv->lock);
  166. priv->control_state = 0;
  167. priv->last_lsr = 0;
  168. priv->last_msr = 0;
  169. /* see comments at top of file */
  170. priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;
  171. info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control);
  172. init_waitqueue_head(&serial->port[0]->write_wait);
  173. usb_set_serial_port_data(serial->port[0], priv);
  174. return (0);
  175. }
  176. static void belkin_sa_shutdown (struct usb_serial *serial)
  177. {
  178. struct belkin_sa_private *priv;
  179. int i;
  180. dbg ("%s", __FUNCTION__);
  181. /* stop reads and writes on all ports */
  182. for (i=0; i < serial->num_ports; ++i) {
  183. /* My special items, the standard routines free my urbs */
  184. priv = usb_get_serial_port_data(serial->port[i]);
  185. kfree(priv);
  186. }
  187. }
  188. static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
  189. {
  190. int retval = 0;
  191. dbg("%s port %d", __FUNCTION__, port->number);
  192. /*Start reading from the device*/
  193. /* TODO: Look at possibility of submitting multiple URBs to device to
  194. * enhance buffering. Win trace shows 16 initial read URBs.
  195. */
  196. port->read_urb->dev = port->serial->dev;
  197. retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
  198. if (retval) {
  199. err("usb_submit_urb(read bulk) failed");
  200. goto exit;
  201. }
  202. port->interrupt_in_urb->dev = port->serial->dev;
  203. retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
  204. if (retval) {
  205. usb_kill_urb(port->read_urb);
  206. err(" usb_submit_urb(read int) failed");
  207. }
  208. exit:
  209. return retval;
  210. } /* belkin_sa_open */
  211. static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
  212. {
  213. dbg("%s port %d", __FUNCTION__, port->number);
  214. /* shutdown our bulk reads and writes */
  215. usb_kill_urb(port->write_urb);
  216. usb_kill_urb(port->read_urb);
  217. usb_kill_urb(port->interrupt_in_urb);
  218. } /* belkin_sa_close */
  219. static void belkin_sa_read_int_callback (struct urb *urb, struct pt_regs *regs)
  220. {
  221. struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
  222. struct belkin_sa_private *priv;
  223. unsigned char *data = urb->transfer_buffer;
  224. int retval;
  225. unsigned long flags;
  226. switch (urb->status) {
  227. case 0:
  228. /* success */
  229. break;
  230. case -ECONNRESET:
  231. case -ENOENT:
  232. case -ESHUTDOWN:
  233. /* this urb is terminated, clean up */
  234. dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
  235. return;
  236. default:
  237. dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
  238. goto exit;
  239. }
  240. usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
  241. /* Handle known interrupt data */
  242. /* ignore data[0] and data[1] */
  243. priv = usb_get_serial_port_data(port);
  244. spin_lock_irqsave(&priv->lock, flags);
  245. priv->last_msr = data[BELKIN_SA_MSR_INDEX];
  246. /* Record Control Line states */
  247. if (priv->last_msr & BELKIN_SA_MSR_DSR)
  248. priv->control_state |= TIOCM_DSR;
  249. else
  250. priv->control_state &= ~TIOCM_DSR;
  251. if (priv->last_msr & BELKIN_SA_MSR_CTS)
  252. priv->control_state |= TIOCM_CTS;
  253. else
  254. priv->control_state &= ~TIOCM_CTS;
  255. if (priv->last_msr & BELKIN_SA_MSR_RI)
  256. priv->control_state |= TIOCM_RI;
  257. else
  258. priv->control_state &= ~TIOCM_RI;
  259. if (priv->last_msr & BELKIN_SA_MSR_CD)
  260. priv->control_state |= TIOCM_CD;
  261. else
  262. priv->control_state &= ~TIOCM_CD;
  263. /* Now to report any errors */
  264. priv->last_lsr = data[BELKIN_SA_LSR_INDEX];
  265. #if 0
  266. /*
  267. * fill in the flip buffer here, but I do not know the relation
  268. * to the current/next receive buffer or characters. I need
  269. * to look in to this before committing any code.
  270. */
  271. if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
  272. tty = port->tty;
  273. /* Overrun Error */
  274. if (priv->last_lsr & BELKIN_SA_LSR_OE) {
  275. }
  276. /* Parity Error */
  277. if (priv->last_lsr & BELKIN_SA_LSR_PE) {
  278. }
  279. /* Framing Error */
  280. if (priv->last_lsr & BELKIN_SA_LSR_FE) {
  281. }
  282. /* Break Indicator */
  283. if (priv->last_lsr & BELKIN_SA_LSR_BI) {
  284. }
  285. }
  286. #endif
  287. spin_unlock_irqrestore(&priv->lock, flags);
  288. exit:
  289. retval = usb_submit_urb (urb, GFP_ATOMIC);
  290. if (retval)
  291. err ("%s - usb_submit_urb failed with result %d",
  292. __FUNCTION__, retval);
  293. }
  294. static void belkin_sa_set_termios (struct usb_serial_port *port, struct termios *old_termios)
  295. {
  296. struct usb_serial *serial = port->serial;
  297. struct belkin_sa_private *priv = usb_get_serial_port_data(port);
  298. unsigned int iflag;
  299. unsigned int cflag;
  300. unsigned int old_iflag = 0;
  301. unsigned int old_cflag = 0;
  302. __u16 urb_value = 0; /* Will hold the new flags */
  303. unsigned long flags;
  304. unsigned long control_state;
  305. int bad_flow_control;
  306. if ((!port->tty) || (!port->tty->termios)) {
  307. dbg ("%s - no tty or termios structure", __FUNCTION__);
  308. return;
  309. }
  310. iflag = port->tty->termios->c_iflag;
  311. cflag = port->tty->termios->c_cflag;
  312. /* get a local copy of the current port settings */
  313. spin_lock_irqsave(&priv->lock, flags);
  314. control_state = priv->control_state;
  315. bad_flow_control = priv->bad_flow_control;
  316. spin_unlock_irqrestore(&priv->lock, flags);
  317. /* check that they really want us to change something */
  318. if (old_termios) {
  319. if ((cflag == old_termios->c_cflag) &&
  320. (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
  321. dbg("%s - nothing to change...", __FUNCTION__);
  322. return;
  323. }
  324. old_iflag = old_termios->c_iflag;
  325. old_cflag = old_termios->c_cflag;
  326. }
  327. /* Set the baud rate */
  328. if( (cflag&CBAUD) != (old_cflag&CBAUD) ) {
  329. /* reassert DTR and (maybe) RTS on transition from B0 */
  330. if( (old_cflag&CBAUD) == B0 ) {
  331. control_state |= (TIOCM_DTR|TIOCM_RTS);
  332. if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
  333. err("Set DTR error");
  334. /* don't set RTS if using hardware flow control */
  335. if (!(old_cflag&CRTSCTS) )
  336. if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
  337. err("Set RTS error");
  338. }
  339. switch(cflag & CBAUD) {
  340. case B0: /* handled below */ break;
  341. case B300: urb_value = BELKIN_SA_BAUD(300); break;
  342. case B600: urb_value = BELKIN_SA_BAUD(600); break;
  343. case B1200: urb_value = BELKIN_SA_BAUD(1200); break;
  344. case B2400: urb_value = BELKIN_SA_BAUD(2400); break;
  345. case B4800: urb_value = BELKIN_SA_BAUD(4800); break;
  346. case B9600: urb_value = BELKIN_SA_BAUD(9600); break;
  347. case B19200: urb_value = BELKIN_SA_BAUD(19200); break;
  348. case B38400: urb_value = BELKIN_SA_BAUD(38400); break;
  349. case B57600: urb_value = BELKIN_SA_BAUD(57600); break;
  350. case B115200: urb_value = BELKIN_SA_BAUD(115200); break;
  351. case B230400: urb_value = BELKIN_SA_BAUD(230400); break;
  352. default: err("BELKIN USB Serial Adapter: unsupported baudrate request, using default of 9600");
  353. urb_value = BELKIN_SA_BAUD(9600); break;
  354. }
  355. if ((cflag & CBAUD) != B0 ) {
  356. if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
  357. err("Set baudrate error");
  358. } else {
  359. /* Disable flow control */
  360. if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0)
  361. err("Disable flowcontrol error");
  362. /* Drop RTS and DTR */
  363. control_state &= ~(TIOCM_DTR | TIOCM_RTS);
  364. if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
  365. err("DTR LOW error");
  366. if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
  367. err("RTS LOW error");
  368. }
  369. }
  370. /* set the parity */
  371. if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) {
  372. if (cflag & PARENB)
  373. urb_value = (cflag & PARODD) ? BELKIN_SA_PARITY_ODD : BELKIN_SA_PARITY_EVEN;
  374. else
  375. urb_value = BELKIN_SA_PARITY_NONE;
  376. if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0)
  377. err("Set parity error");
  378. }
  379. /* set the number of data bits */
  380. if( (cflag&CSIZE) != (old_cflag&CSIZE) ) {
  381. switch (cflag & CSIZE) {
  382. case CS5: urb_value = BELKIN_SA_DATA_BITS(5); break;
  383. case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break;
  384. case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break;
  385. case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break;
  386. default: err("CSIZE was not CS5-CS8, using default of 8");
  387. urb_value = BELKIN_SA_DATA_BITS(8);
  388. break;
  389. }
  390. if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0)
  391. err("Set data bits error");
  392. }
  393. /* set the number of stop bits */
  394. if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) {
  395. urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) : BELKIN_SA_STOP_BITS(1);
  396. if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value) < 0)
  397. err("Set stop bits error");
  398. }
  399. /* Set flow control */
  400. if( (iflag&IXOFF) != (old_iflag&IXOFF)
  401. || (iflag&IXON) != (old_iflag&IXON)
  402. || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) {
  403. urb_value = 0;
  404. if ((iflag & IXOFF) || (iflag & IXON))
  405. urb_value |= (BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
  406. else
  407. urb_value &= ~(BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
  408. if (cflag & CRTSCTS)
  409. urb_value |= (BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
  410. else
  411. urb_value &= ~(BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
  412. if (bad_flow_control)
  413. urb_value &= ~(BELKIN_SA_FLOW_IRTS);
  414. if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0)
  415. err("Set flow control error");
  416. }
  417. /* save off the modified port settings */
  418. spin_lock_irqsave(&priv->lock, flags);
  419. priv->control_state = control_state;
  420. spin_unlock_irqrestore(&priv->lock, flags);
  421. } /* belkin_sa_set_termios */
  422. static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
  423. {
  424. struct usb_serial *serial = port->serial;
  425. if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
  426. err("Set break_ctl %d", break_state);
  427. }
  428. static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
  429. {
  430. struct belkin_sa_private *priv = usb_get_serial_port_data(port);
  431. unsigned long control_state;
  432. unsigned long flags;
  433. dbg("%s", __FUNCTION__);
  434. spin_lock_irqsave(&priv->lock, flags);
  435. control_state = priv->control_state;
  436. spin_unlock_irqrestore(&priv->lock, flags);
  437. return control_state;
  438. }
  439. static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
  440. unsigned int set, unsigned int clear)
  441. {
  442. struct usb_serial *serial = port->serial;
  443. struct belkin_sa_private *priv = usb_get_serial_port_data(port);
  444. unsigned long control_state;
  445. unsigned long flags;
  446. int retval;
  447. int rts = 0;
  448. int dtr = 0;
  449. dbg("%s", __FUNCTION__);
  450. spin_lock_irqsave(&priv->lock, flags);
  451. control_state = priv->control_state;
  452. if (set & TIOCM_RTS) {
  453. control_state |= TIOCM_RTS;
  454. rts = 1;
  455. }
  456. if (set & TIOCM_DTR) {
  457. control_state |= TIOCM_DTR;
  458. dtr = 1;
  459. }
  460. if (clear & TIOCM_RTS) {
  461. control_state &= ~TIOCM_RTS;
  462. rts = 0;
  463. }
  464. if (clear & TIOCM_DTR) {
  465. control_state &= ~TIOCM_DTR;
  466. dtr = 0;
  467. }
  468. priv->control_state = control_state;
  469. spin_unlock_irqrestore(&priv->lock, flags);
  470. retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts);
  471. if (retval < 0) {
  472. err("Set RTS error %d", retval);
  473. goto exit;
  474. }
  475. retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr);
  476. if (retval < 0) {
  477. err("Set DTR error %d", retval);
  478. goto exit;
  479. }
  480. exit:
  481. return retval;
  482. }
  483. static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
  484. {
  485. switch (cmd) {
  486. case TIOCMIWAIT:
  487. /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
  488. /* TODO */
  489. return( 0 );
  490. case TIOCGICOUNT:
  491. /* return count of modemline transitions */
  492. /* TODO */
  493. return 0;
  494. default:
  495. dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd);
  496. return(-ENOIOCTLCMD);
  497. break;
  498. }
  499. return 0;
  500. } /* belkin_sa_ioctl */
  501. static int __init belkin_sa_init (void)
  502. {
  503. int retval;
  504. retval = usb_serial_register(&belkin_device);
  505. if (retval)
  506. goto failed_usb_serial_register;
  507. retval = usb_register(&belkin_driver);
  508. if (retval)
  509. goto failed_usb_register;
  510. info(DRIVER_DESC " " DRIVER_VERSION);
  511. return 0;
  512. failed_usb_register:
  513. usb_serial_deregister(&belkin_device);
  514. failed_usb_serial_register:
  515. return retval;
  516. }
  517. static void __exit belkin_sa_exit (void)
  518. {
  519. usb_deregister (&belkin_driver);
  520. usb_serial_deregister (&belkin_device);
  521. }
  522. module_init (belkin_sa_init);
  523. module_exit (belkin_sa_exit);
  524. MODULE_AUTHOR( DRIVER_AUTHOR );
  525. MODULE_DESCRIPTION( DRIVER_DESC );
  526. MODULE_VERSION( DRIVER_VERSION );
  527. MODULE_LICENSE("GPL");
  528. module_param(debug, bool, S_IRUGO | S_IWUSR);
  529. MODULE_PARM_DESC(debug, "Debug enabled or not");