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