belkin_sa.c 17 KB

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