@@ -570,27 +570,13 @@ static int pl2303_set_line_request(struct usb_serial_port *port,
static bool pl2303_termios_change(const struct ktermios *a, const struct ktermios *b)
{
- bool ixon_change;
+ bool xonxoff_change;
- ixon_change = ((a->c_iflag ^ b->c_iflag) & (IXON | IXANY)) ||
+ xonxoff_change = ((a->c_iflag ^ b->c_iflag) & (IXON | IXANY | IXOFF)) ||
a->c_cc[VSTART] != b->c_cc[VSTART] ||
a->c_cc[VSTOP] != b->c_cc[VSTOP];
- return tty_termios_hw_change(a, b) || ixon_change;
-}
-
-static bool pl2303_enable_xonxoff(struct tty_struct *tty, const struct pl2303_type_data *type)
-{
- if (!I_IXON(tty) || I_IXANY(tty))
- return false;
-
- if (START_CHAR(tty) != 0x11 || STOP_CHAR(tty) != 0x13)
- return false;
-
- if (type->no_autoxonxoff)
- return false;
-
- return true;
+ return tty_termios_hw_change(a, b) || xonxoff_change;
}
static void pl2303_set_termios(struct tty_struct *tty,
@@ -717,12 +703,19 @@ static void pl2303_set_termios(struct tty_struct *tty,
spin_unlock_irqrestore(&priv->lock, flags);
}
+ tty->termios.c_iflag &= ~(IXANY | IXOFF);
+ if (spriv->type->no_autoxonxoff)
+ tty->termios.c_iflag &= ~IXON;
+
+ tty->termios.c_cc[VSTART] = 0x11;
+ tty->termios.c_cc[VSTOP] = 0x13;
+
if (C_CRTSCTS(tty)) {
if (spriv->quirks & PL2303_QUIRK_LEGACY)
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x40);
else
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x60);
- } else if (pl2303_enable_xonxoff(tty, spriv->type)) {
+ } else if (I_IXON(tty)) {
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0xc0);
} else {
pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0);
Fix the XON/XOFF flow-control implementation by reporting back the attributes actually supported while ignoring the rest. Note that only outgoing XON/XOFF flow control (IXON) is currently supported for PL2303HX, and only using the default start and stop chars. Fixes: 68270dab9710 ("USB: serial: pl2303: fix non-supported xon/xoff") Fixes: 7041d9c3f01b ("USB: serial: pl2303: add support for tx xon/xoff flow control") Signed-off-by: Johan Hovold <johan@kernel.org> --- drivers/usb/serial/pl2303.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)