belkin_sa.c 17 KB

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