* [PATCH stable-4.9] USB: serial: ch341: fix modem-control and B0 handling
@ 2017-01-17 15:19 Johan Hovold
2017-01-17 15:31 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2017-01-17 15:19 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Johan Hovold, stable
commit 030ee7ae52a46a2be52ccc8242c4a330aba8d38e upstream.
The modem-control signals are managed by the tty-layer during open and
should not be asserted prematurely when set_termios is called from
driver open.
Also make sure that the signals are asserted only when changing speed
from B0.
Fixes: 664d5df92e88 ("USB: usb-serial ch341: support for DTR/RTS/CTS")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
This is a backport of 030ee7ae52a4 ("USB: serial: ch341: fix
modem-control and B0 handling") to 4.9 that should apply also to 4.4.
Johan
drivers/usb/serial/ch341.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 3a48302c1cd5..d23dfdd0247d 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -345,24 +345,24 @@ static void ch341_set_termios(struct tty_struct *tty,
baud_rate = tty_get_baud_rate(tty);
if (baud_rate) {
- spin_lock_irqsave(&priv->lock, flags);
- priv->line_control |= (CH341_BIT_DTR | CH341_BIT_RTS);
- spin_unlock_irqrestore(&priv->lock, flags);
priv->baud_rate = baud_rate;
ch341_set_baudrate(port->serial->dev, priv);
- } else {
- spin_lock_irqsave(&priv->lock, flags);
- priv->line_control &= ~(CH341_BIT_DTR | CH341_BIT_RTS);
- spin_unlock_irqrestore(&priv->lock, flags);
}
- ch341_set_handshake(port->serial->dev, priv->line_control);
-
/* Unimplemented:
* (cflag & CSIZE) : data bits [5, 8]
* (cflag & PARENB) : parity {NONE, EVEN, ODD}
* (cflag & CSTOPB) : stop bits [1, 2]
*/
+
+ spin_lock_irqsave(&priv->lock, flags);
+ if (C_BAUD(tty) == B0)
+ priv->line_control &= ~(CH341_BIT_DTR | CH341_BIT_RTS);
+ else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
+ priv->line_control |= (CH341_BIT_DTR | CH341_BIT_RTS);
+ spin_unlock_irqrestore(&priv->lock, flags);
+
+ ch341_set_handshake(port->serial->dev, priv->line_control);
}
static void ch341_break_ctl(struct tty_struct *tty, int break_state)
--
2.10.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH stable-4.9] USB: serial: ch341: fix modem-control and B0 handling
2017-01-17 15:19 [PATCH stable-4.9] USB: serial: ch341: fix modem-control and B0 handling Johan Hovold
@ 2017-01-17 15:31 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2017-01-17 15:31 UTC (permalink / raw)
To: Johan Hovold; +Cc: stable
On Tue, Jan 17, 2017 at 04:19:57PM +0100, Johan Hovold wrote:
> commit 030ee7ae52a46a2be52ccc8242c4a330aba8d38e upstream.
>
> The modem-control signals are managed by the tty-layer during open and
> should not be asserted prematurely when set_termios is called from
> driver open.
>
> Also make sure that the signals are asserted only when changing speed
> from B0.
>
> Fixes: 664d5df92e88 ("USB: usb-serial ch341: support for DTR/RTS/CTS")
> Cc: stable <stable@vger.kernel.org>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>
> This is a backport of 030ee7ae52a4 ("USB: serial: ch341: fix
> modem-control and B0 handling") to 4.9 that should apply also to 4.4.
Thanks for the backport, now applied.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-17 15:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-17 15:19 [PATCH stable-4.9] USB: serial: ch341: fix modem-control and B0 handling Johan Hovold
2017-01-17 15:31 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).