All of lore.kernel.org
 help / color / mirror / Atom feed
* USB: serial: pl2303: fix xon/xoff flow control
@ 2019-04-18 16:03 ` Johan Hovold
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2019-04-18 16:03 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Florian Zumbiehl, Johan Hovold

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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] USB: serial: pl2303: fix xon/xoff flow control
@ 2019-04-18 16:03 ` Johan Hovold
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2019-04-18 16:03 UTC (permalink / raw)
  To: linux-usb; +Cc: Greg Kroah-Hartman, Florian Zumbiehl, Johan Hovold

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* USB: serial: pl2303: fix xon/xoff flow control
@ 2019-04-19  8:28 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-04-19  8:28 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, Florian Zumbiehl

On Thu, Apr 18, 2019 at 06:03:52PM +0200, Johan Hovold wrote:
> 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(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] USB: serial: pl2303: fix xon/xoff flow control
@ 2019-04-19  8:28 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-04-19  8:28 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-usb, Florian Zumbiehl

On Thu, Apr 18, 2019 at 06:03:52PM +0200, Johan Hovold wrote:
> 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(-)

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-19 18:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 16:03 USB: serial: pl2303: fix xon/xoff flow control Johan Hovold
2019-04-18 16:03 ` [PATCH] " Johan Hovold
2019-04-19  8:28 Greg Kroah-Hartman
2019-04-19  8:28 ` [PATCH] " Greg Kroah-Hartman

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.