diff options
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/belkin_sa.c | 69 |
1 files changed, 27 insertions, 42 deletions
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 50194eeed02e..e67ce25f7512 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -349,6 +349,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
349 | unsigned long flags; | 349 | unsigned long flags; |
350 | unsigned long control_state; | 350 | unsigned long control_state; |
351 | int bad_flow_control; | 351 | int bad_flow_control; |
352 | speed_t baud; | ||
352 | 353 | ||
353 | if ((!port->tty) || (!port->tty->termios)) { | 354 | if ((!port->tty) || (!port->tty->termios)) { |
354 | dbg ("%s - no tty or termios structure", __FUNCTION__); | 355 | dbg ("%s - no tty or termios structure", __FUNCTION__); |
@@ -364,16 +365,8 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
364 | bad_flow_control = priv->bad_flow_control; | 365 | bad_flow_control = priv->bad_flow_control; |
365 | spin_unlock_irqrestore(&priv->lock, flags); | 366 | spin_unlock_irqrestore(&priv->lock, flags); |
366 | 367 | ||
367 | /* check that they really want us to change something */ | 368 | old_iflag = old_termios->c_iflag; |
368 | if (old_termios) { | 369 | old_cflag = old_termios->c_cflag; |
369 | if ((cflag == old_termios->c_cflag) && | ||
370 | (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) { | ||
371 | dbg("%s - nothing to change...", __FUNCTION__); | ||
372 | return; | ||
373 | } | ||
374 | old_iflag = old_termios->c_iflag; | ||
375 | old_cflag = old_termios->c_cflag; | ||
376 | } | ||
377 | 370 | ||
378 | /* Set the baud rate */ | 371 | /* Set the baud rate */ |
379 | if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { | 372 | if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { |
@@ -387,38 +380,30 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
387 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) | 380 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) |
388 | err("Set RTS error"); | 381 | err("Set RTS error"); |
389 | } | 382 | } |
383 | } | ||
390 | 384 | ||
391 | switch(cflag & CBAUD) { | 385 | baud = tty_get_baud_rate(port->tty); |
392 | case B0: /* handled below */ break; | 386 | urb_value = BELKIN_SA_BAUD(baud); |
393 | case B300: urb_value = BELKIN_SA_BAUD(300); break; | 387 | /* Clip to maximum speed */ |
394 | case B600: urb_value = BELKIN_SA_BAUD(600); break; | 388 | if (urb_value == 0) |
395 | case B1200: urb_value = BELKIN_SA_BAUD(1200); break; | 389 | urb_value = 1; |
396 | case B2400: urb_value = BELKIN_SA_BAUD(2400); break; | 390 | /* Turn it back into a resulting real baud rate */ |
397 | case B4800: urb_value = BELKIN_SA_BAUD(4800); break; | 391 | baud = BELKIN_SA_BAUD(urb_value); |
398 | case B9600: urb_value = BELKIN_SA_BAUD(9600); break; | 392 | /* FIXME: Once the tty updates are done then push this back to the tty */ |
399 | case B19200: urb_value = BELKIN_SA_BAUD(19200); break; | 393 | |
400 | case B38400: urb_value = BELKIN_SA_BAUD(38400); break; | 394 | if ((cflag & CBAUD) != B0 ) { |
401 | case B57600: urb_value = BELKIN_SA_BAUD(57600); break; | 395 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) |
402 | case B115200: urb_value = BELKIN_SA_BAUD(115200); break; | 396 | err("Set baudrate error"); |
403 | case B230400: urb_value = BELKIN_SA_BAUD(230400); break; | 397 | } else { |
404 | default: err("BELKIN USB Serial Adapter: unsupported baudrate request, using default of 9600"); | 398 | /* Disable flow control */ |
405 | urb_value = BELKIN_SA_BAUD(9600); break; | 399 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0) |
406 | } | 400 | err("Disable flowcontrol error"); |
407 | if ((cflag & CBAUD) != B0 ) { | 401 | /* Drop RTS and DTR */ |
408 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) | 402 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
409 | err("Set baudrate error"); | 403 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0) |
410 | } else { | 404 | err("DTR LOW error"); |
411 | /* Disable flow control */ | 405 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0) |
412 | if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0) | 406 | err("RTS LOW error"); |
413 | err("Disable flowcontrol error"); | ||
414 | |||
415 | /* Drop RTS and DTR */ | ||
416 | control_state &= ~(TIOCM_DTR | TIOCM_RTS); | ||
417 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0) | ||
418 | err("DTR LOW error"); | ||
419 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0) | ||
420 | err("RTS LOW error"); | ||
421 | } | ||
422 | } | 407 | } |
423 | 408 | ||
424 | /* set the parity */ | 409 | /* set the parity */ |
@@ -438,7 +423,7 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
438 | case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break; | 423 | case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break; |
439 | case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break; | 424 | case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break; |
440 | case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break; | 425 | case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break; |
441 | default: err("CSIZE was not CS5-CS8, using default of 8"); | 426 | default: dbg("CSIZE was not CS5-CS8, using default of 8"); |
442 | urb_value = BELKIN_SA_DATA_BITS(8); | 427 | urb_value = BELKIN_SA_DATA_BITS(8); |
443 | break; | 428 | break; |
444 | } | 429 | } |