diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-01-03 12:03:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:35:00 -0500 |
commit | 537699ef53f8b97546f0845bf51a49c9ab114a13 (patch) | |
tree | 954a9e9e20f4b7e7d663443023403051b078e841 /drivers/usb | |
parent | 65d063ab21feea8cf65d64fba50a5c4fa7bfd6be (diff) |
USB: ti_usb: termios cleanups
Remove internal NULL passing in termios code
Remove all the if checks it causes
Encode the baud rate back properly
Clear CMSPAR as it is not supported
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/ti_usb_3410_5052.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 995fdf3c4898..70f56c8aef99 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -581,7 +581,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file) | |||
581 | } | 581 | } |
582 | } | 582 | } |
583 | 583 | ||
584 | ti_set_termios(port, NULL); | 584 | ti_set_termios(port, port->tty->termios); |
585 | 585 | ||
586 | dbg("%s - sending TI_OPEN_PORT", __FUNCTION__); | 586 | dbg("%s - sending TI_OPEN_PORT", __FUNCTION__); |
587 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 587 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
@@ -618,7 +618,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file) | |||
618 | usb_clear_halt(dev, port->write_urb->pipe); | 618 | usb_clear_halt(dev, port->write_urb->pipe); |
619 | usb_clear_halt(dev, port->read_urb->pipe); | 619 | usb_clear_halt(dev, port->read_urb->pipe); |
620 | 620 | ||
621 | ti_set_termios(port, NULL); | 621 | ti_set_termios(port, port->tty->termios); |
622 | 622 | ||
623 | dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__); | 623 | dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__); |
624 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, | 624 | status = ti_command_out_sync(tdev, TI_OPEN_PORT, |
@@ -897,24 +897,11 @@ static void ti_set_termios(struct usb_serial_port *port, | |||
897 | 897 | ||
898 | dbg("%s - port %d", __FUNCTION__, port->number); | 898 | dbg("%s - port %d", __FUNCTION__, port->number); |
899 | 899 | ||
900 | if (!tty || !tty->termios) { | ||
901 | dbg("%s - no tty or termios", __FUNCTION__); | ||
902 | return; | ||
903 | } | ||
904 | |||
905 | cflag = tty->termios->c_cflag; | 900 | cflag = tty->termios->c_cflag; |
906 | iflag = tty->termios->c_iflag; | 901 | iflag = tty->termios->c_iflag; |
907 | 902 | ||
908 | if (old_termios && cflag == old_termios->c_cflag | 903 | dbg("%s - cflag %08x, iflag %08x", __FUNCTION__, cflag, iflag); |
909 | && iflag == old_termios->c_iflag) { | 904 | dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); |
910 | dbg("%s - nothing to change", __FUNCTION__); | ||
911 | return; | ||
912 | } | ||
913 | |||
914 | dbg("%s - clfag %08x, iflag %08x", __FUNCTION__, cflag, iflag); | ||
915 | |||
916 | if (old_termios) | ||
917 | dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag); | ||
918 | 905 | ||
919 | if (tport == NULL) | 906 | if (tport == NULL) |
920 | return; | 907 | return; |
@@ -948,6 +935,9 @@ static void ti_set_termios(struct usb_serial_port *port, | |||
948 | break; | 935 | break; |
949 | } | 936 | } |
950 | 937 | ||
938 | /* CMSPAR isn't supported by this driver */ | ||
939 | tty->termios->c_cflag &= ~CMSPAR; | ||
940 | |||
951 | if (cflag & PARENB) { | 941 | if (cflag & PARENB) { |
952 | if (cflag & PARODD) { | 942 | if (cflag & PARODD) { |
953 | config->wFlags |= TI_UART_ENABLE_PARITY_CHECKING; | 943 | config->wFlags |= TI_UART_ENABLE_PARITY_CHECKING; |
@@ -990,12 +980,17 @@ static void ti_set_termios(struct usb_serial_port *port, | |||
990 | } | 980 | } |
991 | 981 | ||
992 | baud = tty_get_baud_rate(tty); | 982 | baud = tty_get_baud_rate(tty); |
993 | if (!baud) baud = 9600; | 983 | if (!baud) |
984 | baud = 9600; | ||
994 | if (tport->tp_tdev->td_is_3410) | 985 | if (tport->tp_tdev->td_is_3410) |
995 | config->wBaudRate = (__u16)((923077 + baud/2) / baud); | 986 | config->wBaudRate = (__u16)((923077 + baud/2) / baud); |
996 | else | 987 | else |
997 | config->wBaudRate = (__u16)((461538 + baud/2) / baud); | 988 | config->wBaudRate = (__u16)((461538 + baud/2) / baud); |
998 | 989 | ||
990 | /* FIXME: Should calculate resulting baud here and report it back */ | ||
991 | if ((cflag & CBAUD) != B0) | ||
992 | tty_encode_baud_rate(tty, baud, baud); | ||
993 | |||
999 | dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", | 994 | dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", |
1000 | __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); | 995 | __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); |
1001 | 996 | ||