aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mct_u232.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/mct_u232.c')
-rw-r--r--drivers/usb/serial/mct_u232.c273
1 files changed, 141 insertions, 132 deletions
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 7bce4302a5f9..7a804d6b3a4c 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -33,10 +33,11 @@
33 * - Fixed an endianess problem with the baudrate selection for PowerPC. 33 * - Fixed an endianess problem with the baudrate selection for PowerPC.
34 * 34 *
35 * 06-Dec-2001 Martin Hamilton <martinh@gnu.org> 35 * 06-Dec-2001 Martin Hamilton <martinh@gnu.org>
36 * Added support for the Belkin F5U109 DB9 adaptor 36 * - Added support for the Belkin F5U109 DB9 adaptor
37 * 37 *
38 * 30-May-2001 Greg Kroah-Hartman 38 * 30-May-2001 Greg Kroah-Hartman
39 * switched from using spinlock to a semaphore, which fixes lots of problems. 39 * - switched from using spinlock to a semaphore, which fixes lots of
40 * problems.
40 * 41 *
41 * 04-May-2001 Stelian Pop 42 * 04-May-2001 Stelian Pop
42 * - Set the maximum bulk output size for Sitecom U232-P25 model to 16 bytes 43 * - Set the maximum bulk output size for Sitecom U232-P25 model to 16 bytes
@@ -49,7 +50,7 @@
49 * 08-Apr-2001 gb 50 * 08-Apr-2001 gb
50 * - Identify version on module load. 51 * - Identify version on module load.
51 * 52 *
52 * 06-Jan-2001 Cornel Ciocirlan 53 * 06-Jan-2001 Cornel Ciocirlan
53 * - Added support for Sitecom U232-P25 model (Product Id 0x0230) 54 * - Added support for Sitecom U232-P25 model (Product Id 0x0230)
54 * - Added support for D-Link DU-H3SP USB BAY (Product Id 0x0200) 55 * - Added support for D-Link DU-H3SP USB BAY (Product Id 0x0200)
55 * 56 *
@@ -59,8 +60,8 @@
59 * (lots of things will change if/when the usb-serial core changes to 60 * (lots of things will change if/when the usb-serial core changes to
60 * handle these issues. 61 * handle these issues.
61 * 62 *
62 * 27-Nov-2000 Wolfgang Grandegger 63 * 27-Nov-2000 Wolfgang Grandegge
63 * A version for kernel 2.4.0-test10 released to the Linux community 64 * A version for kernel 2.4.0-test10 released to the Linux community
64 * (via linux-usb-devel). 65 * (via linux-usb-devel).
65 */ 66 */
66 67
@@ -73,7 +74,7 @@
73#include <linux/tty_flip.h> 74#include <linux/tty_flip.h>
74#include <linux/module.h> 75#include <linux/module.h>
75#include <linux/spinlock.h> 76#include <linux/spinlock.h>
76#include <asm/uaccess.h> 77#include <linux/uaccess.h>
77#include <linux/usb.h> 78#include <linux/usb.h>
78#include <linux/usb/serial.h> 79#include <linux/usb/serial.h>
79#include "mct_u232.h" 80#include "mct_u232.h"
@@ -90,27 +91,21 @@ static int debug;
90/* 91/*
91 * Function prototypes 92 * Function prototypes
92 */ 93 */
93static int mct_u232_startup (struct usb_serial *serial); 94static int mct_u232_startup(struct usb_serial *serial);
94static void mct_u232_shutdown (struct usb_serial *serial); 95static void mct_u232_shutdown(struct usb_serial *serial);
95static int mct_u232_open (struct tty_struct *tty, 96static int mct_u232_open(struct tty_struct *tty,
96 struct usb_serial_port *port, 97 struct usb_serial_port *port, struct file *filp);
97 struct file *filp); 98static void mct_u232_close(struct tty_struct *tty,
98static void mct_u232_close (struct tty_struct *tty, 99 struct usb_serial_port *port, struct file *filp);
99 struct usb_serial_port *port, 100static void mct_u232_read_int_callback(struct urb *urb);
100 struct file *filp); 101static void mct_u232_set_termios(struct tty_struct *tty,
101static void mct_u232_read_int_callback (struct urb *urb); 102 struct usb_serial_port *port, struct ktermios *old);
102static void mct_u232_set_termios (struct tty_struct *tty, 103static void mct_u232_break_ctl(struct tty_struct *tty, int break_state);
103 struct usb_serial_port *port, 104static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file);
104 struct ktermios * old); 105static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
105static void mct_u232_break_ctl (struct tty_struct *tty, 106 unsigned int set, unsigned int clear);
106 int break_state ); 107static void mct_u232_throttle(struct tty_struct *tty);
107static int mct_u232_tiocmget (struct tty_struct *tty, 108static void mct_u232_unthrottle(struct tty_struct *tty);
108 struct file *file);
109static int mct_u232_tiocmset (struct tty_struct *tty,
110 struct file *file, unsigned int set,
111 unsigned int clear);
112static void mct_u232_throttle (struct tty_struct *tty);
113static void mct_u232_unthrottle (struct tty_struct *tty);
114 109
115 110
116/* 111/*
@@ -124,7 +119,7 @@ static struct usb_device_id id_table_combined [] = {
124 { } /* Terminating entry */ 119 { } /* Terminating entry */
125}; 120};
126 121
127MODULE_DEVICE_TABLE (usb, id_table_combined); 122MODULE_DEVICE_TABLE(usb, id_table_combined);
128 123
129static struct usb_driver mct_u232_driver = { 124static struct usb_driver mct_u232_driver = {
130 .name = "mct_u232", 125 .name = "mct_u232",
@@ -178,23 +173,34 @@ struct mct_u232_private {
178 * Later day 2.6.0-test kernels have new baud rates like B230400 which 173 * Later day 2.6.0-test kernels have new baud rates like B230400 which
179 * we do not know how to support. We ignore them for the moment. 174 * we do not know how to support. We ignore them for the moment.
180 */ 175 */
181static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result) 176static int mct_u232_calculate_baud_rate(struct usb_serial *serial,
177 speed_t value, speed_t *result)
182{ 178{
183 *result = value; 179 *result = value;
184 180
185 if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID 181 if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID
186 || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { 182 || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) {
187 switch (value) { 183 switch (value) {
188 case 300: return 0x01; 184 case 300:
189 case 600: return 0x02; /* this one not tested */ 185 return 0x01;
190 case 1200: return 0x03; 186 case 600:
191 case 2400: return 0x04; 187 return 0x02; /* this one not tested */
192 case 4800: return 0x06; 188 case 1200:
193 case 9600: return 0x08; 189 return 0x03;
194 case 19200: return 0x09; 190 case 2400:
195 case 38400: return 0x0a; 191 return 0x04;
196 case 57600: return 0x0b; 192 case 4800:
197 case 115200: return 0x0c; 193 return 0x06;
194 case 9600:
195 return 0x08;
196 case 19200:
197 return 0x09;
198 case 38400:
199 return 0x0a;
200 case 57600:
201 return 0x0b;
202 case 115200:
203 return 0x0c;
198 default: 204 default:
199 *result = 9600; 205 *result = 9600;
200 return 0x08; 206 return 0x08;
@@ -226,18 +232,19 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
226 struct usb_serial *serial, struct usb_serial_port *port, speed_t value) 232 struct usb_serial *serial, struct usb_serial_port *port, speed_t value)
227{ 233{
228 __le32 divisor; 234 __le32 divisor;
229 int rc; 235 int rc;
230 unsigned char zero_byte = 0; 236 unsigned char zero_byte = 0;
231 unsigned char cts_enable_byte = 0; 237 unsigned char cts_enable_byte = 0;
232 speed_t speed; 238 speed_t speed;
233 239
234 divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, &speed)); 240 divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value,
235 241 &speed));
236 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 242
237 MCT_U232_SET_BAUD_RATE_REQUEST, 243 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
238 MCT_U232_SET_REQUEST_TYPE, 244 MCT_U232_SET_BAUD_RATE_REQUEST,
239 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, 245 MCT_U232_SET_REQUEST_TYPE,
240 WDR_TIMEOUT); 246 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE,
247 WDR_TIMEOUT);
241 if (rc < 0) /*FIXME: What value speed results */ 248 if (rc < 0) /*FIXME: What value speed results */
242 err("Set BAUD RATE %d failed (error = %d)", value, rc); 249 err("Set BAUD RATE %d failed (error = %d)", value, rc);
243 else 250 else
@@ -256,55 +263,55 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
256 whether data will be transmitted to a device which is not asserting 263 whether data will be transmitted to a device which is not asserting
257 the 'CTS' signal. If the second message's data byte is zero, data 264 the 'CTS' signal. If the second message's data byte is zero, data
258 will be transmitted even if 'CTS' is not asserted (i.e. no hardware 265 will be transmitted even if 'CTS' is not asserted (i.e. no hardware
259 flow control). if the second message's data byte is nonzero (a value 266 flow control). if the second message's data byte is nonzero (a
260 of 1 is used by this driver), data will not be transmitted to a device 267 value of 1 is used by this driver), data will not be transmitted to
261 which is not asserting 'CTS'. 268 a device which is not asserting 'CTS'.
262 */ 269 */
263 270
264 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 271 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
265 MCT_U232_SET_UNKNOWN1_REQUEST, 272 MCT_U232_SET_UNKNOWN1_REQUEST,
266 MCT_U232_SET_REQUEST_TYPE, 273 MCT_U232_SET_REQUEST_TYPE,
267 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, 274 0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE,
268 WDR_TIMEOUT); 275 WDR_TIMEOUT);
269 if (rc < 0) 276 if (rc < 0)
270 err("Sending USB device request code %d failed (error = %d)", 277 err("Sending USB device request code %d failed (error = %d)",
271 MCT_U232_SET_UNKNOWN1_REQUEST, rc); 278 MCT_U232_SET_UNKNOWN1_REQUEST, rc);
272 279
273 if (port && C_CRTSCTS(tty)) { 280 if (port && C_CRTSCTS(tty))
274 cts_enable_byte = 1; 281 cts_enable_byte = 1;
275 }
276 282
277 dbg("set_baud_rate: send second control message, data = %02X", cts_enable_byte); 283 dbg("set_baud_rate: send second control message, data = %02X",
284 cts_enable_byte);
278 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 285 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
279 MCT_U232_SET_CTS_REQUEST, 286 MCT_U232_SET_CTS_REQUEST,
280 MCT_U232_SET_REQUEST_TYPE, 287 MCT_U232_SET_REQUEST_TYPE,
281 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE, 288 0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE,
282 WDR_TIMEOUT); 289 WDR_TIMEOUT);
283 if (rc < 0) 290 if (rc < 0)
284 err("Sending USB device request code %d failed (error = %d)", 291 err("Sending USB device request code %d failed (error = %d)",
285 MCT_U232_SET_CTS_REQUEST, rc); 292 MCT_U232_SET_CTS_REQUEST, rc);
286 293
287 return rc; 294 return rc;
288} /* mct_u232_set_baud_rate */ 295} /* mct_u232_set_baud_rate */
289 296
290static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) 297static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr)
291{ 298{
292 int rc; 299 int rc;
293 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 300 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
294 MCT_U232_SET_LINE_CTRL_REQUEST, 301 MCT_U232_SET_LINE_CTRL_REQUEST,
295 MCT_U232_SET_REQUEST_TYPE, 302 MCT_U232_SET_REQUEST_TYPE,
296 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE, 303 0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE,
297 WDR_TIMEOUT); 304 WDR_TIMEOUT);
298 if (rc < 0) 305 if (rc < 0)
299 err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc); 306 err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc);
300 dbg("set_line_ctrl: 0x%x", lcr); 307 dbg("set_line_ctrl: 0x%x", lcr);
301 return rc; 308 return rc;
302} /* mct_u232_set_line_ctrl */ 309} /* mct_u232_set_line_ctrl */
303 310
304static int mct_u232_set_modem_ctrl(struct usb_serial *serial, 311static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
305 unsigned int control_state) 312 unsigned int control_state)
306{ 313{
307 int rc; 314 int rc;
308 unsigned char mcr = MCT_U232_MCR_NONE; 315 unsigned char mcr = MCT_U232_MCR_NONE;
309 316
310 if (control_state & TIOCM_DTR) 317 if (control_state & TIOCM_DTR)
@@ -312,37 +319,39 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
312 if (control_state & TIOCM_RTS) 319 if (control_state & TIOCM_RTS)
313 mcr |= MCT_U232_MCR_RTS; 320 mcr |= MCT_U232_MCR_RTS;
314 321
315 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 322 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
316 MCT_U232_SET_MODEM_CTRL_REQUEST, 323 MCT_U232_SET_MODEM_CTRL_REQUEST,
317 MCT_U232_SET_REQUEST_TYPE, 324 MCT_U232_SET_REQUEST_TYPE,
318 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE, 325 0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE,
319 WDR_TIMEOUT); 326 WDR_TIMEOUT);
320 if (rc < 0) 327 if (rc < 0)
321 err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc); 328 err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc);
322 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); 329 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr);
323 330
324 return rc; 331 return rc;
325} /* mct_u232_set_modem_ctrl */ 332} /* mct_u232_set_modem_ctrl */
326 333
327static int mct_u232_get_modem_stat(struct usb_serial *serial, unsigned char *msr) 334static int mct_u232_get_modem_stat(struct usb_serial *serial,
335 unsigned char *msr)
328{ 336{
329 int rc; 337 int rc;
330 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 338 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
331 MCT_U232_GET_MODEM_STAT_REQUEST, 339 MCT_U232_GET_MODEM_STAT_REQUEST,
332 MCT_U232_GET_REQUEST_TYPE, 340 MCT_U232_GET_REQUEST_TYPE,
333 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE, 341 0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE,
334 WDR_TIMEOUT); 342 WDR_TIMEOUT);
335 if (rc < 0) { 343 if (rc < 0) {
336 err("Get MODEM STATus failed (error = %d)", rc); 344 err("Get MODEM STATus failed (error = %d)", rc);
337 *msr = 0; 345 *msr = 0;
338 } 346 }
339 dbg("get_modem_stat: 0x%x", *msr); 347 dbg("get_modem_stat: 0x%x", *msr);
340 return rc; 348 return rc;
341} /* mct_u232_get_modem_stat */ 349} /* mct_u232_get_modem_stat */
342 350
343static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr) 351static void mct_u232_msr_to_state(unsigned int *control_state,
352 unsigned char msr)
344{ 353{
345 /* Translate Control Line states */ 354 /* Translate Control Line states */
346 if (msr & MCT_U232_MSR_DSR) 355 if (msr & MCT_U232_MSR_DSR)
347 *control_state |= TIOCM_DSR; 356 *control_state |= TIOCM_DSR;
348 else 357 else
@@ -359,14 +368,14 @@ static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr
359 *control_state |= TIOCM_CD; 368 *control_state |= TIOCM_CD;
360 else 369 else
361 *control_state &= ~TIOCM_CD; 370 *control_state &= ~TIOCM_CD;
362 dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state); 371 dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state);
363} /* mct_u232_msr_to_state */ 372} /* mct_u232_msr_to_state */
364 373
365/* 374/*
366 * Driver's tty interface functions 375 * Driver's tty interface functions
367 */ 376 */
368 377
369static int mct_u232_startup (struct usb_serial *serial) 378static int mct_u232_startup(struct usb_serial *serial)
370{ 379{
371 struct mct_u232_private *priv; 380 struct mct_u232_private *priv;
372 struct usb_serial_port *port, *rport; 381 struct usb_serial_port *port, *rport;
@@ -388,18 +397,18 @@ static int mct_u232_startup (struct usb_serial *serial)
388 rport->interrupt_in_urb = NULL; 397 rport->interrupt_in_urb = NULL;
389 port->read_urb->context = port; 398 port->read_urb->context = port;
390 399
391 return (0); 400 return 0;
392} /* mct_u232_startup */ 401} /* mct_u232_startup */
393 402
394 403
395static void mct_u232_shutdown (struct usb_serial *serial) 404static void mct_u232_shutdown(struct usb_serial *serial)
396{ 405{
397 struct mct_u232_private *priv; 406 struct mct_u232_private *priv;
398 int i; 407 int i;
399 408
400 dbg("%s", __func__); 409 dbg("%s", __func__);
401 410
402 for (i=0; i < serial->num_ports; ++i) { 411 for (i = 0; i < serial->num_ports; ++i) {
403 /* My special items, the standard routines free my urbs */ 412 /* My special items, the standard routines free my urbs */
404 priv = usb_get_serial_port_data(serial->port[i]); 413 priv = usb_get_serial_port_data(serial->port[i]);
405 if (priv) { 414 if (priv) {
@@ -409,7 +418,7 @@ static void mct_u232_shutdown (struct usb_serial *serial)
409 } 418 }
410} /* mct_u232_shutdown */ 419} /* mct_u232_shutdown */
411 420
412static int mct_u232_open (struct tty_struct *tty, 421static int mct_u232_open(struct tty_struct *tty,
413 struct usb_serial_port *port, struct file *filp) 422 struct usb_serial_port *port, struct file *filp)
414{ 423{
415 struct usb_serial *serial = port->serial; 424 struct usb_serial *serial = port->serial;
@@ -427,10 +436,11 @@ static int mct_u232_open (struct tty_struct *tty,
427 * it seems to be able to accept only 16 bytes (and that's what 436 * it seems to be able to accept only 16 bytes (and that's what
428 * SniffUSB says too...) 437 * SniffUSB says too...)
429 */ 438 */
430 if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID) 439 if (le16_to_cpu(serial->dev->descriptor.idProduct)
440 == MCT_U232_SITECOM_PID)
431 port->bulk_out_size = 16; 441 port->bulk_out_size = 16;
432 442
433 /* Do a defined restart: the normal serial device seems to 443 /* Do a defined restart: the normal serial device seems to
434 * always turn on DTR and RTS here, so do the same. I'm not 444 * always turn on DTR and RTS here, so do the same. I'm not
435 * sure if this is really necessary. But it should not harm 445 * sure if this is really necessary. But it should not harm
436 * either. 446 * either.
@@ -440,8 +450,8 @@ static int mct_u232_open (struct tty_struct *tty,
440 priv->control_state = TIOCM_DTR | TIOCM_RTS; 450 priv->control_state = TIOCM_DTR | TIOCM_RTS;
441 else 451 else
442 priv->control_state = 0; 452 priv->control_state = 0;
443 453
444 priv->last_lcr = (MCT_U232_DATA_BITS_8 | 454 priv->last_lcr = (MCT_U232_DATA_BITS_8 |
445 MCT_U232_PARITY_NONE | 455 MCT_U232_PARITY_NONE |
446 MCT_U232_STOP_BITS_1); 456 MCT_U232_STOP_BITS_1);
447 control_state = priv->control_state; 457 control_state = priv->control_state;
@@ -488,7 +498,7 @@ static void mct_u232_close(struct tty_struct *tty,
488 struct mct_u232_private *priv = usb_get_serial_port_data(port); 498 struct mct_u232_private *priv = usb_get_serial_port_data(port);
489 dbg("%s port %d", __func__, port->number); 499 dbg("%s port %d", __func__, port->number);
490 500
491 if (tty) { 501 if (tty) {
492 c_cflag = tty->termios->c_cflag; 502 c_cflag = tty->termios->c_cflag;
493 mutex_lock(&port->serial->disc_mutex); 503 mutex_lock(&port->serial->disc_mutex);
494 if (c_cflag & HUPCL && !port->serial->disconnected) { 504 if (c_cflag & HUPCL && !port->serial->disconnected) {
@@ -512,7 +522,7 @@ static void mct_u232_close(struct tty_struct *tty,
512} /* mct_u232_close */ 522} /* mct_u232_close */
513 523
514 524
515static void mct_u232_read_int_callback (struct urb *urb) 525static void mct_u232_read_int_callback(struct urb *urb)
516{ 526{
517 struct usb_serial_port *port = urb->context; 527 struct usb_serial_port *port = urb->context;
518 struct mct_u232_private *priv = usb_get_serial_port_data(port); 528 struct mct_u232_private *priv = usb_get_serial_port_data(port);
@@ -545,8 +555,9 @@ static void mct_u232_read_int_callback (struct urb *urb)
545 return; 555 return;
546 } 556 }
547 557
548 dbg("%s - port %d", __func__, port->number); 558 dbg("%s - port %d", __func__, port->number);
549 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 559 usb_serial_debug_data(debug, &port->dev, __func__,
560 urb->actual_length, data);
550 561
551 /* 562 /*
552 * Work-a-round: handle the 'usual' bulk-in pipe here 563 * Work-a-round: handle the 'usual' bulk-in pipe here
@@ -555,26 +566,25 @@ static void mct_u232_read_int_callback (struct urb *urb)
555 int i; 566 int i;
556 tty = port->port.tty; 567 tty = port->port.tty;
557 if (urb->actual_length) { 568 if (urb->actual_length) {
558 for (i = 0; i < urb->actual_length ; ++i) { 569 for (i = 0; i < urb->actual_length ; ++i)
559 tty_insert_flip_char(tty, data[i], 0); 570 tty_insert_flip_char(tty, data[i], 0);
560 }
561 tty_flip_buffer_push(tty); 571 tty_flip_buffer_push(tty);
562 } 572 }
563 goto exit; 573 goto exit;
564 } 574 }
565 575
566 /* 576 /*
567 * The interrupt-in pipe signals exceptional conditions (modem line 577 * The interrupt-in pipe signals exceptional conditions (modem line
568 * signal changes and errors). data[0] holds MSR, data[1] holds LSR. 578 * signal changes and errors). data[0] holds MSR, data[1] holds LSR.
569 */ 579 */
570 spin_lock_irqsave(&priv->lock, flags); 580 spin_lock_irqsave(&priv->lock, flags);
571 priv->last_msr = data[MCT_U232_MSR_INDEX]; 581 priv->last_msr = data[MCT_U232_MSR_INDEX];
572 582
573 /* Record Control Line states */ 583 /* Record Control Line states */
574 mct_u232_msr_to_state(&priv->control_state, priv->last_msr); 584 mct_u232_msr_to_state(&priv->control_state, priv->last_msr);
575 585
576#if 0 586#if 0
577 /* Not yet handled. See belin_sa.c for further information */ 587 /* Not yet handled. See belkin_sa.c for further information */
578 /* Now to report any errors */ 588 /* Now to report any errors */
579 priv->last_lsr = data[MCT_U232_LSR_INDEX]; 589 priv->last_lsr = data[MCT_U232_LSR_INDEX];
580 /* 590 /*
@@ -600,15 +610,15 @@ static void mct_u232_read_int_callback (struct urb *urb)
600#endif 610#endif
601 spin_unlock_irqrestore(&priv->lock, flags); 611 spin_unlock_irqrestore(&priv->lock, flags);
602exit: 612exit:
603 retval = usb_submit_urb (urb, GFP_ATOMIC); 613 retval = usb_submit_urb(urb, GFP_ATOMIC);
604 if (retval) 614 if (retval)
605 err ("%s - usb_submit_urb failed with result %d", 615 err("%s - usb_submit_urb failed with result %d",
606 __func__, retval); 616 __func__, retval);
607} /* mct_u232_read_int_callback */ 617} /* mct_u232_read_int_callback */
608 618
609static void mct_u232_set_termios (struct tty_struct *tty, 619static void mct_u232_set_termios(struct tty_struct *tty,
610 struct usb_serial_port *port, 620 struct usb_serial_port *port,
611 struct ktermios *old_termios) 621 struct ktermios *old_termios)
612{ 622{
613 struct usb_serial *serial = port->serial; 623 struct usb_serial *serial = port->serial;
614 struct mct_u232_private *priv = usb_get_serial_port_data(port); 624 struct mct_u232_private *priv = usb_get_serial_port_data(port);
@@ -632,7 +642,7 @@ static void mct_u232_set_termios (struct tty_struct *tty,
632 * Premature optimization is the root of all evil. 642 * Premature optimization is the root of all evil.
633 */ 643 */
634 644
635 /* reassert DTR and RTS on transition from B0 */ 645 /* reassert DTR and RTS on transition from B0 */
636 if ((old_cflag & CBAUD) == B0) { 646 if ((old_cflag & CBAUD) == B0) {
637 dbg("%s: baud was B0", __func__); 647 dbg("%s: baud was B0", __func__);
638 control_state |= TIOCM_DTR | TIOCM_RTS; 648 control_state |= TIOCM_DTR | TIOCM_RTS;
@@ -641,11 +651,11 @@ static void mct_u232_set_termios (struct tty_struct *tty,
641 651
642 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); 652 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty));
643 653
644 if ((cflag & CBAUD) == B0 ) { 654 if ((cflag & CBAUD) == B0) {
645 dbg("%s: baud is B0", __func__); 655 dbg("%s: baud is B0", __func__);
646 /* Drop RTS and DTR */ 656 /* Drop RTS and DTR */
647 control_state &= ~(TIOCM_DTR | TIOCM_RTS); 657 control_state &= ~(TIOCM_DTR | TIOCM_RTS);
648 mct_u232_set_modem_ctrl(serial, control_state); 658 mct_u232_set_modem_ctrl(serial, control_state);
649 } 659 }
650 660
651 /* 661 /*
@@ -717,7 +727,7 @@ static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file)
717 struct mct_u232_private *priv = usb_get_serial_port_data(port); 727 struct mct_u232_private *priv = usb_get_serial_port_data(port);
718 unsigned int control_state; 728 unsigned int control_state;
719 unsigned long flags; 729 unsigned long flags;
720 730
721 dbg("%s", __func__); 731 dbg("%s", __func__);
722 732
723 spin_lock_irqsave(&priv->lock, flags); 733 spin_lock_irqsave(&priv->lock, flags);
@@ -735,7 +745,7 @@ static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
735 struct mct_u232_private *priv = usb_get_serial_port_data(port); 745 struct mct_u232_private *priv = usb_get_serial_port_data(port);
736 unsigned int control_state; 746 unsigned int control_state;
737 unsigned long flags; 747 unsigned long flags;
738 748
739 dbg("%s", __func__); 749 dbg("%s", __func__);
740 750
741 spin_lock_irqsave(&priv->lock, flags); 751 spin_lock_irqsave(&priv->lock, flags);
@@ -798,7 +808,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty)
798 } 808 }
799} 809}
800 810
801static int __init mct_u232_init (void) 811static int __init mct_u232_init(void)
802{ 812{
803 int retval; 813 int retval;
804 retval = usb_serial_register(&mct_u232_device); 814 retval = usb_serial_register(&mct_u232_device);
@@ -816,18 +826,17 @@ failed_usb_serial_register:
816} 826}
817 827
818 828
819static void __exit mct_u232_exit (void) 829static void __exit mct_u232_exit(void)
820{ 830{
821 usb_deregister (&mct_u232_driver); 831 usb_deregister(&mct_u232_driver);
822 usb_serial_deregister (&mct_u232_device); 832 usb_serial_deregister(&mct_u232_device);
823} 833}
824 834
825 835module_init(mct_u232_init);
826module_init (mct_u232_init);
827module_exit(mct_u232_exit); 836module_exit(mct_u232_exit);
828 837
829MODULE_AUTHOR( DRIVER_AUTHOR ); 838MODULE_AUTHOR(DRIVER_AUTHOR);
830MODULE_DESCRIPTION( DRIVER_DESC ); 839MODULE_DESCRIPTION(DRIVER_DESC);
831MODULE_LICENSE("GPL"); 840MODULE_LICENSE("GPL");
832 841
833module_param(debug, bool, S_IRUGO | S_IWUSR); 842module_param(debug, bool, S_IRUGO | S_IWUSR);