From: Johan Hovold <johan@kernel.org> To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Florian Zumbiehl <florz@florz.de>, Johan Hovold <johan@kernel.org> Subject: USB: serial: pl2303: fix xon/xoff flow control Date: Thu, 18 Apr 2019 18:03:52 +0200 [thread overview] Message-ID: <20190418160352.17793-1-johan@kernel.org> (raw) 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(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 55122ac84518..dc20a3359601 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -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);
WARNING: multiple messages have this Message-ID (diff)
From: Johan Hovold <johan@kernel.org> To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Florian Zumbiehl <florz@florz.de>, Johan Hovold <johan@kernel.org> Subject: [PATCH] USB: serial: pl2303: fix xon/xoff flow control Date: Thu, 18 Apr 2019 18:03:52 +0200 [thread overview] Message-ID: <20190418160352.17793-1-johan@kernel.org> (raw) Message-ID: <20190418160352.uxLK7xLY-XT138HErBUALMfQacTBKaNL8l91HzfE8m8@z> (raw) 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(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 55122ac84518..dc20a3359601 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -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); -- 2.21.0
next reply other threads:[~2019-04-18 16:03 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-04-18 16:03 Johan Hovold [this message] 2019-04-18 16:03 ` [PATCH] USB: serial: pl2303: fix xon/xoff flow control Johan Hovold 2019-04-19 8:28 Greg Kroah-Hartman 2019-04-19 8:28 ` [PATCH] " Greg Kroah-Hartman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190418160352.17793-1-johan@kernel.org \ --to=johan@kernel.org \ --cc=florz@florz.de \ --cc=gregkh@linuxfoundation.org \ --cc=linux-usb@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.