aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/belkin_sa.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/belkin_sa.c')
-rw-r--r--drivers/usb/serial/belkin_sa.c78
1 files changed, 33 insertions, 45 deletions
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 3b800d277c4b..e67ce25f7512 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -255,9 +255,10 @@ static void belkin_sa_read_int_callback (struct urb *urb)
255 struct belkin_sa_private *priv; 255 struct belkin_sa_private *priv;
256 unsigned char *data = urb->transfer_buffer; 256 unsigned char *data = urb->transfer_buffer;
257 int retval; 257 int retval;
258 int status = urb->status;
258 unsigned long flags; 259 unsigned long flags;
259 260
260 switch (urb->status) { 261 switch (status) {
261 case 0: 262 case 0:
262 /* success */ 263 /* success */
263 break; 264 break;
@@ -265,10 +266,12 @@ static void belkin_sa_read_int_callback (struct urb *urb)
265 case -ENOENT: 266 case -ENOENT:
266 case -ESHUTDOWN: 267 case -ESHUTDOWN:
267 /* this urb is terminated, clean up */ 268 /* this urb is terminated, clean up */
268 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 269 dbg("%s - urb shutting down with status: %d",
270 __FUNCTION__, status);
269 return; 271 return;
270 default: 272 default:
271 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); 273 dbg("%s - nonzero urb status received: %d",
274 __FUNCTION__, status);
272 goto exit; 275 goto exit;
273 } 276 }
274 277
@@ -346,6 +349,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
346 unsigned long flags; 349 unsigned long flags;
347 unsigned long control_state; 350 unsigned long control_state;
348 int bad_flow_control; 351 int bad_flow_control;
352 speed_t baud;
349 353
350 if ((!port->tty) || (!port->tty->termios)) { 354 if ((!port->tty) || (!port->tty->termios)) {
351 dbg ("%s - no tty or termios structure", __FUNCTION__); 355 dbg ("%s - no tty or termios structure", __FUNCTION__);
@@ -361,16 +365,8 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
361 bad_flow_control = priv->bad_flow_control; 365 bad_flow_control = priv->bad_flow_control;
362 spin_unlock_irqrestore(&priv->lock, flags); 366 spin_unlock_irqrestore(&priv->lock, flags);
363 367
364 /* check that they really want us to change something */ 368 old_iflag = old_termios->c_iflag;
365 if (old_termios) { 369 old_cflag = old_termios->c_cflag;
366 if ((cflag == old_termios->c_cflag) &&
367 (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
368 dbg("%s - nothing to change...", __FUNCTION__);
369 return;
370 }
371 old_iflag = old_termios->c_iflag;
372 old_cflag = old_termios->c_cflag;
373 }
374 370
375 /* Set the baud rate */ 371 /* Set the baud rate */
376 if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { 372 if( (cflag&CBAUD) != (old_cflag&CBAUD) ) {
@@ -384,38 +380,30 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
384 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) 380 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
385 err("Set RTS error"); 381 err("Set RTS error");
386 } 382 }
383 }
387 384
388 switch(cflag & CBAUD) { 385 baud = tty_get_baud_rate(port->tty);
389 case B0: /* handled below */ break; 386 urb_value = BELKIN_SA_BAUD(baud);
390 case B300: urb_value = BELKIN_SA_BAUD(300); break; 387 /* Clip to maximum speed */
391 case B600: urb_value = BELKIN_SA_BAUD(600); break; 388 if (urb_value == 0)
392 case B1200: urb_value = BELKIN_SA_BAUD(1200); break; 389 urb_value = 1;
393 case B2400: urb_value = BELKIN_SA_BAUD(2400); break; 390 /* Turn it back into a resulting real baud rate */
394 case B4800: urb_value = BELKIN_SA_BAUD(4800); break; 391 baud = BELKIN_SA_BAUD(urb_value);
395 case B9600: urb_value = BELKIN_SA_BAUD(9600); break; 392 /* FIXME: Once the tty updates are done then push this back to the tty */
396 case B19200: urb_value = BELKIN_SA_BAUD(19200); break; 393
397 case B38400: urb_value = BELKIN_SA_BAUD(38400); break; 394 if ((cflag & CBAUD) != B0 ) {
398 case B57600: urb_value = BELKIN_SA_BAUD(57600); break; 395 if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
399 case B115200: urb_value = BELKIN_SA_BAUD(115200); break; 396 err("Set baudrate error");
400 case B230400: urb_value = BELKIN_SA_BAUD(230400); break; 397 } else {
401 default: err("BELKIN USB Serial Adapter: unsupported baudrate request, using default of 9600"); 398 /* Disable flow control */
402 urb_value = BELKIN_SA_BAUD(9600); break; 399 if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0)
403 } 400 err("Disable flowcontrol error");
404 if ((cflag & CBAUD) != B0 ) { 401 /* Drop RTS and DTR */
405 if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) 402 control_state &= ~(TIOCM_DTR | TIOCM_RTS);
406 err("Set baudrate error"); 403 if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
407 } else { 404 err("DTR LOW error");
408 /* Disable flow control */ 405 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
409 if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0) 406 err("RTS LOW error");
410 err("Disable flowcontrol error");
411
412 /* Drop RTS and DTR */
413 control_state &= ~(TIOCM_DTR | TIOCM_RTS);
414 if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
415 err("DTR LOW error");
416 if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
417 err("RTS LOW error");
418 }
419 } 407 }
420 408
421 /* set the parity */ 409 /* set the parity */
@@ -435,7 +423,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
435 case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break; 423 case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break;
436 case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break; 424 case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break;
437 case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break; 425 case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break;
438 default: err("CSIZE was not CS5-CS8, using default of 8"); 426 default: dbg("CSIZE was not CS5-CS8, using default of 8");
439 urb_value = BELKIN_SA_DATA_BITS(8); 427 urb_value = BELKIN_SA_DATA_BITS(8);
440 break; 428 break;
441 } 429 }