belkin_sa.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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/kernel.h>
  66. #include <linux/errno.h>
  67. #include <linux/init.h>
  68. #include <linux/slab.h>
  69. #include <linux/tty.h>
  70. #include <linux/tty_driver.h>
  71. #include <linux/tty_flip.h>
  72. #include <linux/module.h>
  73. #include <linux/spinlock.h>
  74. #include <asm/uaccess.h>
  75. #include <linux/usb.h>
  76. #include <linux/usb/serial.h>
  77. #include "belkin_sa.h"
  78. static int debug;
  79. /*
  80. * Version Information
  81. */
  82. #define DRIVER_VERSION "v1.2"
  83. #define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>"
  84. #define DRIVER_DESC "USB Belkin Serial converter driver"
  85. /* function prototypes for a Belkin USB Serial Adapter F5U103 */
  86. static int belkin_sa_startup (struct usb_serial *serial);
  87. static void belkin_sa_shutdown (struct usb_serial *serial);
  88. static int belkin_sa_open (struct usb_serial_port *port, struct file *filp);
  89. static void belkin_sa_close (struct usb_serial_port *port, struct file *filp);
  90. static void belkin_sa_read_int_callback (struct urb *urb);
  91. static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios * old);
  92. static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
  93. static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state );
  94. static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file);
  95. static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
  96. static struct usb_device_id id_table_combined [] = {
  97. { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) },
  98. { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) },
  99. { USB_DEVICE(PERACOM_VID, PERACOM_PID) },
  100. { USB_DEVICE(GOHUBS_VID, GOHUBS_PID) },
  101. { USB_DEVICE(GOHUBS_VID, HANDYLINK_PID) },
  102. { USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) },
  103. { } /* Terminating entry */
  104. };
  105. MODULE_DEVICE_TABLE (usb, id_table_combined);
  106. static struct usb_driver belkin_driver = {
  107. .name = "belkin",
  108. .probe = usb_serial_probe,
  109. .disconnect = usb_serial_disconnect,
  110. .id_table = id_table_combined,
  111. .no_dynamic_id = 1,
  112. };
  113. /* All of the device info needed for the serial converters */
  114. static struct usb_serial_driver belkin_device = {
  115. .driver = {
  116. .owner = THIS_MODULE,
  117. .name = "belkin",
  118. },
  119. .description = "Belkin / Peracom / GoHubs USB Serial Adapter",
  120. .usb_driver = &belkin_driver,
  121. .id_table = id_table_combined,
  122. .num_interrupt_in = 1,
  123. .num_bulk_in = 1,
  124. .num_bulk_out = 1,
  125. .num_ports = 1,
  126. .open = belkin_sa_open,
  127. .close = belkin_sa_close,
  128. .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */
  129. .ioctl = belkin_sa_ioctl,
  130. .set_termios = belkin_sa_set_termios,
  131. .break_ctl = belkin_sa_break_ctl,
  132. .tiocmget = belkin_sa_tiocmget,
  133. .tiocmset = belkin_sa_tiocmset,
  134. .attach = belkin_sa_startup,
  135. .shutdown = belkin_sa_shutdown,
  136. };
  137. struct belkin_sa_private {
  138. spinlock_t lock;
  139. unsigned long control_state;
  140. unsigned char last_lsr;
  141. unsigned char last_msr;
  142. int bad_flow_control;
  143. };
  144. /*
  145. * ***************************************************************************
  146. * Belkin USB Serial Adapter F5U103 specific driver functions
  147. * ***************************************************************************
  148. */
  149. #define WDR_TIMEOUT 5000 /* default urb timeout */
  150. /* assumes that struct usb_serial *serial is available */
  151. #define BSA_USB_CMD(c,v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
  152. (c), BELKIN_SA_SET_REQUEST_TYPE, \
  153. (v), 0, NULL, 0, WDR_TIMEOUT)
  154. /* do some startup allocations not currently performed by usb_serial_probe() */
  155. static int belkin_sa_startup (struct usb_serial *serial)
  156. {
  157. struct usb_device *dev = serial->dev;
  158. struct belkin_sa_private *priv;
  159. /* allocate the private data structure */
  160. priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
  161. if (!priv)
  162. return (-1); /* error */
  163. /* set initial values for control structures */
  164. spin_lock_init(&priv->lock);
  165. priv->control_state = 0;
  166. priv->last_lsr = 0;
  167. priv->last_msr = 0;
  168. /* see comments at top of file */
  169. priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;
  170. info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control);
  171. init_waitqueue_head(&serial->port[0]->write_wait);
  172. usb_set_serial_port_data(serial->port[0], priv);
  173. return (0);
  174. }
  175. static void belkin_sa_shutdown (struct usb_serial *serial)
  176. {
  177. struct belkin_sa_private *priv;
  178. int i;
  179. dbg ("%s", __FUNCTION__);
  180. /* stop reads and writes on all ports */
  181. for (i=0; i < serial->num_ports; ++i) {
  182. /* My special items, the standard routines free my urbs */
  183. priv = usb_get_serial_port_data(serial->port[i]);
  184. kfree(priv);
  185. }
  186. }
  187. static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
  188. {
  189. int retval = 0;
  190. dbg("%s port %d", __FUNCTION__, port->number);
  191. /*Start reading from the device*/
  192. /* TODO: Look at possibility of submitting multiple URBs to device to
  193. * enhance buffering. Win trace shows 16 initial read URBs.
  194. */
  195. port->read_urb->dev = port->serial->dev;
  196. retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
  197. if (retval) {
  198. err("usb_submit_urb(read bulk) failed");
  199. goto exit;
  200. }
  201. port->interrupt_in_urb->dev = port->serial->dev;
  202. retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
  203. if (retval) {
  204. usb_kill_urb(port->read_urb);
  205. err(" usb_submit_urb(read int) failed");
  206. }
  207. exit:
  208. return retval;
  209. } /* belkin_sa_open */
  210. static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
  211. {
  212. dbg("%s port %d", __FUNCTION__, port->number);
  213. /* shutdown our bulk reads and writes */
  214. usb_kill_urb(port->write_urb);
  215. usb_kill_urb(port->read_urb);
  216. usb_kill_urb(port->interrupt_in_urb);
  217. } /* belkin_sa_close */
  218. static void belkin_sa_read_int_callback (struct urb *urb)
  219. {
  220. struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
  221. struct belkin_sa_private *priv;
  222. unsigned char *data = urb->transfer_buffer;
  223. int retval;
  224. int status = urb->status;
  225. unsigned long flags;
  226. switch (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",
  235. __FUNCTION__, status);
  236. return;
  237. default:
  238. dbg("%s - nonzero urb status received: %d",
  239. __FUNCTION__, status);
  240. goto exit;
  241. }
  242. usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
  243. /* Handle known interrupt data */
  244. /* ignore data[0] and data[1] */
  245. priv = usb_get_serial_port_data(port);
  246. spin_lock_irqsave(&priv->lock, flags);
  247. priv->last_msr = data[BELKIN_SA_MSR_INDEX];
  248. /* Record Control Line states */
  249. if (priv->last_msr & BELKIN_SA_MSR_DSR)
  250. priv->control_state |= TIOCM_DSR;
  251. else
  252. priv->control_state &= ~TIOCM_DSR;
  253. if (priv->last_msr & BELKIN_SA_MSR_CTS)
  254. priv->control_state |= TIOCM_CTS;
  255. else
  256. priv->control_state &= ~TIOCM_CTS;
  257. if (priv->last_msr & BELKIN_SA_MSR_RI)
  258. priv->control_state |= TIOCM_RI;
  259. else
  260. priv->control_state &= ~TIOCM_RI;
  261. if (priv->last_msr & BELKIN_SA_MSR_CD)
  262. priv->control_state |= TIOCM_CD;
  263. else
  264. priv->control_state &= ~TIOCM_CD;
  265. /* Now to report any errors */
  266. priv->last_lsr = data[BELKIN_SA_LSR_INDEX];
  267. #if 0
  268. /*
  269. * fill in the flip buffer here, but I do not know the relation
  270. * to the current/next receive buffer or characters. I need
  271. * to look in to this before committing any code.
  272. */
  273. if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
  274. tty = port->tty;
  275. /* Overrun Error */
  276. if (priv->last_lsr & BELKIN_SA_LSR_OE) {
  277. }
  278. /* Parity Error */
  279. if (priv->last_lsr & BELKIN_SA_LSR_PE) {
  280. }
  281. /* Framing Error */
  282. if (priv->last_lsr & BELKIN_SA_LSR_FE) {
  283. }
  284. /* Break Indicator */
  285. if (priv->last_lsr & BELKIN_SA_LSR_BI) {
  286. }
  287. }
  288. #endif
  289. spin_unlock_irqrestore(&priv->lock, flags);
  290. exit:
  291. retval = usb_submit_urb (urb, GFP_ATOMIC);
  292. if (retval)
  293. err ("%s - usb_submit_urb failed with result %d",
  294. __FUNCTION__, retval);
  295. }
  296. static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
  297. {
  298. struct usb_serial *serial = port->serial;
  299. struct belkin_sa_private *priv = usb_get_serial_port_data(port);
  300. unsigned int iflag;
  301. unsigned int cflag;
  302. unsigned int old_iflag = 0;
  303. unsigned int old_cflag = 0;
  304. __u16 urb_value = 0; /* Will hold the new flags */
  305. unsigned long flags;
  306. unsigned long control_state;
  307. int bad_flow_control;
  308. speed_t baud;
  309. if ((!port->tty) || (!port->tty->termios)) {
  310. dbg ("%s - no tty or termios structure", __FUNCTION__);
  311. return;
  312. }
  313. iflag = port->tty->termios->c_iflag;
  314. cflag = port->tty->termios->c_cflag;
  315. /* get a local copy of the current port settings */
  316. spin_lock_irqsave(&priv->lock, flags);
  317. control_state = priv->control_state;
  318. bad_flow_control = priv->bad_flow_control;
  319. spin_unlock_irqrestore(&priv->lock, flags);
  320. old_iflag = old_termios->c_iflag;
  321. old_cflag = old_termios->c_cflag;
  322. /* Set the baud rate */
  323. if( (cflag&CBAUD) != (old_cflag&CBAUD) ) {
  324. /* reassert DTR and (maybe) RTS on transition from B0 */
  325. if( (old_cflag&CBAUD) == B0 ) {
  326. control_state |= (TIOCM_DTR|TIOCM_RTS);
  327. if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
  328. err("Set DTR error");
  329. /* don't set RTS if using hardware flow control */
  330. if (!(old_cflag&CRTSCTS) )
  331. if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
  332. err("Set RTS error");
  333. }
  334. }
  335. baud = tty_get_baud_rate(port->tty);
  336. if (baud == 0) {
  337. dbg("%s - tty_get_baud_rate says 0 baud", __FUNCTION__);
  338. return;
  339. }
  340. urb_value = BELKIN_SA_BAUD(baud);
  341. /* Clip to maximum speed */
  342. if (urb_value == 0)
  343. urb_value = 1;
  344. /* Turn it back into a resulting real baud rate */
  345. baud = BELKIN_SA_BAUD(urb_value);
  346. /* FIXME: Once the tty updates are done then push this back to the tty */
  347. if ((cflag & CBAUD) != B0 ) {
  348. if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
  349. err("Set baudrate error");
  350. } else {
  351. /* Disable flow control */
  352. if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0)
  353. err("Disable flowcontrol error");
  354. /* Drop RTS and DTR */
  355. control_state &= ~(TIOCM_DTR | TIOCM_RTS);
  356. if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
  357. err("DTR LOW error");
  358. if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
  359. err("RTS LOW error");
  360. }
  361. /* set the parity */
  362. if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) {
  363. if (cflag & PARENB)
  364. urb_value = (cflag & PARODD) ? BELKIN_SA_PARITY_ODD : BELKIN_SA_PARITY_EVEN;
  365. else
  366. urb_value = BELKIN_SA_PARITY_NONE;
  367. if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0)
  368. err("Set parity error");
  369. }
  370. /* set the number of data bits */
  371. if( (cflag&CSIZE) != (old_cflag&CSIZE) ) {
  372. switch (cflag & CSIZE) {
  373. case CS5: urb_value = BELKIN_SA_DATA_BITS(5); break;
  374. case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break;
  375. case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break;
  376. case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break;
  377. default: dbg("CSIZE was not CS5-CS8, using default of 8");
  378. urb_value = BELKIN_SA_DATA_BITS(8);
  379. break;
  380. }
  381. if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0)
  382. err("Set data bits error");
  383. }
  384. /* set the number of stop bits */
  385. if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) {
  386. urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) : BELKIN_SA_STOP_BITS(1);
  387. if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value) < 0)
  388. err("Set stop bits error");
  389. }
  390. /* Set flow control */
  391. if( (iflag&IXOFF) != (old_iflag&IXOFF)
  392. || (iflag&IXON) != (old_iflag&IXON)
  393. || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) {
  394. urb_value = 0;
  395. if ((iflag & IXOFF) || (iflag & IXON))
  396. urb_value |= (BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
  397. else
  398. urb_value &= ~(BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
  399. if (cflag & CRTSCTS)
  400. urb_value |= (BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
  401. else
  402. urb_value &= ~(BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
  403. if (bad_flow_control)
  404. urb_value &= ~(BELKIN_SA_FLOW_IRTS);
  405. if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0)
  406. err("Set flow control error");
  407. }
  408. /* save off the modified port settings */
  409. spin_lock_irqsave(&priv->lock, flags);
  410. priv->control_state = control_state;
  411. spin_unlock_irqrestore(&priv->lock, flags);
  412. } /* belkin_sa_set_termios */
  413. static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
  414. {
  415. struct usb_serial *serial = port->serial;
  416. if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
  417. err("Set break_ctl %d", break_state);
  418. }
  419. static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
  420. {
  421. struct belkin_sa_private *priv = usb_get_serial_port_data(port);
  422. unsigned long control_state;
  423. unsigned long flags;
  424. dbg("%s", __FUNCTION__);
  425. spin_lock_irqsave(&priv->lock, flags);
  426. control_state = priv->control_state;
  427. spin_unlock_irqrestore(&priv->lock, flags);
  428. return control_state;
  429. }
  430. static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
  431. unsigned int set, unsigned int clear)
  432. {
  433. struct usb_serial *serial = port->serial;
  434. struct belkin_sa_private *priv = usb_get_serial_port_data(port);
  435. unsigned long control_state;
  436. unsigned long flags;
  437. int retval;
  438. int rts = 0;
  439. int dtr = 0;
  440. dbg("%s", __FUNCTION__);
  441. spin_lock_irqsave(&priv->lock, flags);
  442. control_state = priv->control_state;
  443. if (set & TIOCM_RTS) {
  444. control_state |= TIOCM_RTS;
  445. rts = 1;
  446. }
  447. if (set & TIOCM_DTR) {
  448. control_state |= TIOCM_DTR;
  449. dtr = 1;
  450. }
  451. if (clear & TIOCM_RTS) {
  452. control_state &= ~TIOCM_RTS;
  453. rts = 0;
  454. }
  455. if (clear & TIOCM_DTR) {
  456. control_state &= ~TIOCM_DTR;
  457. dtr = 0;
  458. }
  459. priv->control_state = control_state;
  460. spin_unlock_irqrestore(&priv->lock, flags);
  461. retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts);
  462. if (retval < 0) {
  463. err("Set RTS error %d", retval);
  464. goto exit;
  465. }
  466. retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr);
  467. if (retval < 0) {
  468. err("Set DTR error %d", retval);
  469. goto exit;
  470. }
  471. exit:
  472. return retval;
  473. }
  474. static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
  475. {
  476. switch (cmd) {
  477. case TIOCMIWAIT:
  478. /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
  479. /* TODO */
  480. return( 0 );
  481. case TIOCGICOUNT:
  482. /* return count of modemline transitions */
  483. /* TODO */
  484. return 0;
  485. default:
  486. dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd);
  487. return(-ENOIOCTLCMD);
  488. break;
  489. }
  490. return 0;
  491. } /* belkin_sa_ioctl */
  492. static int __init belkin_sa_init (void)
  493. {
  494. int retval;
  495. retval = usb_serial_register(&belkin_device);
  496. if (retval)
  497. goto failed_usb_serial_register;
  498. retval = usb_register(&belkin_driver);
  499. if (retval)
  500. goto failed_usb_register;
  501. info(DRIVER_DESC " " DRIVER_VERSION);
  502. return 0;
  503. failed_usb_register:
  504. usb_serial_deregister(&belkin_device);
  505. failed_usb_serial_register:
  506. return retval;
  507. }
  508. static void __exit belkin_sa_exit (void)
  509. {
  510. usb_deregister (&belkin_driver);
  511. usb_serial_deregister (&belkin_device);
  512. }
  513. module_init (belkin_sa_init);
  514. module_exit (belkin_sa_exit);
  515. MODULE_AUTHOR( DRIVER_AUTHOR );
  516. MODULE_DESCRIPTION( DRIVER_DESC );
  517. MODULE_VERSION( DRIVER_VERSION );
  518. MODULE_LICENSE("GPL");
  519. module_param(debug, bool, S_IRUGO | S_IWUSR);
  520. MODULE_PARM_DESC(debug, "Debug enabled or not");