aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2007-10-18 04:24:24 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-25 15:18:42 -0400
commit9ab0f202e6a700d1362a1eb990ac3054f2cd15ea (patch)
treef73f1b3120a1d5c123276ac7487d037e8d8f8ef0 /drivers/usb
parent01d1df29517625b8e8b5f48a0d3c2020d950eb4b (diff)
USB: cp2101: convert to new termios
- Convert to new baud rate functions - Add baud rate reporting Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/cp2101.c48
1 files changed, 11 insertions, 37 deletions
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index eb7df1835c11..3a83cb4c4bc2 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -361,7 +361,6 @@ static void cp2101_get_termios (struct usb_serial_port *port)
361 dbg("%s - no tty structures", __FUNCTION__); 361 dbg("%s - no tty structures", __FUNCTION__);
362 return; 362 return;
363 } 363 }
364 cflag = port->tty->termios->c_cflag;
365 364
366 cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2); 365 cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2);
367 /* Convert to baudrate */ 366 /* Convert to baudrate */
@@ -369,40 +368,9 @@ static void cp2101_get_termios (struct usb_serial_port *port)
369 baud = BAUD_RATE_GEN_FREQ / baud; 368 baud = BAUD_RATE_GEN_FREQ / baud;
370 369
371 dbg("%s - baud rate = %d", __FUNCTION__, baud); 370 dbg("%s - baud rate = %d", __FUNCTION__, baud);
372 cflag &= ~CBAUD; 371
373 switch (baud) { 372 tty_encode_baud_rate(port->tty, baud, baud);
374 /* 373 cflag = port->tty->termios->c_cflag;
375 * The baud rates which are commented out below
376 * appear to be supported by the device
377 * but are non-standard
378 */
379 case 600: cflag |= B600; break;
380 case 1200: cflag |= B1200; break;
381 case 1800: cflag |= B1800; break;
382 case 2400: cflag |= B2400; break;
383 case 4800: cflag |= B4800; break;
384 /*case 7200: cflag |= B7200; break;*/
385 case 9600: cflag |= B9600; break;
386 /*case 14400: cflag |= B14400; break;*/
387 case 19200: cflag |= B19200; break;
388 /*case 28800: cflag |= B28800; break;*/
389 case 38400: cflag |= B38400; break;
390 /*case 55854: cflag |= B55054; break;*/
391 case 57600: cflag |= B57600; break;
392 case 115200: cflag |= B115200; break;
393 /*case 127117: cflag |= B127117; break;*/
394 case 230400: cflag |= B230400; break;
395 case 460800: cflag |= B460800; break;
396 case 921600: cflag |= B921600; break;
397 /*case 3686400: cflag |= B3686400; break;*/
398 default:
399 dbg("%s - Baud rate is not supported, "
400 "using 9600 baud", __FUNCTION__);
401 cflag |= B9600;
402 cp2101_set_config_single(port, CP2101_BAUDRATE,
403 (BAUD_RATE_GEN_FREQ/9600));
404 break;
405 }
406 374
407 cp2101_get_config(port, CP2101_BITS, &bits, 2); 375 cp2101_get_config(port, CP2101_BITS, &bits, 2);
408 cflag &= ~CSIZE; 376 cflag &= ~CSIZE;
@@ -516,7 +484,7 @@ static void cp2101_get_termios (struct usb_serial_port *port)
516static void cp2101_set_termios (struct usb_serial_port *port, 484static void cp2101_set_termios (struct usb_serial_port *port,
517 struct ktermios *old_termios) 485 struct ktermios *old_termios)
518{ 486{
519 unsigned int cflag, old_cflag=0; 487 unsigned int cflag, old_cflag;
520 int baud=0, bits; 488 int baud=0, bits;
521 unsigned int modem_ctl[4]; 489 unsigned int modem_ctl[4];
522 490
@@ -526,6 +494,8 @@ static void cp2101_set_termios (struct usb_serial_port *port,
526 dbg("%s - no tty structures", __FUNCTION__); 494 dbg("%s - no tty structures", __FUNCTION__);
527 return; 495 return;
528 } 496 }
497 port->tty->termios->c_cflag &= ~CMSPAR;
498
529 cflag = port->tty->termios->c_cflag; 499 cflag = port->tty->termios->c_cflag;
530 old_cflag = old_termios->c_cflag; 500 old_cflag = old_termios->c_cflag;
531 baud = tty_get_baud_rate(port->tty); 501 baud = tty_get_baud_rate(port->tty);
@@ -563,11 +533,15 @@ static void cp2101_set_termios (struct usb_serial_port *port,
563 dbg("%s - Setting baud rate to %d baud", __FUNCTION__, 533 dbg("%s - Setting baud rate to %d baud", __FUNCTION__,
564 baud); 534 baud);
565 if (cp2101_set_config_single(port, CP2101_BAUDRATE, 535 if (cp2101_set_config_single(port, CP2101_BAUDRATE,
566 (BAUD_RATE_GEN_FREQ / baud))) 536 (BAUD_RATE_GEN_FREQ / baud))) {
567 dev_err(&port->dev, "Baud rate requested not " 537 dev_err(&port->dev, "Baud rate requested not "
568 "supported by device\n"); 538 "supported by device\n");
539 baud = tty_termios_baud_rate(old_termios);
540 }
569 } 541 }
570 } 542 }
543 /* Report back the resulting baud rate */
544 tty_encode_baud_rate(port->tty, baud, baud);
571 545
572 /* If the number of data bits is to be updated */ 546 /* If the number of data bits is to be updated */
573 if ((cflag & CSIZE) != (old_cflag & CSIZE)) { 547 if ((cflag & CSIZE) != (old_cflag & CSIZE)) {