Commit 166ceb69 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: ftdi_sio: clean up line-status handling

Reverse priority of errors reported to ldisc so that it matches that of
other serial drivers (break takes precedence over parity, which takes
precedence over framing errors).

Also make sure overrun errors are handled as in other drivers, that is,
an overrun error is always reported and is not associated with any
received character (instead a NULL character with the TTY_OVERRUN flag
set is inserted).
Signed-off-by: default avatarJohan Hovold <jhovold@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d45cc8df
...@@ -1767,6 +1767,8 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port, ...@@ -1767,6 +1767,8 @@ static int ftdi_prepare_write_buffer(struct usb_serial_port *port,
return count; return count;
} }
#define FTDI_RS_ERR_MASK (FTDI_RS_BI | FTDI_RS_PE | FTDI_RS_FE | FTDI_RS_OE)
static int ftdi_process_packet(struct tty_struct *tty, static int ftdi_process_packet(struct tty_struct *tty,
struct usb_serial_port *port, struct ftdi_private *priv, struct usb_serial_port *port, struct ftdi_private *priv,
char *packet, int len) char *packet, int len)
...@@ -1793,28 +1795,21 @@ static int ftdi_process_packet(struct tty_struct *tty, ...@@ -1793,28 +1795,21 @@ static int ftdi_process_packet(struct tty_struct *tty,
priv->prev_status = status; priv->prev_status = status;
} }
/*
* Although the device uses a bitmask and hence can have multiple
* errors on a packet - the order here sets the priority the error is
* returned to the tty layer.
*/
flag = TTY_NORMAL; flag = TTY_NORMAL;
if (packet[1] & FTDI_RS_OE) { if (packet[1] & FTDI_RS_ERR_MASK) {
flag = TTY_OVERRUN; /* Break takes precedence over parity, which takes precedence
dbg("OVERRRUN error"); * over framing errors */
} if (packet[1] & FTDI_RS_BI) {
if (packet[1] & FTDI_RS_BI) { flag = TTY_BREAK;
flag = TTY_BREAK; usb_serial_handle_break(port);
dbg("BREAK received"); } else if (packet[1] & FTDI_RS_PE) {
usb_serial_handle_break(port); flag = TTY_PARITY;
} } else if (packet[1] & FTDI_RS_FE) {
if (packet[1] & FTDI_RS_PE) { flag = TTY_FRAME;
flag = TTY_PARITY; }
dbg("PARITY error"); /* Overrun is special, not associated with a char */
} if (packet[1] & FTDI_RS_OE)
if (packet[1] & FTDI_RS_FE) { tty_insert_flip_char(tty, 0, TTY_OVERRUN);
flag = TTY_FRAME;
dbg("FRAMING error");
} }
len -= 2; len -= 2;
......
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