belkin_sa.c 14.6 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4
/*
 * Belkin USB Serial Adapter Driver
 *
 *  Copyright (C) 2000		William Greathouse (wgreathouse@smva.com)
5
 *  Copyright (C) 2000-2001	Greg Kroah-Hartman (greg@kroah.com)
6
 *  Copyright (C) 2010		Johan Hovold (jhovold@gmail.com)
L
Linus Torvalds 已提交
7 8 9 10
 *
 *  This program is largely derived from work by the linux-usb group
 *  and associated source files.  Please see the usb/serial files for
 *  individual credits and copyrights.
A
Alan Cox 已提交
11
 *
12 13 14 15
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
L
Linus Torvalds 已提交
16
 *
A
Alan Cox 已提交
17 18
 * See Documentation/usb/usb-serial.txt for more information on using this
 * driver
L
Linus Torvalds 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 *
 * TODO:
 * -- Add true modem contol line query capability.  Currently we track the
 *    states reported by the interrupt and the states we request.
 * -- Add support for flush commands
 */

#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/spinlock.h>
A
Alan Cox 已提交
35
#include <linux/uaccess.h>
L
Linus Torvalds 已提交
36
#include <linux/usb.h>
37
#include <linux/usb/serial.h>
L
Linus Torvalds 已提交
38 39
#include "belkin_sa.h"

40
static bool debug;
L
Linus Torvalds 已提交
41 42 43 44

/*
 * Version Information
 */
45
#define DRIVER_VERSION "v1.3"
L
Linus Torvalds 已提交
46 47 48 49
#define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>"
#define DRIVER_DESC "USB Belkin Serial converter driver"

/* function prototypes for a Belkin USB Serial Adapter F5U103 */
A
Alan Cox 已提交
50
static int  belkin_sa_startup(struct usb_serial *serial);
51
static void belkin_sa_release(struct usb_serial *serial);
A
Alan Cox 已提交
52
static int  belkin_sa_open(struct tty_struct *tty,
53
			struct usb_serial_port *port);
54
static void belkin_sa_close(struct usb_serial_port *port);
A
Alan Cox 已提交
55
static void belkin_sa_read_int_callback(struct urb *urb);
56
static void belkin_sa_process_read_urb(struct urb *urb);
A
Alan Cox 已提交
57 58 59
static void belkin_sa_set_termios(struct tty_struct *tty,
			struct usb_serial_port *port, struct ktermios * old);
static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state);
60
static int  belkin_sa_tiocmget(struct tty_struct *tty);
61
static int  belkin_sa_tiocmset(struct tty_struct *tty,
A
Alan Cox 已提交
62
					unsigned int set, unsigned int clear);
L
Linus Torvalds 已提交
63 64


65
static const struct usb_device_id id_table[] = {
L
Linus Torvalds 已提交
66 67 68 69 70 71
	{ USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) },
	{ USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) },
	{ USB_DEVICE(PERACOM_VID, PERACOM_PID) },
	{ USB_DEVICE(GOHUBS_VID, GOHUBS_PID) },
	{ USB_DEVICE(GOHUBS_VID, HANDYLINK_PID) },
	{ USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) },
A
Alan Cox 已提交
72
	{ }	/* Terminating entry */
L
Linus Torvalds 已提交
73
};
74
MODULE_DEVICE_TABLE(usb, id_table);
L
Linus Torvalds 已提交
75 76

/* All of the device info needed for the serial converters */
77
static struct usb_serial_driver belkin_device = {
78 79
	.driver = {
		.owner =	THIS_MODULE,
80
		.name =		"belkin",
81
	},
82
	.description =		"Belkin / Peracom / GoHubs USB Serial Adapter",
83
	.id_table =		id_table,
L
Linus Torvalds 已提交
84 85 86
	.num_ports =		1,
	.open =			belkin_sa_open,
	.close =		belkin_sa_close,
A
Alan Cox 已提交
87
	.read_int_callback =	belkin_sa_read_int_callback,
88
	.process_read_urb =	belkin_sa_process_read_urb,
L
Linus Torvalds 已提交
89 90 91 92 93
	.set_termios =		belkin_sa_set_termios,
	.break_ctl =		belkin_sa_break_ctl,
	.tiocmget =		belkin_sa_tiocmget,
	.tiocmset =		belkin_sa_tiocmset,
	.attach =		belkin_sa_startup,
94
	.release =		belkin_sa_release,
L
Linus Torvalds 已提交
95 96
};

