Merge branch 'for-linus' of git://git390.osdl.marist.edu/pub/scm/linux-2.6
[pandora-kernel.git] / drivers / usb / serial / belkin_sa.c
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
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 <linux/usb/serial.h>
78 #include "belkin_sa.h"
79
80 static int debug;
81
82 /*
83  * Version Information
84  */
85 #define DRIVER_VERSION "v1.2"
86 #define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>"
87 #define DRIVER_DESC "USB Belkin Serial converter driver"
88
89 /* function prototypes for a Belkin USB Serial Adapter F5U103 */
90 static int  belkin_sa_startup           (struct usb_serial *serial);
91 static void belkin_sa_shutdown          (struct usb_serial *serial);
92 static int  belkin_sa_open              (struct usb_serial_port *port, struct file *filp);
93 static void belkin_sa_close             (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 usb_serial_port *port, struct ktermios * old);
96 static int  belkin_sa_ioctl             (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
97 static void belkin_sa_break_ctl         (struct usb_serial_port *port, int break_state );
98 static int  belkin_sa_tiocmget          (struct usb_serial_port *port, struct file *file);
99 static int  belkin_sa_tiocmset          (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
100
101
102 static 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
112 MODULE_DEVICE_TABLE (usb, id_table_combined);
113
114 static struct usb_driver belkin_driver = {
115         .name =         "belkin",
116         .probe =        usb_serial_probe,
117         .disconnect =   usb_serial_disconnect,
118         .id_table =     id_table_combined,
119         .no_dynamic_id =        1,
120 };
121
122 /* All of the device info needed for the serial converters */
123 static struct usb_serial_driver belkin_device = {
124         .driver = {
125                 .owner =        THIS_MODULE,
126                 .name =         "belkin",
127         },
128         .description =          "Belkin / Peracom / GoHubs USB Serial Adapter",
129         .id_table =             id_table_combined,
130         .num_interrupt_in =     1,
131         .num_bulk_in =          1,
132         .num_bulk_out =         1,
133         .num_ports =            1,
134         .open =                 belkin_sa_open,
135         .close =                belkin_sa_close,
136         .read_int_callback =    belkin_sa_read_int_callback,    /* How we get the status info */
137         .ioctl =                belkin_sa_ioctl,
138         .set_termios =          belkin_sa_set_termios,
139         .break_ctl =            belkin_sa_break_ctl,
140         .tiocmget =             belkin_sa_tiocmget,
141         .tiocmset =             belkin_sa_tiocmset,
142         .attach =               belkin_sa_startup,
143         .shutdown =             belkin_sa_shutdown,
144 };
145
146
147 struct belkin_sa_private {
148         spinlock_t              lock;
149         unsigned long           control_state;
150         unsigned char           last_lsr;
151         unsigned char           last_msr;
152         int                     bad_flow_control;
153 };
154
155
156 /*
157  * ***************************************************************************
158  * Belkin USB Serial Adapter F5U103 specific driver functions
159  * ***************************************************************************
160  */
161
162 #define WDR_TIMEOUT 5000 /* default urb timeout */
163
164 /* assumes that struct usb_serial *serial is available */
165 #define BSA_USB_CMD(c,v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
166                                             (c), BELKIN_SA_SET_REQUEST_TYPE, \
167                                             (v), 0, NULL, 0, WDR_TIMEOUT)
168
169 /* do some startup allocations not currently performed by usb_serial_probe() */
170 static int belkin_sa_startup (struct usb_serial *serial)
171 {
172         struct usb_device *dev = serial->dev;
173         struct belkin_sa_private *priv;
174
175         /* allocate the private data structure */
176         priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
177         if (!priv)
178                 return (-1); /* error */
179         /* set initial values for control structures */
180         spin_lock_init(&priv->lock);
181         priv->control_state = 0;
182         priv->last_lsr = 0;
183         priv->last_msr = 0;
184         /* see comments at top of file */
185         priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;
186         info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control);
187
188         init_waitqueue_head(&serial->port[0]->write_wait);
189         usb_set_serial_port_data(serial->port[0], priv);
190         
191         return (0);
192 }
193
194
195 static void belkin_sa_shutdown (struct usb_serial *serial)
196 {
197         struct belkin_sa_private *priv;
198         int i;
199         
200         dbg ("%s", __FUNCTION__);
201
202         /* stop reads and writes on all ports */
203         for (i=0; i < serial->num_ports; ++i) {
204                 /* My special items, the standard routines free my urbs */
205                 priv = usb_get_serial_port_data(serial->port[i]);
206                 kfree(priv);
207         }
208 }
209
210
211 static int  belkin_sa_open (struct usb_serial_port *port, struct file *filp)
212 {
213         int retval = 0;
214
215         dbg("%s port %d", __FUNCTION__, port->number);
216
217         /*Start reading from the device*/
218         /* TODO: Look at possibility of submitting multiple URBs to device to
219          *       enhance buffering.  Win trace shows 16 initial read URBs.
220          */
221         port->read_urb->dev = port->serial->dev;
222         retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
223         if (retval) {
224                 err("usb_submit_urb(read bulk) failed");
225                 goto exit;
226         }
227
228         port->interrupt_in_urb->dev = port->serial->dev;
229         retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
230         if (retval) {
231                 usb_kill_urb(port->read_urb);
232                 err(" usb_submit_urb(read int) failed");
233         }
234
235 exit:
236         return retval;
237 } /* belkin_sa_open */
238
239
240 static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
241 {
242         dbg("%s port %d", __FUNCTION__, port->number);
243
244         /* shutdown our bulk reads and writes */
245         usb_kill_urb(port->write_urb);
246         usb_kill_urb(port->read_urb);
247         usb_kill_urb(port->interrupt_in_urb);
248 } /* belkin_sa_close */
249
250
251 static void belkin_sa_read_int_callback (struct urb *urb)
252 {
253         struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
254         struct belkin_sa_private *priv;
255         unsigned char *data = urb->transfer_buffer;
256         int retval;
257         unsigned long flags;
258
259         switch (urb->status) {
260         case 0:
261                 /* success */
262                 break;
263         case -ECONNRESET:
264         case -ENOENT:
265         case -ESHUTDOWN:
266                 /* this urb is terminated, clean up */
267                 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
268                 return;
269         default:
270                 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
271                 goto exit;
272         }
273
274         usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
275
276         /* Handle known interrupt data */
277         /* ignore data[0] and data[1] */
278
279         priv = usb_get_serial_port_data(port);
280         spin_lock_irqsave(&priv->lock, flags);
281         priv->last_msr = data[BELKIN_SA_MSR_INDEX];
282         
283         /* Record Control Line states */
284         if (priv->last_msr & BELKIN_SA_MSR_DSR)
285                 priv->control_state |= TIOCM_DSR;
286         else
287                 priv->control_state &= ~TIOCM_DSR;
288
289         if (priv->last_msr & BELKIN_SA_MSR_CTS)
290                 priv->control_state |= TIOCM_CTS;
291         else
292                 priv->control_state &= ~TIOCM_CTS;
293
294         if (priv->last_msr & BELKIN_SA_MSR_RI)
295                 priv->control_state |= TIOCM_RI;
296         else
297                 priv->control_state &= ~TIOCM_RI;
298
299         if (priv->last_msr & BELKIN_SA_MSR_CD)
300                 priv->control_state |= TIOCM_CD;
301         else
302                 priv->control_state &= ~TIOCM_CD;
303
304         /* Now to report any errors */
305         priv->last_lsr = data[BELKIN_SA_LSR_INDEX];
306 #if 0
307         /*
308          * fill in the flip buffer here, but I do not know the relation
309          * to the current/next receive buffer or characters.  I need
310          * to look in to this before committing any code.
311          */
312         if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
313                 tty = port->tty;
314                 /* Overrun Error */
315                 if (priv->last_lsr & BELKIN_SA_LSR_OE) {
316                 }
317                 /* Parity Error */
318                 if (priv->last_lsr & BELKIN_SA_LSR_PE) {
319                 }
320                 /* Framing Error */
321                 if (priv->last_lsr & BELKIN_SA_LSR_FE) {
322                 }
323                 /* Break Indicator */
324                 if (priv->last_lsr & BELKIN_SA_LSR_BI) {
325                 }
326         }
327 #endif
328         spin_unlock_irqrestore(&priv->lock, flags);
329 exit:
330         retval = usb_submit_urb (urb, GFP_ATOMIC);
331         if (retval)
332                 err ("%s - usb_submit_urb failed with result %d",
333                      __FUNCTION__, retval);
334 }
335
336 static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
337 {
338         struct usb_serial *serial = port->serial;
339         struct belkin_sa_private *priv = usb_get_serial_port_data(port);
340         unsigned int iflag;
341         unsigned int cflag;
342         unsigned int old_iflag = 0;
343         unsigned int old_cflag = 0;
344         __u16 urb_value = 0; /* Will hold the new flags */
345         unsigned long flags;
346         unsigned long control_state;
347         int bad_flow_control;
348         
349         if ((!port->tty) || (!port->tty->termios)) {
350                 dbg ("%s - no tty or termios structure", __FUNCTION__);
351                 return;
352         }
353
354         iflag = port->tty->termios->c_iflag;
355         cflag = port->tty->termios->c_cflag;
356
357         /* get a local copy of the current port settings */
358         spin_lock_irqsave(&priv->lock, flags);
359         control_state = priv->control_state;
360         bad_flow_control = priv->bad_flow_control;
361         spin_unlock_irqrestore(&priv->lock, flags);
362         
363         /* check that they really want us to change something */
364         if (old_termios) {
365                 if ((cflag == old_termios->c_cflag) &&
366                     (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
367                         dbg("%s - nothing to change...", __FUNCTION__);
368                         return;
369                 }
370                 old_iflag = old_termios->c_iflag;
371                 old_cflag = old_termios->c_cflag;
372         }
373
374         /* Set the baud rate */
375         if( (cflag&CBAUD) != (old_cflag&CBAUD) ) {
376                 /* reassert DTR and (maybe) RTS on transition from B0 */
377                 if( (old_cflag&CBAUD) == B0 ) {
378                         control_state |= (TIOCM_DTR|TIOCM_RTS);
379                         if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
380                                 err("Set DTR error");
381                         /* don't set RTS if using hardware flow control */
382                         if (!(old_cflag&CRTSCTS) )
383                                 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
384                                         err("Set RTS error");
385                 }
386
387                 switch(cflag & CBAUD) {
388                         case B0: /* handled below */ break;
389                         case B300: urb_value = BELKIN_SA_BAUD(300); break;
390                         case B600: urb_value = BELKIN_SA_BAUD(600); break;
391                         case B1200: urb_value = BELKIN_SA_BAUD(1200); break;
392                         case B2400: urb_value = BELKIN_SA_BAUD(2400); break;
393                         case B4800: urb_value = BELKIN_SA_BAUD(4800); break;
394                         case B9600: urb_value = BELKIN_SA_BAUD(9600); break;
395                         case B19200: urb_value = BELKIN_SA_BAUD(19200); break;
396                         case B38400: urb_value = BELKIN_SA_BAUD(38400); break;
397                         case B57600: urb_value = BELKIN_SA_BAUD(57600); break;
398                         case B115200: urb_value = BELKIN_SA_BAUD(115200); break;
399                         case B230400: urb_value = BELKIN_SA_BAUD(230400); break;
400                         default: err("BELKIN USB Serial Adapter: unsupported baudrate request, using default of 9600");
401                                 urb_value = BELKIN_SA_BAUD(9600); break;
402                 }
403                 if ((cflag & CBAUD) != B0 ) {
404                         if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
405                                 err("Set baudrate error");
406                 } else {
407                         /* Disable flow control */
408                         if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0)
409                                 err("Disable flowcontrol error");
410
411                         /* Drop RTS and DTR */
412                         control_state &= ~(TIOCM_DTR | TIOCM_RTS);
413                         if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
414                                 err("DTR LOW error");
415                         if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
416                                 err("RTS LOW error");
417                 }
418         }
419
420         /* set the parity */
421         if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) {
422                 if (cflag & PARENB)
423                         urb_value = (cflag & PARODD) ?  BELKIN_SA_PARITY_ODD : BELKIN_SA_PARITY_EVEN;
424                 else
425                         urb_value = BELKIN_SA_PARITY_NONE;
426                 if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0)
427                         err("Set parity error");
428         }
429
430         /* set the number of data bits */
431         if( (cflag&CSIZE) != (old_cflag&CSIZE) ) {
432                 switch (cflag & CSIZE) {
433                         case CS5: urb_value = BELKIN_SA_DATA_BITS(5); break;
434                         case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break;
435                         case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break;
436                         case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break;
437                         default: err("CSIZE was not CS5-CS8, using default of 8");
438                                 urb_value = BELKIN_SA_DATA_BITS(8);
439                                 break;
440                 }
441                 if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0)
442                         err("Set data bits error");
443         }
444
445         /* set the number of stop bits */
446         if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) {
447                 urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) : BELKIN_SA_STOP_BITS(1);
448                 if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value) < 0)
449                         err("Set stop bits error");
450         }
451
452         /* Set flow control */
453         if( (iflag&IXOFF)   != (old_iflag&IXOFF)
454         ||      (iflag&IXON)    != (old_iflag&IXON)
455         ||  (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) {
456                 urb_value = 0;
457                 if ((iflag & IXOFF) || (iflag & IXON))
458                         urb_value |= (BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
459                 else
460                         urb_value &= ~(BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
461
462                 if (cflag & CRTSCTS)
463                         urb_value |=  (BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
464                 else
465                         urb_value &= ~(BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
466
467                 if (bad_flow_control)
468                         urb_value &= ~(BELKIN_SA_FLOW_IRTS);
469
470                 if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0)
471                         err("Set flow control error");
472         }
473
474         /* save off the modified port settings */
475         spin_lock_irqsave(&priv->lock, flags);
476         priv->control_state = control_state;
477         spin_unlock_irqrestore(&priv->lock, flags);
478 } /* belkin_sa_set_termios */
479
480
481 static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
482 {
483         struct usb_serial *serial = port->serial;
484
485         if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
486                 err("Set break_ctl %d", break_state);
487 }
488
489
490 static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
491 {
492         struct belkin_sa_private *priv = usb_get_serial_port_data(port);
493         unsigned long control_state;
494         unsigned long flags;
495         
496         dbg("%s", __FUNCTION__);
497
498         spin_lock_irqsave(&priv->lock, flags);
499         control_state = priv->control_state;
500         spin_unlock_irqrestore(&priv->lock, flags);
501
502         return control_state;
503 }
504
505
506 static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
507                                unsigned int set, unsigned int clear)
508 {
509         struct usb_serial *serial = port->serial;
510         struct belkin_sa_private *priv = usb_get_serial_port_data(port);
511         unsigned long control_state;
512         unsigned long flags;
513         int retval;
514         int rts = 0;
515         int dtr = 0;
516         
517         dbg("%s", __FUNCTION__);
518
519         spin_lock_irqsave(&priv->lock, flags);
520         control_state = priv->control_state;
521
522         if (set & TIOCM_RTS) {
523                 control_state |= TIOCM_RTS;
524                 rts = 1;
525         }
526         if (set & TIOCM_DTR) {
527                 control_state |= TIOCM_DTR;
528                 dtr = 1;
529         }
530         if (clear & TIOCM_RTS) {
531                 control_state &= ~TIOCM_RTS;
532                 rts = 0;
533         }
534         if (clear & TIOCM_DTR) {
535                 control_state &= ~TIOCM_DTR;
536                 dtr = 0;
537         }
538
539         priv->control_state = control_state;
540         spin_unlock_irqrestore(&priv->lock, flags);
541
542         retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts);
543         if (retval < 0) {
544                 err("Set RTS error %d", retval);
545                 goto exit;
546         }
547
548         retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr);
549         if (retval < 0) {
550                 err("Set DTR error %d", retval);
551                 goto exit;
552         }
553 exit:
554         return retval;
555 }
556
557
558 static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
559 {
560         switch (cmd) {
561         case TIOCMIWAIT:
562                 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
563                 /* TODO */
564                 return( 0 );
565
566         case TIOCGICOUNT:
567                 /* return count of modemline transitions */
568                 /* TODO */
569                 return 0;
570
571         default:
572                 dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd);
573                 return(-ENOIOCTLCMD);
574                 break;
575         }
576         return 0;
577 } /* belkin_sa_ioctl */
578
579
580 static int __init belkin_sa_init (void)
581 {
582         int retval;
583         retval = usb_serial_register(&belkin_device);
584         if (retval)
585                 goto failed_usb_serial_register;
586         retval = usb_register(&belkin_driver);
587         if (retval)
588                 goto failed_usb_register;
589         info(DRIVER_DESC " " DRIVER_VERSION);
590         return 0;
591 failed_usb_register:
592         usb_serial_deregister(&belkin_device);
593 failed_usb_serial_register:
594         return retval;
595 }
596
597
598 static void __exit belkin_sa_exit (void)
599 {
600         usb_deregister (&belkin_driver);
601         usb_serial_deregister (&belkin_device);
602 }
603
604
605 module_init (belkin_sa_init);
606 module_exit (belkin_sa_exit);
607
608 MODULE_AUTHOR( DRIVER_AUTHOR );
609 MODULE_DESCRIPTION( DRIVER_DESC );
610 MODULE_VERSION( DRIVER_VERSION );
611 MODULE_LICENSE("GPL");
612
613 module_param(debug, bool, S_IRUGO | S_IWUSR);
614 MODULE_PARM_DESC(debug, "Debug enabled or not");