blob: e67ce25f7512627dad57bf4930d2ca26c6bc413a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#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>
Greg Kroah-Hartmana9698882006-07-11 21:22:58 -070077#include <linux/usb/serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#include "belkin_sa.h"
79
80static 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 */
90static int belkin_sa_startup (struct usb_serial *serial);
91static void belkin_sa_shutdown (struct usb_serial *serial);
92static int belkin_sa_open (struct usb_serial_port *port, struct file *filp);
93static void belkin_sa_close (struct usb_serial_port *port, struct file *filp);
David Howells7d12e782006-10-05 14:55:46 +010094static void belkin_sa_read_int_callback (struct urb *urb);
Alan Cox606d0992006-12-08 02:38:45 -080095static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios * old);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
97static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state );
98static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file);
99static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
100
101
102static 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
112MODULE_DEVICE_TABLE (usb, id_table_combined);
113
114static struct usb_driver belkin_driver = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 .name = "belkin",
116 .probe = usb_serial_probe,
117 .disconnect = usb_serial_disconnect,
118 .id_table = id_table_combined,
Greg Kroah-Hartmanba9dc652005-11-16 13:41:28 -0800119 .no_dynamic_id = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120};
121
122/* All of the device info needed for the serial converters */
Greg Kroah-Hartmanea653702005-06-20 21:15:16 -0700123static struct usb_serial_driver belkin_device = {
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -0700124 .driver = {
125 .owner = THIS_MODULE,
Greg Kroah-Hartman269bda12005-06-20 21:15:16 -0700126 .name = "belkin",
Greg Kroah-Hartman18fcac32005-06-20 21:15:16 -0700127 },
Greg Kroah-Hartman269bda12005-06-20 21:15:16 -0700128 .description = "Belkin / Peracom / GoHubs USB Serial Adapter",
Johannes Hölzld9b1b782006-12-17 21:50:24 +0100129 .usb_driver = &belkin_driver,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 .id_table = id_table_combined,
131 .num_interrupt_in = 1,
132 .num_bulk_in = 1,
133 .num_bulk_out = 1,
134 .num_ports = 1,
135 .open = belkin_sa_open,
136 .close = belkin_sa_close,
137 .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */
138 .ioctl = belkin_sa_ioctl,
139 .set_termios = belkin_sa_set_termios,
140 .break_ctl = belkin_sa_break_ctl,
141 .tiocmget = belkin_sa_tiocmget,
142 .tiocmset = belkin_sa_tiocmset,
143 .attach = belkin_sa_startup,
144 .shutdown = belkin_sa_shutdown,
145};
146
147
148struct belkin_sa_private {
149 spinlock_t lock;
150 unsigned long control_state;
151 unsigned char last_lsr;
152 unsigned char last_msr;
153 int bad_flow_control;
154};
155
156
157/*
158 * ***************************************************************************
159 * Belkin USB Serial Adapter F5U103 specific driver functions
160 * ***************************************************************************
161 */
162
163#define WDR_TIMEOUT 5000 /* default urb timeout */
164
165/* assumes that struct usb_serial *serial is available */
166#define BSA_USB_CMD(c,v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
167 (c), BELKIN_SA_SET_REQUEST_TYPE, \
168 (v), 0, NULL, 0, WDR_TIMEOUT)
169
170/* do some startup allocations not currently performed by usb_serial_probe() */
171static int belkin_sa_startup (struct usb_serial *serial)
172{
173 struct usb_device *dev = serial->dev;
174 struct belkin_sa_private *priv;
175
176 /* allocate the private data structure */
177 priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
178 if (!priv)
179 return (-1); /* error */
180 /* set initial values for control structures */
181 spin_lock_init(&priv->lock);
182 priv->control_state = 0;
183 priv->last_lsr = 0;
184 priv->last_msr = 0;
185 /* see comments at top of file */
186 priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;
187 info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control);
188
189 init_waitqueue_head(&serial->port[0]->write_wait);
190 usb_set_serial_port_data(serial->port[0], priv);
191
192 return (0);
193}
194
195
196static void belkin_sa_shutdown (struct usb_serial *serial)
197{
198 struct belkin_sa_private *priv;
199 int i;
200
201 dbg ("%s", __FUNCTION__);
202
203 /* stop reads and writes on all ports */
204 for (i=0; i < serial->num_ports; ++i) {
205 /* My special items, the standard routines free my urbs */
206 priv = usb_get_serial_port_data(serial->port[i]);
Jesper Juhl1bc3c9e2005-04-18 17:39:34 -0700207 kfree(priv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 }
209}
210
211
212static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
213{
214 int retval = 0;
215
216 dbg("%s port %d", __FUNCTION__, port->number);
217
218 /*Start reading from the device*/
219 /* TODO: Look at possibility of submitting multiple URBs to device to
220 * enhance buffering. Win trace shows 16 initial read URBs.
221 */
222 port->read_urb->dev = port->serial->dev;
223 retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
224 if (retval) {
225 err("usb_submit_urb(read bulk) failed");
226 goto exit;
227 }
228
229 port->interrupt_in_urb->dev = port->serial->dev;
230 retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
231 if (retval) {
232 usb_kill_urb(port->read_urb);
233 err(" usb_submit_urb(read int) failed");
234 }
235
236exit:
237 return retval;
238} /* belkin_sa_open */
239
240
241static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
242{
243 dbg("%s port %d", __FUNCTION__, port->number);
244
245 /* shutdown our bulk reads and writes */
246 usb_kill_urb(port->write_urb);
247 usb_kill_urb(port->read_urb);
248 usb_kill_urb(port->interrupt_in_urb);
249} /* belkin_sa_close */
250
251
David Howells7d12e782006-10-05 14:55:46 +0100252static void belkin_sa_read_int_callback (struct urb *urb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253{
254 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
255 struct belkin_sa_private *priv;
256 unsigned char *data = urb->transfer_buffer;
257 int retval;
Greg Kroah-Hartmanf26aad22007-06-15 15:44:13 -0700258 int status = urb->status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 unsigned long flags;
260
Greg Kroah-Hartmanf26aad22007-06-15 15:44:13 -0700261 switch (status) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 case 0:
263 /* success */
264 break;
265 case -ECONNRESET:
266 case -ENOENT:
267 case -ESHUTDOWN:
268 /* this urb is terminated, clean up */
Greg Kroah-Hartmanf26aad22007-06-15 15:44:13 -0700269 dbg("%s - urb shutting down with status: %d",
270 __FUNCTION__, status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 return;
272 default:
Greg Kroah-Hartmanf26aad22007-06-15 15:44:13 -0700273 dbg("%s - nonzero urb status received: %d",
274 __FUNCTION__, status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 goto exit;
276 }
277
278 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
279
280 /* Handle known interrupt data */
281 /* ignore data[0] and data[1] */
282
283 priv = usb_get_serial_port_data(port);
284 spin_lock_irqsave(&priv->lock, flags);
285 priv->last_msr = data[BELKIN_SA_MSR_INDEX];
286
287 /* Record Control Line states */
288 if (priv->last_msr & BELKIN_SA_MSR_DSR)
289 priv->control_state |= TIOCM_DSR;
290 else
291 priv->control_state &= ~TIOCM_DSR;
292
293 if (priv->last_msr & BELKIN_SA_MSR_CTS)
294 priv->control_state |= TIOCM_CTS;
295 else
296 priv->control_state &= ~TIOCM_CTS;
297
298 if (priv->last_msr & BELKIN_SA_MSR_RI)
299 priv->control_state |= TIOCM_RI;
300 else
301 priv->control_state &= ~TIOCM_RI;
302
303 if (priv->last_msr & BELKIN_SA_MSR_CD)
304 priv->control_state |= TIOCM_CD;
305 else
306 priv->control_state &= ~TIOCM_CD;
307
308 /* Now to report any errors */
309 priv->last_lsr = data[BELKIN_SA_LSR_INDEX];
310#if 0
311 /*
312 * fill in the flip buffer here, but I do not know the relation
313 * to the current/next receive buffer or characters. I need
314 * to look in to this before committing any code.
315 */
316 if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
317 tty = port->tty;
318 /* Overrun Error */
319 if (priv->last_lsr & BELKIN_SA_LSR_OE) {
320 }
321 /* Parity Error */
322 if (priv->last_lsr & BELKIN_SA_LSR_PE) {
323 }
324 /* Framing Error */
325 if (priv->last_lsr & BELKIN_SA_LSR_FE) {
326 }
327 /* Break Indicator */
328 if (priv->last_lsr & BELKIN_SA_LSR_BI) {
329 }
330 }
331#endif
332 spin_unlock_irqrestore(&priv->lock, flags);
333exit:
334 retval = usb_submit_urb (urb, GFP_ATOMIC);
335 if (retval)
336 err ("%s - usb_submit_urb failed with result %d",
337 __FUNCTION__, retval);
338}
339
Alan Cox606d0992006-12-08 02:38:45 -0800340static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341{
342 struct usb_serial *serial = port->serial;
343 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
344 unsigned int iflag;
345 unsigned int cflag;
346 unsigned int old_iflag = 0;
347 unsigned int old_cflag = 0;
348 __u16 urb_value = 0; /* Will hold the new flags */
349 unsigned long flags;
350 unsigned long control_state;
351 int bad_flow_control;
Alan Cox9a8baec2007-06-22 14:40:18 +0100352 speed_t baud;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 if ((!port->tty) || (!port->tty->termios)) {
355 dbg ("%s - no tty or termios structure", __FUNCTION__);
356 return;
357 }
358
359 iflag = port->tty->termios->c_iflag;
360 cflag = port->tty->termios->c_cflag;
361
362 /* get a local copy of the current port settings */
363 spin_lock_irqsave(&priv->lock, flags);
364 control_state = priv->control_state;
365 bad_flow_control = priv->bad_flow_control;
366 spin_unlock_irqrestore(&priv->lock, flags);
367
Alan Cox9a8baec2007-06-22 14:40:18 +0100368 old_iflag = old_termios->c_iflag;
369 old_cflag = old_termios->c_cflag;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370
371 /* Set the baud rate */
372 if( (cflag&CBAUD) != (old_cflag&CBAUD) ) {
373 /* reassert DTR and (maybe) RTS on transition from B0 */
374 if( (old_cflag&CBAUD) == B0 ) {
375 control_state |= (TIOCM_DTR|TIOCM_RTS);
376 if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
377 err("Set DTR error");
378 /* don't set RTS if using hardware flow control */
379 if (!(old_cflag&CRTSCTS) )
380 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
381 err("Set RTS error");
382 }
Alan Cox9a8baec2007-06-22 14:40:18 +0100383 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
Alan Cox9a8baec2007-06-22 14:40:18 +0100385 baud = tty_get_baud_rate(port->tty);
386 urb_value = BELKIN_SA_BAUD(baud);
387 /* Clip to maximum speed */
388 if (urb_value == 0)
389 urb_value = 1;
390 /* Turn it back into a resulting real baud rate */
391 baud = BELKIN_SA_BAUD(urb_value);
392 /* FIXME: Once the tty updates are done then push this back to the tty */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
Alan Cox9a8baec2007-06-22 14:40:18 +0100394 if ((cflag & CBAUD) != B0 ) {
395 if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
396 err("Set baudrate error");
397 } else {
398 /* Disable flow control */
399 if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0)
400 err("Disable flowcontrol error");
401 /* Drop RTS and DTR */
402 control_state &= ~(TIOCM_DTR | TIOCM_RTS);
403 if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
404 err("DTR LOW error");
405 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
406 err("RTS LOW error");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 }
408
409 /* set the parity */
410 if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) {
411 if (cflag & PARENB)
412 urb_value = (cflag & PARODD) ? BELKIN_SA_PARITY_ODD : BELKIN_SA_PARITY_EVEN;
413 else
414 urb_value = BELKIN_SA_PARITY_NONE;
415 if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0)
416 err("Set parity error");
417 }
418
419 /* set the number of data bits */
420 if( (cflag&CSIZE) != (old_cflag&CSIZE) ) {
421 switch (cflag & CSIZE) {
422 case CS5: urb_value = BELKIN_SA_DATA_BITS(5); break;
423 case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break;
424 case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break;
425 case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break;
Alan Cox9a8baec2007-06-22 14:40:18 +0100426 default: dbg("CSIZE was not CS5-CS8, using default of 8");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 urb_value = BELKIN_SA_DATA_BITS(8);
428 break;
429 }
430 if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0)
431 err("Set data bits error");
432 }
433
434 /* set the number of stop bits */
435 if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) {
436 urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) : BELKIN_SA_STOP_BITS(1);
437 if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value) < 0)
438 err("Set stop bits error");
439 }
440
441 /* Set flow control */
442 if( (iflag&IXOFF) != (old_iflag&IXOFF)
443 || (iflag&IXON) != (old_iflag&IXON)
444 || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) {
445 urb_value = 0;
446 if ((iflag & IXOFF) || (iflag & IXON))
447 urb_value |= (BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
448 else
449 urb_value &= ~(BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
450
451 if (cflag & CRTSCTS)
452 urb_value |= (BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
453 else
454 urb_value &= ~(BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
455
456 if (bad_flow_control)
457 urb_value &= ~(BELKIN_SA_FLOW_IRTS);
458
459 if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0)
460 err("Set flow control error");
461 }
462
463 /* save off the modified port settings */
464 spin_lock_irqsave(&priv->lock, flags);
465 priv->control_state = control_state;
466 spin_unlock_irqrestore(&priv->lock, flags);
467} /* belkin_sa_set_termios */
468
469
470static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
471{
472 struct usb_serial *serial = port->serial;
473
474 if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
475 err("Set break_ctl %d", break_state);
476}
477
478
479static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
480{
481 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
482 unsigned long control_state;
483 unsigned long flags;
484
485 dbg("%s", __FUNCTION__);
486
487 spin_lock_irqsave(&priv->lock, flags);
488 control_state = priv->control_state;
489 spin_unlock_irqrestore(&priv->lock, flags);
490
491 return control_state;
492}
493
494
495static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
496 unsigned int set, unsigned int clear)
497{
498 struct usb_serial *serial = port->serial;
499 struct belkin_sa_private *priv = usb_get_serial_port_data(port);
500 unsigned long control_state;
501 unsigned long flags;
502 int retval;
503 int rts = 0;
504 int dtr = 0;
505
506 dbg("%s", __FUNCTION__);
507
508 spin_lock_irqsave(&priv->lock, flags);
509 control_state = priv->control_state;
510
511 if (set & TIOCM_RTS) {
512 control_state |= TIOCM_RTS;
513 rts = 1;
514 }
515 if (set & TIOCM_DTR) {
516 control_state |= TIOCM_DTR;
517 dtr = 1;
518 }
519 if (clear & TIOCM_RTS) {
520 control_state &= ~TIOCM_RTS;
521 rts = 0;
522 }
523 if (clear & TIOCM_DTR) {
524 control_state &= ~TIOCM_DTR;
525 dtr = 0;
526 }
527
528 priv->control_state = control_state;
529 spin_unlock_irqrestore(&priv->lock, flags);
530
531 retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts);
532 if (retval < 0) {
533 err("Set RTS error %d", retval);
534 goto exit;
535 }
536
537 retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr);
538 if (retval < 0) {
539 err("Set DTR error %d", retval);
540 goto exit;
541 }
542exit:
543 return retval;
544}
545
546
547static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
548{
549 switch (cmd) {
550 case TIOCMIWAIT:
551 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
552 /* TODO */
553 return( 0 );
554
555 case TIOCGICOUNT:
556 /* return count of modemline transitions */
557 /* TODO */
558 return 0;
559
560 default:
561 dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd);
562 return(-ENOIOCTLCMD);
563 break;
564 }
565 return 0;
566} /* belkin_sa_ioctl */
567
568
569static int __init belkin_sa_init (void)
570{
571 int retval;
572 retval = usb_serial_register(&belkin_device);
573 if (retval)
574 goto failed_usb_serial_register;
575 retval = usb_register(&belkin_driver);
576 if (retval)
577 goto failed_usb_register;
578 info(DRIVER_DESC " " DRIVER_VERSION);
579 return 0;
580failed_usb_register:
581 usb_serial_deregister(&belkin_device);
582failed_usb_serial_register:
583 return retval;
584}
585
586
587static void __exit belkin_sa_exit (void)
588{
589 usb_deregister (&belkin_driver);
590 usb_serial_deregister (&belkin_device);
591}
592
593
594module_init (belkin_sa_init);
595module_exit (belkin_sa_exit);
596
597MODULE_AUTHOR( DRIVER_AUTHOR );
598MODULE_DESCRIPTION( DRIVER_DESC );
599MODULE_VERSION( DRIVER_VERSION );
600MODULE_LICENSE("GPL");
601
602module_param(debug, bool, S_IRUGO | S_IWUSR);
603MODULE_PARM_DESC(debug, "Debug enabled or not");