97 98 99 100
static struct usb_serial_driver * const serial_drivers[] = {
	&belkin_device, NULL
};

L
Linus Torvalds 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
struct belkin_sa_private {
	spinlock_t		lock;
	unsigned long		control_state;
	unsigned char		last_lsr;
	unsigned char		last_msr;
	int			bad_flow_control;
};


/*
 * ***************************************************************************
 * Belkin USB Serial Adapter F5U103 specific driver functions
 * ***************************************************************************
 */

#define WDR_TIMEOUT 5000 /* default urb timeout */

/* assumes that struct usb_serial *serial is available */
A
Alan Cox 已提交
119
#define BSA_USB_CMD(c, v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
L
Linus Torvalds 已提交
120 121 122 123
					    (c), BELKIN_SA_SET_REQUEST_TYPE, \
					    (v), 0, NULL, 0, WDR_TIMEOUT)

/* do some startup allocations not currently performed by usb_serial_probe() */
A
Alan Cox 已提交
124
static int belkin_sa_startup(struct usb_serial *serial)
L
Linus Torvalds 已提交
125 126 127 128 129 130 131
{
	struct usb_device *dev = serial->dev;
	struct belkin_sa_private *priv;

	/* allocate the private data structure */
	priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
	if (!priv)
A
Alan Cox 已提交
132
		return -1; /* error */
L
Linus Torvalds 已提交
133 134 135 136 137 138
	/* set initial values for control structures */
	spin_lock_init(&priv->lock);
	priv->control_state = 0;
	priv->last_lsr = 0;
	priv->last_msr = 0;
	/* see comments at top of file */
A
Alan Cox 已提交
139 140
	priv->bad_flow_control =
		(le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;
141
	dev_info(&dev->dev, "bcdDevice: %04x, bfc: %d\n",
A
Alan Cox 已提交
142 143
					le16_to_cpu(dev->descriptor.bcdDevice),
					priv->bad_flow_control);
L
Linus Torvalds 已提交
144 145 146

	init_waitqueue_head(&serial->port[0]->write_wait);
	usb_set_serial_port_data(serial->port[0], priv);
A
Alan Cox 已提交
147 148

	return 0;
L
Linus Torvalds 已提交
149 150
}

151
static void belkin_sa_release(struct usb_serial *serial)
L
Linus Torvalds 已提交
152 153
{
	int i;
A
Alan Cox 已提交
154

J
Johan Hovold 已提交
155 156
	for (i = 0; i < serial->num_ports; ++i)
		kfree(usb_get_serial_port_data(serial->port[i]));
L
Linus Torvalds 已提交
157 158
}

J
Johan Hovold 已提交
159
static int belkin_sa_open(struct tty_struct *tty,
160
					struct usb_serial_port *port)
L
Linus Torvalds 已提交
161
{
J
Johan Hovold 已提交
162
	int retval;
L
Linus Torvalds 已提交
163 164 165

	retval = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
	if (retval) {
166
		dev_err(&port->dev, "usb_submit_urb(read int) failed\n");
J
Johan Hovold 已提交
167
		return retval;
L
Linus Torvalds 已提交
168 169
	}

J
Johan Hovold 已提交
170 171 172 173
	retval = usb_serial_generic_open(tty, port);
	if (retval)
		usb_kill_urb(port->interrupt_in_urb);

L
Linus Torvalds 已提交
174
	return retval;
J
Johan Hovold 已提交
175
}
L
Linus Torvalds 已提交
176

177
static void belkin_sa_close(struct usb_serial_port *port)
L
Linus Torvalds 已提交
178
{
179
	usb_serial_generic_close(port);
L
Linus Torvalds 已提交
180
	usb_kill_urb(port->interrupt_in_urb);
J
Johan Hovold 已提交
181
}
L
Linus Torvalds 已提交
182

A
Alan Cox 已提交
183
static void belkin_sa_read_int_callback(struct urb *urb)
L
Linus Torvalds 已提交
184
{
185
	struct usb_serial_port *port = urb->context;
L
Linus Torvalds 已提交
186 187 188
	struct belkin_sa_private *priv;
	unsigned char *data = urb->transfer_buffer;
	int retval;
189
	int status = urb->status;
L
Linus Torvalds 已提交
190 191
	unsigned long flags;

192
	switch (status) {
L
Linus Torvalds 已提交
193 194 195 196 197 198 199
	case 0:
		/* success */
		break;
	case -ECONNRESET:
	case -ENOENT:
	case -ESHUTDOWN:
		/* this urb is terminated, clean up */
200 201
		dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n",
			__func__, status);
L
Linus Torvalds 已提交
202 203
		return;
	default:
204 205
		dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n",
			__func__, status);
L
Linus Torvalds 已提交
206 207 208
		goto exit;
	}

