Commit 4c72dfff authored by Andrew Worsley's avatar Andrew Worsley Committed by Greg Kroah-Hartman

USB: Fix Corruption issue in USB ftdi driver ftdi_sio.c

commit b1ffb4c8 upstream.

Fix for ftdi_set_termios() glitching output

ftdi_set_termios() is constantly setting the baud rate, data bits and parity
unnecessarily on every call, . When called while characters are being
transmitted can cause the FTDI chip to corrupt the serial port bit stream
output by stalling the output half a bit during the output of a character.
Simple fix by skipping this setting if the baud rate/data bits/parity are
unchanged.
Signed-off-by: default avatarAndrew Worsley <amworsley@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 22e88b06
...@@ -2083,13 +2083,19 @@ static void ftdi_set_termios(struct tty_struct *tty, ...@@ -2083,13 +2083,19 @@ static void ftdi_set_termios(struct tty_struct *tty,
cflag = termios->c_cflag; cflag = termios->c_cflag;
/* FIXME -For this cut I don't care if the line is really changing or if (old_termios->c_cflag == termios->c_cflag
not - so just do the change regardless - should be able to && old_termios->c_ispeed == termios->c_ispeed
compare old_termios and tty->termios */ && old_termios->c_ospeed == termios->c_ospeed)
goto no_c_cflag_changes;
/* NOTE These routines can get interrupted by /* NOTE These routines can get interrupted by
ftdi_sio_read_bulk_callback - need to examine what this means - ftdi_sio_read_bulk_callback - need to examine what this means -
don't see any problems yet */ don't see any problems yet */
if ((old_termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)) ==
(termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)))
goto no_data_parity_stop_changes;
/* Set number of data bits, parity, stop bits */ /* Set number of data bits, parity, stop bits */
urb_value = 0; urb_value = 0;
...@@ -2130,6 +2136,7 @@ static void ftdi_set_termios(struct tty_struct *tty, ...@@ -2130,6 +2136,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
} }
/* Now do the baudrate */ /* Now do the baudrate */
no_data_parity_stop_changes:
if ((cflag & CBAUD) == B0) { if ((cflag & CBAUD) == B0) {
/* Disable flow control */ /* Disable flow control */
if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
...@@ -2157,6 +2164,7 @@ static void ftdi_set_termios(struct tty_struct *tty, ...@@ -2157,6 +2164,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
/* Set flow control */ /* Set flow control */
/* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
no_c_cflag_changes:
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
dbg("%s Setting to CRTSCTS flow control", __func__); dbg("%s Setting to CRTSCTS flow control", __func__);
if (usb_control_msg(dev, if (usb_control_msg(dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment