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