A
Alan Cox 已提交
209 210
	usb_serial_debug_data(debug, &port->dev, __func__,
					urb->actual_length, data);
L
Linus Torvalds 已提交
211 212 213 214 215 216 217

	/* Handle known interrupt data */
	/* ignore data[0] and data[1] */

	priv = usb_get_serial_port_data(port);
	spin_lock_irqsave(&priv->lock, flags);
	priv->last_msr = data[BELKIN_SA_MSR_INDEX];
A
Alan Cox 已提交
218

L
Linus Torvalds 已提交
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
	/* Record Control Line states */
	if (priv->last_msr & BELKIN_SA_MSR_DSR)
		priv->control_state |= TIOCM_DSR;
	else
		priv->control_state &= ~TIOCM_DSR;

	if (priv->last_msr & BELKIN_SA_MSR_CTS)
		priv->control_state |= TIOCM_CTS;
	else
		priv->control_state &= ~TIOCM_CTS;

	if (priv->last_msr & BELKIN_SA_MSR_RI)
		priv->control_state |= TIOCM_RI;
	else
		priv->control_state &= ~TIOCM_RI;

	if (priv->last_msr & BELKIN_SA_MSR_CD)
		priv->control_state |= TIOCM_CD;
	else
		priv->control_state &= ~TIOCM_CD;

	priv->last_lsr = data[BELKIN_SA_LSR_INDEX];
	spin_unlock_irqrestore(&priv->lock, flags);
exit:
A
Alan Cox 已提交
243
	retval = usb_submit_urb(urb, GFP_ATOMIC);
L
Linus Torvalds 已提交
244
	if (retval)
245 246
		dev_err(&port->dev, "%s - usb_submit_urb failed with "
			"result %d\n", __func__, retval);
L
Linus Torvalds 已提交
247 248
}

249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
static void belkin_sa_process_read_urb(struct urb *urb)
{
	struct usb_serial_port *port = urb->context;
	struct belkin_sa_private *priv = usb_get_serial_port_data(port);
	struct tty_struct *tty;
	unsigned char *data = urb->transfer_buffer;
	unsigned long flags;
	unsigned char status;
	char tty_flag;

	/* Update line status */
	tty_flag = TTY_NORMAL;

	spin_lock_irqsave(&priv->lock, flags);
	status = priv->last_lsr;
	priv->last_lsr &= ~BELKIN_SA_LSR_ERR;
	spin_unlock_irqrestore(&priv->lock, flags);

	if (!urb->actual_length)
		return;

	tty = tty_port_tty_get(&port->port);
	if (!tty)
		return;

	if (status & BELKIN_SA_LSR_ERR) {
		/* Break takes precedence over parity, which takes precedence
		 * over framing errors. */
		if (status & BELKIN_SA_LSR_BI)
			tty_flag = TTY_BREAK;
		else if (status & BELKIN_SA_LSR_PE)
			tty_flag = TTY_PARITY;
		else if (status & BELKIN_SA_LSR_FE)
			tty_flag = TTY_FRAME;
		dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag);

		/* Overrun is special, not associated with a char. */
		if (status & BELKIN_SA_LSR_OE)
			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
	}

	tty_insert_flip_string_fixed_flag(tty, data, tty_flag,
							urb->actual_length);
	tty_flip_buffer_push(tty);
	tty_kref_put(tty);
}

A
Alan Cox 已提交
296 297
static void belkin_sa_set_termios(struct tty_struct *tty,
		struct usb_serial_port *port, struct ktermios *old_termios)
