USB: serial: ssu100: fix control-message error handling
[pandora-kernel.git] / drivers / usb / serial / ssu100.c
1 /*
2  * usb-serial driver for Quatech SSU-100
3  *
4  * based on ftdi_sio.c and the original serqt_usb.c from Quatech
5  *
6  */
7
8 #include <linux/errno.h>
9 #include <linux/init.h>
10 #include <linux/slab.h>
11 #include <linux/tty.h>
12 #include <linux/tty_driver.h>
13 #include <linux/tty_flip.h>
14 #include <linux/module.h>
15 #include <linux/serial.h>
16 #include <linux/usb.h>
17 #include <linux/usb/serial.h>
18 #include <linux/serial_reg.h>
19 #include <linux/uaccess.h>
20
21 #define QT_OPEN_CLOSE_CHANNEL       0xca
22 #define QT_SET_GET_DEVICE           0xc2
23 #define QT_SET_GET_REGISTER         0xc0
24 #define QT_GET_SET_PREBUF_TRIG_LVL  0xcc
25 #define QT_SET_ATF                  0xcd
26 #define QT_GET_SET_UART             0xc1
27 #define QT_TRANSFER_IN              0xc0
28 #define QT_HW_FLOW_CONTROL_MASK     0xc5
29 #define QT_SW_FLOW_CONTROL_MASK     0xc6
30
31 #define  SERIAL_MSR_MASK            0xf0
32
33 #define  SERIAL_CRTSCTS ((UART_MCR_RTS << 8) | UART_MSR_CTS)
34
35 #define  SERIAL_EVEN_PARITY         (UART_LCR_PARITY | UART_LCR_EPAR)
36
37 #define  MAX_BAUD_RATE              460800
38
39 #define ATC_DISABLED                0x00
40 #define DUPMODE_BITS        0xc0
41 #define RR_BITS             0x03
42 #define LOOPMODE_BITS       0x41
43 #define RS232_MODE          0x00
44 #define RTSCTS_TO_CONNECTOR 0x40
45 #define CLKS_X4             0x02
46 #define FULLPWRBIT          0x00000080
47 #define NEXT_BOARD_POWER_BIT        0x00000004
48
49 static int debug;
50
51 /* Version Information */
52 #define DRIVER_VERSION "v0.1"
53 #define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver"
54
55 #define USB_VENDOR_ID_QUATECH   0x061d  /* Quatech VID */
56 #define QUATECH_SSU100  0xC020  /* SSU100 */
57
58 static const struct usb_device_id id_table[] = {
59         {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU100)},
60         {}                      /* Terminating entry */
61 };
62
63 MODULE_DEVICE_TABLE(usb, id_table);
64
65
66 static struct usb_driver ssu100_driver = {
67         .name                          = "ssu100",
68         .probe                         = usb_serial_probe,
69         .disconnect                    = usb_serial_disconnect,
70         .id_table                      = id_table,
71         .suspend                       = usb_serial_suspend,
72         .resume                        = usb_serial_resume,
73         .no_dynamic_id                 = 1,
74         .supports_autosuspend          = 1,
75 };
76
77 struct ssu100_port_private {
78         spinlock_t status_lock;
79         u8 shadowLSR;
80         u8 shadowMSR;
81         struct async_icount icount;
82 };
83
84 static void ssu100_release(struct usb_serial *serial)
85 {
86         struct ssu100_port_private *priv = usb_get_serial_port_data(*serial->port);
87
88         dbg("%s", __func__);
89         kfree(priv);
90 }
91
92 static inline int ssu100_control_msg(struct usb_device *dev,
93                                      u8 request, u16 data, u16 index)
94 {
95         return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
96                                request, 0x40, data, index,
97                                NULL, 0, 300);
98 }
99
100 static inline int ssu100_setdevice(struct usb_device *dev, u8 *data)
101 {
102         u16 x = ((u16)(data[1] << 8) | (u16)(data[0]));
103
104         return ssu100_control_msg(dev, QT_SET_GET_DEVICE, x, 0);
105 }
106
107
108 static inline int ssu100_getdevice(struct usb_device *dev, u8 *data)
109 {
110         int ret;
111
112         ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
113                               QT_SET_GET_DEVICE, 0xc0, 0, 0,
114                               data, 3, 300);
115         if (ret < 3) {
116                 if (ret >= 0)
117                         ret = -EIO;
118         }
119
120         return ret;
121 }
122
123 static inline int ssu100_getregister(struct usb_device *dev,
124                                      unsigned short uart,
125                                      unsigned short reg,
126                                      u8 *data)
127 {
128         int ret;
129
130         ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
131                               QT_SET_GET_REGISTER, 0xc0, reg,
132                               uart, data, sizeof(*data), 300);
133         if (ret < sizeof(*data)) {
134                 if (ret >= 0)
135                         ret = -EIO;
136         }
137
138         return ret;
139 }
140
141
142 static inline int ssu100_setregister(struct usb_device *dev,
143                                      unsigned short uart,
144                                      unsigned short reg,
145                                      u16 data)
146 {
147         u16 value = (data << 8) | reg;
148
149         return usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
150                                QT_SET_GET_REGISTER, 0x40, value, uart,
151                                NULL, 0, 300);
152
153 }
154
155 #define set_mctrl(dev, set)             update_mctrl((dev), (set), 0)
156 #define clear_mctrl(dev, clear) update_mctrl((dev), 0, (clear))
157
158 /* these do not deal with device that have more than 1 port */
159 static inline int update_mctrl(struct usb_device *dev, unsigned int set,
160                                unsigned int clear)
161 {
162         unsigned urb_value;
163         int result;
164
165         if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) {
166                 dbg("%s - DTR|RTS not being set|cleared", __func__);
167                 return 0;       /* no change */
168         }
169
170         clear &= ~set;  /* 'set' takes precedence over 'clear' */
171         urb_value = 0;
172         if (set & TIOCM_DTR)
173                 urb_value |= UART_MCR_DTR;
174         if (set & TIOCM_RTS)
175                 urb_value |= UART_MCR_RTS;
176
177         result = ssu100_setregister(dev, 0, UART_MCR, urb_value);
178         if (result < 0)
179                 dbg("%s Error from MODEM_CTRL urb", __func__);
180
181         return result;
182 }
183
184 static int ssu100_initdevice(struct usb_device *dev)
185 {
186         u8 *data;
187         int result = 0;
188
189         dbg("%s", __func__);
190
191         data = kzalloc(3, GFP_KERNEL);
192         if (!data)
193                 return -ENOMEM;
194
195         result = ssu100_getdevice(dev, data);
196         if (result < 0) {
197                 dbg("%s - get_device failed %i", __func__, result);
198                 goto out;
199         }
200
201         data[1] &= ~FULLPWRBIT;
202
203         result = ssu100_setdevice(dev, data);
204         if (result < 0) {
205                 dbg("%s - setdevice failed %i", __func__, result);
206                 goto out;
207         }
208
209         result = ssu100_control_msg(dev, QT_GET_SET_PREBUF_TRIG_LVL, 128, 0);
210         if (result < 0) {
211                 dbg("%s - set prebuffer level failed %i", __func__, result);
212                 goto out;
213         }
214
215         result = ssu100_control_msg(dev, QT_SET_ATF, ATC_DISABLED, 0);
216         if (result < 0) {
217                 dbg("%s - set ATFprebuffer level failed %i", __func__, result);
218                 goto out;
219         }
220
221         result = ssu100_getdevice(dev, data);
222         if (result < 0) {
223                 dbg("%s - get_device failed %i", __func__, result);
224                 goto out;
225         }
226
227         data[0] &= ~(RR_BITS | DUPMODE_BITS);
228         data[0] |= CLKS_X4;
229         data[1] &= ~(LOOPMODE_BITS);
230         data[1] |= RS232_MODE;
231
232         result = ssu100_setdevice(dev, data);
233         if (result < 0) {
234                 dbg("%s - setdevice failed %i", __func__, result);
235                 goto out;
236         }
237
238 out:    kfree(data);
239         return result;
240
241 }
242
243
244 static void ssu100_set_termios(struct tty_struct *tty,
245                                struct usb_serial_port *port,
246                                struct ktermios *old_termios)
247 {
248         struct usb_device *dev = port->serial->dev;
249         struct ktermios *termios = tty->termios;
250         u16 baud, divisor, remainder;
251         unsigned int cflag = termios->c_cflag;
252         u16 urb_value = 0; /* will hold the new flags */
253         int result;
254
255         dbg("%s", __func__);
256
257         if (cflag & PARENB) {
258                 if (cflag & PARODD)
259                         urb_value |= UART_LCR_PARITY;
260                 else
261                         urb_value |= SERIAL_EVEN_PARITY;
262         }
263
264         switch (cflag & CSIZE) {
265         case CS5:
266                 urb_value |= UART_LCR_WLEN5;
267                 break;
268         case CS6:
269                 urb_value |= UART_LCR_WLEN6;
270                 break;
271         case CS7:
272                 urb_value |= UART_LCR_WLEN7;
273                 break;
274         default:
275         case CS8:
276                 urb_value |= UART_LCR_WLEN8;
277                 break;
278         }
279
280         baud = tty_get_baud_rate(tty);
281         if (!baud)
282                 baud = 9600;
283
284         dbg("%s - got baud = %d\n", __func__, baud);
285
286
287         divisor = MAX_BAUD_RATE / baud;
288         remainder = MAX_BAUD_RATE % baud;
289         if (((remainder * 2) >= baud) && (baud != 110))
290                 divisor++;
291
292         urb_value = urb_value << 8;
293
294         result = ssu100_control_msg(dev, QT_GET_SET_UART, divisor, urb_value);
295         if (result < 0)
296                 dbg("%s - set uart failed", __func__);
297
298         if (cflag & CRTSCTS)
299                 result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK,
300                                             SERIAL_CRTSCTS, 0);
301         else
302                 result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK,
303                                             0, 0);
304         if (result < 0)
305                 dbg("%s - set HW flow control failed", __func__);
306
307         if (I_IXOFF(tty) || I_IXON(tty)) {
308                 u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty)));
309
310                 result = ssu100_control_msg(dev, QT_SW_FLOW_CONTROL_MASK,
311                                             x, 0);
312         } else
313                 result = ssu100_control_msg(dev, QT_SW_FLOW_CONTROL_MASK,
314                                             0, 0);
315
316         if (result < 0)
317                 dbg("%s - set SW flow control failed", __func__);
318
319 }
320
321
322 static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)
323 {
324         struct usb_device *dev = port->serial->dev;
325         struct ssu100_port_private *priv = usb_get_serial_port_data(port);
326         u8 *data;
327         int result;
328         unsigned long flags;
329
330         dbg("%s - port %d", __func__, port->number);
331
332         data = kzalloc(2, GFP_KERNEL);
333         if (!data)
334                 return -ENOMEM;
335
336         result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
337                                  QT_OPEN_CLOSE_CHANNEL,
338                                  QT_TRANSFER_IN, 0x01,
339                                  0, data, 2, 300);
340         if (result < 2) {
341                 dbg("%s - open failed %i", __func__, result);
342                 if (result >= 0)
343                         result = -EIO;
344                 kfree(data);
345                 return result;
346         }
347
348         spin_lock_irqsave(&priv->status_lock, flags);
349         priv->shadowLSR = data[0];
350         priv->shadowMSR = data[1];
351         spin_unlock_irqrestore(&priv->status_lock, flags);
352
353         kfree(data);
354
355 /* set to 9600 */
356         result = ssu100_control_msg(dev, QT_GET_SET_UART, 0x30, 0x0300);
357         if (result < 0)
358                 dbg("%s - set uart failed", __func__);
359
360         if (tty)
361                 ssu100_set_termios(tty, port, tty->termios);
362
363         return usb_serial_generic_open(tty, port);
364 }
365
366 static void ssu100_close(struct usb_serial_port *port)
367 {
368         dbg("%s", __func__);
369         usb_serial_generic_close(port);
370 }
371
372 static int get_serial_info(struct usb_serial_port *port,
373                            struct serial_struct __user *retinfo)
374 {
375         struct serial_struct tmp;
376
377         if (!retinfo)
378                 return -EFAULT;
379
380         memset(&tmp, 0, sizeof(tmp));
381         tmp.line                = port->serial->minor;
382         tmp.port                = 0;
383         tmp.irq                 = 0;
384         tmp.flags               = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
385         tmp.xmit_fifo_size      = port->bulk_out_size;
386         tmp.baud_base           = 9600;
387         tmp.close_delay         = 5*HZ;
388         tmp.closing_wait        = 30*HZ;
389
390         if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
391                 return -EFAULT;
392         return 0;
393 }
394
395 static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
396 {
397         struct ssu100_port_private *priv = usb_get_serial_port_data(port);
398         struct async_icount prev, cur;
399         unsigned long flags;
400
401         spin_lock_irqsave(&priv->status_lock, flags);
402         prev = priv->icount;
403         spin_unlock_irqrestore(&priv->status_lock, flags);
404
405         while (1) {
406                 wait_event_interruptible(port->delta_msr_wait,
407                                          (port->serial->disconnected ||
408                                           (priv->icount.rng != prev.rng) ||
409                                           (priv->icount.dsr != prev.dsr) ||
410                                           (priv->icount.dcd != prev.dcd) ||
411                                           (priv->icount.cts != prev.cts)));
412
413                 if (signal_pending(current))
414                         return -ERESTARTSYS;
415
416                 if (port->serial->disconnected)
417                         return -EIO;
418
419                 spin_lock_irqsave(&priv->status_lock, flags);
420                 cur = priv->icount;
421                 spin_unlock_irqrestore(&priv->status_lock, flags);
422
423                 if ((prev.rng == cur.rng) &&
424                     (prev.dsr == cur.dsr) &&
425                     (prev.dcd == cur.dcd) &&
426                     (prev.cts == cur.cts))
427                         return -EIO;
428
429                 if ((arg & TIOCM_RNG && (prev.rng != cur.rng)) ||
430                     (arg & TIOCM_DSR && (prev.dsr != cur.dsr)) ||
431                     (arg & TIOCM_CD  && (prev.dcd != cur.dcd)) ||
432                     (arg & TIOCM_CTS && (prev.cts != cur.cts)))
433                         return 0;
434         }
435         return 0;
436 }
437
438 static int ssu100_get_icount(struct tty_struct *tty,
439                         struct serial_icounter_struct *icount)
440 {
441         struct usb_serial_port *port = tty->driver_data;
442         struct ssu100_port_private *priv = usb_get_serial_port_data(port);
443         struct async_icount cnow = priv->icount;
444
445         icount->cts = cnow.cts;
446         icount->dsr = cnow.dsr;
447         icount->rng = cnow.rng;
448         icount->dcd = cnow.dcd;
449         icount->rx = cnow.rx;
450         icount->tx = cnow.tx;
451         icount->frame = cnow.frame;
452         icount->overrun = cnow.overrun;
453         icount->parity = cnow.parity;
454         icount->brk = cnow.brk;
455         icount->buf_overrun = cnow.buf_overrun;
456
457         return 0;
458 }
459
460
461
462 static int ssu100_ioctl(struct tty_struct *tty,
463                     unsigned int cmd, unsigned long arg)
464 {
465         struct usb_serial_port *port = tty->driver_data;
466
467         dbg("%s cmd 0x%04x", __func__, cmd);
468
469         switch (cmd) {
470         case TIOCGSERIAL:
471                 return get_serial_info(port,
472                                        (struct serial_struct __user *) arg);
473
474         case TIOCMIWAIT:
475                 return wait_modem_info(port, arg);
476
477         default:
478                 break;
479         }
480
481         dbg("%s arg not supported", __func__);
482
483         return -ENOIOCTLCMD;
484 }
485
486 static int ssu100_attach(struct usb_serial *serial)
487 {
488         struct ssu100_port_private *priv;
489         struct usb_serial_port *port = *serial->port;
490
491         dbg("%s", __func__);
492
493         priv = kzalloc(sizeof(*priv), GFP_KERNEL);
494         if (!priv) {
495                 dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__,
496                         sizeof(*priv));
497                 return -ENOMEM;
498         }
499
500         spin_lock_init(&priv->status_lock);
501         usb_set_serial_port_data(port, priv);
502
503         return ssu100_initdevice(serial->dev);
504 }
505
506 static int ssu100_tiocmget(struct tty_struct *tty)
507 {
508         struct usb_serial_port *port = tty->driver_data;
509         struct usb_device *dev = port->serial->dev;
510         u8 *d;
511         int r;
512
513         dbg("%s\n", __func__);
514
515         d = kzalloc(2, GFP_KERNEL);
516         if (!d)
517                 return -ENOMEM;
518
519         r = ssu100_getregister(dev, 0, UART_MCR, d);
520         if (r < 0)
521                 goto mget_out;
522
523         r = ssu100_getregister(dev, 0, UART_MSR, d+1);
524         if (r < 0)
525                 goto mget_out;
526
527         r = (d[0] & UART_MCR_DTR ? TIOCM_DTR : 0) |
528                 (d[0] & UART_MCR_RTS ? TIOCM_RTS : 0) |
529                 (d[1] & UART_MSR_CTS ? TIOCM_CTS : 0) |
530                 (d[1] & UART_MSR_DCD ? TIOCM_CAR : 0) |
531                 (d[1] & UART_MSR_RI ? TIOCM_RI : 0) |
532                 (d[1] & UART_MSR_DSR ? TIOCM_DSR : 0);
533
534 mget_out:
535         kfree(d);
536         return r;
537 }
538
539 static int ssu100_tiocmset(struct tty_struct *tty,
540                            unsigned int set, unsigned int clear)
541 {
542         struct usb_serial_port *port = tty->driver_data;
543         struct usb_device *dev = port->serial->dev;
544
545         dbg("%s\n", __func__);
546         return update_mctrl(dev, set, clear);
547 }
548
549 static void ssu100_dtr_rts(struct usb_serial_port *port, int on)
550 {
551         struct usb_device *dev = port->serial->dev;
552
553         dbg("%s\n", __func__);
554
555         /* Disable flow control */
556         if (!on) {
557                 if (ssu100_setregister(dev, 0, UART_MCR, 0) < 0)
558                         dev_err(&port->dev, "error from flowcontrol urb\n");
559         }
560         /* drop RTS and DTR */
561         if (on)
562                 set_mctrl(dev, TIOCM_DTR | TIOCM_RTS);
563         else
564                 clear_mctrl(dev, TIOCM_DTR | TIOCM_RTS);
565 }
566
567 static void ssu100_update_msr(struct usb_serial_port *port, u8 msr)
568 {
569         struct ssu100_port_private *priv = usb_get_serial_port_data(port);
570         unsigned long flags;
571
572         spin_lock_irqsave(&priv->status_lock, flags);
573         priv->shadowMSR = msr;
574         spin_unlock_irqrestore(&priv->status_lock, flags);
575
576         if (msr & UART_MSR_ANY_DELTA) {
577                 /* update input line counters */
578                 if (msr & UART_MSR_DCTS)
579                         priv->icount.cts++;
580                 if (msr & UART_MSR_DDSR)
581                         priv->icount.dsr++;
582                 if (msr & UART_MSR_DDCD)
583                         priv->icount.dcd++;
584                 if (msr & UART_MSR_TERI)
585                         priv->icount.rng++;
586                 wake_up_interruptible(&port->delta_msr_wait);
587         }
588 }
589
590 static void ssu100_update_lsr(struct usb_serial_port *port, u8 lsr,
591                               char *tty_flag)
592 {
593         struct ssu100_port_private *priv = usb_get_serial_port_data(port);
594         unsigned long flags;
595
596         spin_lock_irqsave(&priv->status_lock, flags);
597         priv->shadowLSR = lsr;
598         spin_unlock_irqrestore(&priv->status_lock, flags);
599
600         *tty_flag = TTY_NORMAL;
601         if (lsr & UART_LSR_BRK_ERROR_BITS) {
602                 /* we always want to update icount, but we only want to
603                  * update tty_flag for one case */
604                 if (lsr & UART_LSR_BI) {
605                         priv->icount.brk++;
606                         *tty_flag = TTY_BREAK;
607                         usb_serial_handle_break(port);
608                 }
609                 if (lsr & UART_LSR_PE) {
610                         priv->icount.parity++;
611                         if (*tty_flag == TTY_NORMAL)
612                                 *tty_flag = TTY_PARITY;
613                 }
614                 if (lsr & UART_LSR_FE) {
615                         priv->icount.frame++;
616                         if (*tty_flag == TTY_NORMAL)
617                                 *tty_flag = TTY_FRAME;
618                 }
619                 if (lsr & UART_LSR_OE) {
620                         priv->icount.overrun++;
621                         tty_insert_flip_char(tty_port_tty_get(&port->port),
622                                              0, TTY_OVERRUN);
623                 }
624         }
625
626 }
627
628 static int ssu100_process_packet(struct urb *urb,
629                                  struct tty_struct *tty)
630 {
631         struct usb_serial_port *port = urb->context;
632         char *packet = (char *)urb->transfer_buffer;
633         char flag = TTY_NORMAL;
634         u32 len = urb->actual_length;
635         int i;
636         char *ch;
637
638         dbg("%s - port %d", __func__, port->number);
639
640         if ((len >= 4) &&
641             (packet[0] == 0x1b) && (packet[1] == 0x1b) &&
642             ((packet[2] == 0x00) || (packet[2] == 0x01))) {
643                 if (packet[2] == 0x00)
644                         ssu100_update_lsr(port, packet[3], &flag);
645                 if (packet[2] == 0x01)
646                         ssu100_update_msr(port, packet[3]);
647
648                 len -= 4;
649                 ch = packet + 4;
650         } else
651                 ch = packet;
652
653         if (!len)
654                 return 0;       /* status only */
655
656         if (port->port.console && port->sysrq) {
657                 for (i = 0; i < len; i++, ch++) {
658                         if (!usb_serial_handle_sysrq_char(port, *ch))
659                                 tty_insert_flip_char(tty, *ch, flag);
660                 }
661         } else
662                 tty_insert_flip_string_fixed_flag(tty, ch, flag, len);
663
664         return len;
665 }
666
667 static void ssu100_process_read_urb(struct urb *urb)
668 {
669         struct usb_serial_port *port = urb->context;
670         struct tty_struct *tty;
671         int count;
672
673         dbg("%s", __func__);
674
675         tty = tty_port_tty_get(&port->port);
676         if (!tty)
677                 return;
678
679         count = ssu100_process_packet(urb, tty);
680
681         if (count)
682                 tty_flip_buffer_push(tty);
683         tty_kref_put(tty);
684 }
685
686 static struct usb_serial_driver ssu100_device = {
687         .driver = {
688                 .owner = THIS_MODULE,
689                 .name = "ssu100",
690         },
691         .description         = DRIVER_DESC,
692         .id_table            = id_table,
693         .usb_driver          = &ssu100_driver,
694         .num_ports           = 1,
695         .open                = ssu100_open,
696         .close               = ssu100_close,
697         .attach              = ssu100_attach,
698         .release             = ssu100_release,
699         .dtr_rts             = ssu100_dtr_rts,
700         .process_read_urb    = ssu100_process_read_urb,
701         .tiocmget            = ssu100_tiocmget,
702         .tiocmset            = ssu100_tiocmset,
703         .get_icount          = ssu100_get_icount,
704         .ioctl               = ssu100_ioctl,
705         .set_termios         = ssu100_set_termios,
706         .disconnect          = usb_serial_generic_disconnect,
707 };
708
709 static int __init ssu100_init(void)
710 {
711         int retval;
712
713         dbg("%s", __func__);
714
715         /* register with usb-serial */
716         retval = usb_serial_register(&ssu100_device);
717
718         if (retval)
719                 goto failed_usb_sio_register;
720
721         retval = usb_register(&ssu100_driver);
722         if (retval)
723                 goto failed_usb_register;
724
725         printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
726                DRIVER_DESC "\n");
727
728         return 0;
729
730 failed_usb_register:
731         usb_serial_deregister(&ssu100_device);
732 failed_usb_sio_register:
733         return retval;
734 }
735
736 static void __exit ssu100_exit(void)
737 {
738         usb_deregister(&ssu100_driver);
739         usb_serial_deregister(&ssu100_device);
740 }
741
742 module_init(ssu100_init);
743 module_exit(ssu100_exit);
744
745 MODULE_DESCRIPTION(DRIVER_DESC);
746 MODULE_LICENSE("GPL");
747
748 module_param(debug, bool, S_IRUGO | S_IWUSR);
749 MODULE_PARM_DESC(debug, "Debug enabled or not");