diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-04-08 12:16:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:55 -0400 |
commit | a5b6f60c5a30c494017c7a2d11c4067f90d3d0df (patch) | |
tree | 2f80d1a6c2655c5c12f40cafbc47516284934d42 /drivers/usb/serial/kl5kusb105.c | |
parent | 441b62c1edb986827154768d89bbac0ba779984f (diff) |
usb serial: more fixes and groundwork for tty changes
- If a termios change fails due to lack of memory we should copy the
old settings back over as the device has not changed
- Note various locking problems
- kl5kusb105 had various remaining tty flag handling problems
- Make safe_serial use tty_insert_flip_string not open coded loops
- set termios speed properly in usb_serial
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/kl5kusb105.c')
-rw-r--r-- | drivers/usb/serial/kl5kusb105.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 160e19263e25..b3ac045ab408 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -702,12 +702,14 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
702 | struct ktermios *old_termios) | 702 | struct ktermios *old_termios) |
703 | { | 703 | { |
704 | struct klsi_105_private *priv = usb_get_serial_port_data(port); | 704 | struct klsi_105_private *priv = usb_get_serial_port_data(port); |
705 | unsigned int iflag = port->tty->termios->c_iflag; | 705 | struct tty_struct *tty = port->tty; |
706 | unsigned int iflag = tty->termios->c_iflag; | ||
706 | unsigned int old_iflag = old_termios->c_iflag; | 707 | unsigned int old_iflag = old_termios->c_iflag; |
707 | unsigned int cflag = port->tty->termios->c_cflag; | 708 | unsigned int cflag = tty->termios->c_cflag; |
708 | unsigned int old_cflag = old_termios->c_cflag; | 709 | unsigned int old_cflag = old_termios->c_cflag; |
709 | struct klsi_105_port_settings cfg; | 710 | struct klsi_105_port_settings cfg; |
710 | unsigned long flags; | 711 | unsigned long flags; |
712 | speed_t baud; | ||
711 | 713 | ||
712 | /* lock while we are modifying the settings */ | 714 | /* lock while we are modifying the settings */ |
713 | spin_lock_irqsave (&priv->lock, flags); | 715 | spin_lock_irqsave (&priv->lock, flags); |
@@ -715,6 +717,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
715 | /* | 717 | /* |
716 | * Update baud rate | 718 | * Update baud rate |
717 | */ | 719 | */ |
720 | baud = tty_get_baud_rate(tty); | ||
721 | |||
718 | if( (cflag & CBAUD) != (old_cflag & CBAUD) ) { | 722 | if( (cflag & CBAUD) != (old_cflag & CBAUD) ) { |
719 | /* reassert DTR and (maybe) RTS on transition from B0 */ | 723 | /* reassert DTR and (maybe) RTS on transition from B0 */ |
720 | if( (old_cflag & CBAUD) == B0 ) { | 724 | if( (old_cflag & CBAUD) == B0 ) { |
@@ -728,8 +732,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
728 | mct_u232_set_modem_ctrl(serial, priv->control_state); | 732 | mct_u232_set_modem_ctrl(serial, priv->control_state); |
729 | #endif | 733 | #endif |
730 | } | 734 | } |
731 | 735 | } | |
732 | switch(tty_get_baud_rate(port->tty)) { | 736 | switch(baud) { |
733 | case 0: /* handled below */ | 737 | case 0: /* handled below */ |
734 | break; | 738 | break; |
735 | case 1200: | 739 | case 1200: |
@@ -757,25 +761,26 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
757 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; | 761 | priv->cfg.baudrate = kl5kusb105a_sio_b115200; |
758 | break; | 762 | break; |
759 | default: | 763 | default: |
760 | err("KLSI USB->Serial converter:" | 764 | dbg("KLSI USB->Serial converter:" |
761 | " unsupported baudrate request, using default" | 765 | " unsupported baudrate request, using default" |
762 | " of 9600"); | 766 | " of 9600"); |
763 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; | 767 | priv->cfg.baudrate = kl5kusb105a_sio_b9600; |
768 | baud = 9600; | ||
764 | break; | 769 | break; |
765 | } | 770 | } |
766 | if ((cflag & CBAUD) == B0 ) { | 771 | if ((cflag & CBAUD) == B0 ) { |
767 | dbg("%s: baud is B0", __func__); | 772 | dbg("%s: baud is B0", __func__); |
768 | /* Drop RTS and DTR */ | 773 | /* Drop RTS and DTR */ |
769 | /* maybe this should be simulated by sending read | 774 | /* maybe this should be simulated by sending read |
770 | * disable and read enable messages? | 775 | * disable and read enable messages? |
771 | */ | 776 | */ |
772 | ; | 777 | ; |
773 | #if 0 | 778 | #if 0 |
774 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); | 779 | priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); |
775 | mct_u232_set_modem_ctrl(serial, priv->control_state); | 780 | mct_u232_set_modem_ctrl(serial, priv->control_state); |
776 | #endif | 781 | #endif |
777 | } | ||
778 | } | 782 | } |
783 | tty_encode_baud_rate(tty, baud, baud); | ||
779 | 784 | ||
780 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { | 785 | if ((cflag & CSIZE) != (old_cflag & CSIZE)) { |
781 | /* set the number of data bits */ | 786 | /* set the number of data bits */ |
@@ -807,6 +812,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
807 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) | 812 | if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD)) |
808 | || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) { | 813 | || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) { |
809 | 814 | ||
815 | /* Not currently supported */ | ||
816 | tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB); | ||
810 | #if 0 | 817 | #if 0 |
811 | priv->last_lcr = 0; | 818 | priv->last_lcr = 0; |
812 | 819 | ||
@@ -834,6 +841,8 @@ static void klsi_105_set_termios (struct usb_serial_port *port, | |||
834 | || (iflag & IXON) != (old_iflag & IXON) | 841 | || (iflag & IXON) != (old_iflag & IXON) |
835 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) { | 842 | || (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) { |
836 | 843 | ||
844 | /* Not currently supported */ | ||
845 | tty->termios->c_cflag &= ~CRTSCTS; | ||
837 | /* Drop DTR/RTS if no flow control otherwise assert */ | 846 | /* Drop DTR/RTS if no flow control otherwise assert */ |
838 | #if 0 | 847 | #if 0 |
839 | if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) ) | 848 | if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) ) |