L
Linus Torvalds 已提交
298 299 300 301 302 303 304 305 306 307 308
{
	struct usb_serial *serial = port->serial;
	struct belkin_sa_private *priv = usb_get_serial_port_data(port);
	unsigned int iflag;
	unsigned int cflag;
	unsigned int old_iflag = 0;
	unsigned int old_cflag = 0;
	__u16 urb_value = 0; /* Will hold the new flags */
	unsigned long flags;
	unsigned long control_state;
	int bad_flow_control;
309
	speed_t baud;
310
	struct ktermios *termios = &tty->termios;
A
Alan Cox 已提交
311

312 313
	iflag = termios->c_iflag;
	cflag = termios->c_cflag;
L
Linus Torvalds 已提交
314

315
	termios->c_cflag &= ~CMSPAR;
L
Linus Torvalds 已提交
316 317 318 319 320 321

	/* get a local copy of the current port settings */
	spin_lock_irqsave(&priv->lock, flags);
	control_state = priv->control_state;
	bad_flow_control = priv->bad_flow_control;
	spin_unlock_irqrestore(&priv->lock, flags);
A
Alan Cox 已提交
322

323 324
	old_iflag = old_termios->c_iflag;
	old_cflag = old_termios->c_cflag;
L
Linus Torvalds 已提交
325 326

	/* Set the baud rate */
327
	if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
L
Linus Torvalds 已提交
328
		/* reassert DTR and (maybe) RTS on transition from B0 */
A
Alan Cox 已提交
329
		if ((old_cflag & CBAUD) == B0) {
L
Linus Torvalds 已提交
330 331
			control_state |= (TIOCM_DTR|TIOCM_RTS);
			if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
332
				dev_err(&port->dev, "Set DTR error\n");
L
Linus Torvalds 已提交
333
			/* don't set RTS if using hardware flow control */
334
			if (!(old_cflag & CRTSCTS))
A
Alan Cox 已提交
335 336
				if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST
								, 1) < 0)
337
					dev_err(&port->dev, "Set RTS error\n");
L
Linus Torvalds 已提交
338
		}
339
	}
L
Linus Torvalds 已提交
340

A
Alan Cox 已提交
341
	baud = tty_get_baud_rate(tty);
342 343 344 345 346 347 348 349 350
	if (baud) {
		urb_value = BELKIN_SA_BAUD(baud);
		/* Clip to maximum speed */
		if (urb_value == 0)
			urb_value = 1;
		/* Turn it back into a resulting real baud rate */
		baud = BELKIN_SA_BAUD(urb_value);

		/* Report the actual baud rate back to the caller */
A
Alan Cox 已提交
351
		tty_encode_baud_rate(tty, baud, baud);
352
		if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
353
			dev_err(&port->dev, "Set baudrate error\n");
354 355
	} else {
		/* Disable flow control */
A
Alan Cox 已提交
356 357
		if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST,
						BELKIN_SA_FLOW_NONE) < 0)
358
			dev_err(&port->dev, "Disable flowcontrol error\n");
359 360 361
		/* Drop RTS and DTR */
		control_state &= ~(TIOCM_DTR | TIOCM_RTS);
		if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
362
			dev_err(&port->dev, "DTR LOW error\n");
363
		if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
364
			dev_err(&port->dev, "RTS LOW error\n");
L
Linus Torvalds 已提交
365 366 367
	}

	/* set the parity */
A
Alan Cox 已提交
368
	if ((cflag ^ old_cflag) & (PARENB | PARODD)) {
L
Linus Torvalds 已提交
369
		if (cflag & PARENB)
A
Alan Cox 已提交
370 371
			urb_value = (cflag & PARODD) ?  BELKIN_SA_PARITY_ODD
						: BELKIN_SA_PARITY_EVEN;
L
Linus Torvalds 已提交
372 373 374
		else
			urb_value = BELKIN_SA_PARITY_NONE;
		if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0)
375
			dev_err(&port->dev, "Set parity error\n");
L
Linus Torvalds 已提交
376 377 378
	}

	/* set the number of data bits */
A
Alan Cox 已提交
379
	if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
L
Linus Torvalds 已提交
380
		switch (cflag & CSIZE) {
A
Alan Cox 已提交
381 382 383 384 385 386 387 388 389 390 391 392
		case CS5:
			urb_value = BELKIN_SA_DATA_BITS(5);
			break;
		case CS6:
			urb_value = BELKIN_SA_DATA_BITS(6);
			break;
		case CS7:
			urb_value = BELKIN_SA_DATA_BITS(7);
			break;
		case CS8:
			urb_value = BELKIN_SA_DATA_BITS(8);
			break;
393
		default:
394 395
			dev_dbg(&port->dev,
				"CSIZE was not CS5-CS8, using default of 8\n");
A
Alan Cox 已提交
396 397
			urb_value = BELKIN_SA_DATA_BITS(8);
			break;
L
Linus Torvalds 已提交
398 399
		}
		if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0)
400
			dev_err(&port->dev, "Set data bits error\n");
L
Linus Torvalds 已提交
401 402 403
	}

	/* set the number of stop bits */
A
Alan Cox 已提交
404 405 406 407 408
	if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) {
		urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2)
						: BELKIN_SA_STOP_BITS(1);
		if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST,
							urb_value) < 0)
409
			dev_err(&port->dev, "Set stop bits error\n");
L
Linus Torvalds 已提交
410 411 412
	}

	/* Set flow control */
A
Alan Cox 已提交
413 414
	if (((iflag ^ old_iflag) & (IXOFF | IXON)) ||
		((cflag ^ old_cflag) & CRTSCTS)) {
L
Linus Torvalds 已提交
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
		urb_value = 0;
		if ((iflag & IXOFF) || (iflag & IXON))
			urb_value |= (BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
		else
			urb_value &= ~(BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);

		if (cflag & CRTSCTS)
			urb_value |=  (BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);
		else
			urb_value &= ~(BELKIN_SA_FLOW_OCTS | BELKIN_SA_FLOW_IRTS);

		if (bad_flow_control)
			urb_value &= ~(BELKIN_SA_FLOW_IRTS);

		if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0)
430
			dev_err(&port->dev, "Set flow control error\n");
L
Linus Torvalds 已提交
431 432 433 434 435 436
	}

	/* save off the modified port settings */
	spin_lock_irqsave(&priv->lock, flags);
	priv->control_state = control_state;
	spin_unlock_irqrestore(&priv->lock, flags);
J
Johan Hovold 已提交
437
}
L
Linus Torvalds 已提交
438

A
Alan Cox 已提交
439
static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state)
L
Linus Torvalds 已提交
440
{
A
Alan Cox 已提交
441
	struct usb_serial_port *port = tty->driver_data;
L
Linus Torvalds 已提交
442 443 444
	struct usb_serial *serial = port->serial;

	if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
445
		dev_err(&port->dev, "Set break_ctl %d\n", break_state);
L
Linus Torvalds 已提交
446 447
}

448
static int belkin_sa_tiocmget(struct tty_struct *tty)
L
Linus Torvalds 已提交
449
{
A
Alan Cox 已提交
450
	struct usb_serial_port *port = tty->driver_data;
L
Linus Torvalds 已提交
451 452 453
	struct belkin_sa_private *priv = usb_get_serial_port_data(port);
	unsigned long control_state;
	unsigned long flags;
A
Alan Cox 已提交
454

L
Linus Torvalds 已提交
455 456 457 458 459 460 461
	spin_lock_irqsave(&priv->lock, flags);
	control_state = priv->control_state;
	spin_unlock_irqrestore(&priv->lock, flags);

	return control_state;
}

462
static int belkin_sa_tiocmset(struct tty_struct *tty,
L
Linus Torvalds 已提交
463 464
			       unsigned int set, unsigned int clear)
{
A
Alan Cox 已提交
465
	struct usb_serial_port *port = tty->driver_data;
L
Linus Torvalds 已提交
466 467 468 469 470 471 472
	struct usb_serial *serial = port->serial;
	struct belkin_sa_private *priv = usb_get_serial_port_data(port);
	unsigned long control_state;
	unsigned long flags;
	int retval;
	int rts = 0;
	int dtr = 0;
A
Alan Cox 已提交
473

L
Linus Torvalds 已提交
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498
	spin_lock_irqsave(&priv->lock, flags);
	control_state = priv->control_state;

	if (set & TIOCM_RTS) {
		control_state |= TIOCM_RTS;
		rts = 1;
	}
	if (set & TIOCM_DTR) {
		control_state |= TIOCM_DTR;
		dtr = 1;
	}
	if (clear & TIOCM_RTS) {
		control_state &= ~TIOCM_RTS;
		rts = 0;
	}
	if (clear & TIOCM_DTR) {
		control_state &= ~TIOCM_DTR;
		dtr = 0;
	}

	priv->control_state = control_state;
	spin_unlock_irqrestore(&priv->lock, flags);

	retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts);
	if (retval < 0) {
499
		dev_err(&port->dev, "Set RTS error %d\n", retval);
L
Linus Torvalds 已提交
500 501 502 503 504
		goto exit;
	}

	retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr);
	if (retval < 0) {
505
		dev_err(&port->dev, "Set DTR error %d\n", retval);
L
Linus Torvalds 已提交
506 507 508 509 510 511
		goto exit;
	}
exit:
	return retval;
}

512
module_usb_serial_driver(serial_drivers, id_table);
L
Linus Torvalds 已提交
513

A
Alan Cox 已提交
514 515 516
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION(DRIVER_VERSION);
L
Linus Torvalds 已提交
517 518 519 520
MODULE_LICENSE("GPL");

module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Debug enabled or not");