* [PATCH v2 01/14] USB: serial: ch341: fix initial modem-control state
[not found] <20170106181523.21324-1-johan@kernel.org>
@ 2017-01-06 18:15 ` Johan Hovold
2017-01-06 18:15 ` [PATCH v2 02/14] USB: serial: ch341: fix open and resume after B0 Johan Hovold
` (3 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2017-01-06 18:15 UTC (permalink / raw)
To: linux-usb
Cc: Aidan Thornton, Grigori Goronzy, Karl Palsson, Russell Senior,
Eddi De Pieri, Johan Hovold, stable
DTR and RTS will be asserted by the tty-layer when the port is opened
and deasserted on close (if HUPCL is set). Make sure the initial state
is not-asserted before the port is first opened as well.
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>
---
drivers/usb/serial/ch341.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 2597b83a8ae2..d133e72fe888 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -258,7 +258,6 @@ static int ch341_port_probe(struct usb_serial_port *port)
spin_lock_init(&priv->lock);
priv->baud_rate = DEFAULT_BAUD_RATE;
- priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR;
r = ch341_configure(port->serial->dev, priv);
if (r < 0)
--
2.10.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 02/14] USB: serial: ch341: fix open and resume after B0
[not found] <20170106181523.21324-1-johan@kernel.org>
2017-01-06 18:15 ` [PATCH v2 01/14] USB: serial: ch341: fix initial modem-control state Johan Hovold
@ 2017-01-06 18:15 ` Johan Hovold
2017-01-06 18:15 ` [PATCH v2 03/14] USB: serial: ch341: fix modem-control and B0 handling Johan Hovold
` (2 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2017-01-06 18:15 UTC (permalink / raw)
To: linux-usb
Cc: Aidan Thornton, Grigori Goronzy, Karl Palsson, Russell Senior,
Eddi De Pieri, Johan Hovold, stable
The private baud_rate variable is used to configure the port at open and
reset-resume and must never be set to (and left at) zero or reset-resume
and all further open attempts will fail.
Fixes: aa91def41a7b ("USB: ch341: set tty baud speed according to tty
struct")
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>
---
drivers/usb/serial/ch341.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index d133e72fe888..6279df905c14 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -355,7 +355,6 @@ static void ch341_set_termios(struct tty_struct *tty,
baud_rate = tty_get_baud_rate(tty);
- priv->baud_rate = baud_rate;
ctrl = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX;
switch (C_CSIZE(tty)) {
@@ -388,6 +387,9 @@ static void ch341_set_termios(struct tty_struct *tty,
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;
+
r = ch341_init_set_baudrate(port->serial->dev, priv, ctrl);
if (r < 0 && old_termios) {
priv->baud_rate = tty_termios_baud_rate(old_termios);
--
2.10.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 03/14] USB: serial: ch341: fix modem-control and B0 handling
[not found] <20170106181523.21324-1-johan@kernel.org>
2017-01-06 18:15 ` [PATCH v2 01/14] USB: serial: ch341: fix initial modem-control state Johan Hovold
2017-01-06 18:15 ` [PATCH v2 02/14] USB: serial: ch341: fix open and resume after B0 Johan Hovold
@ 2017-01-06 18:15 ` Johan Hovold
2017-01-06 18:15 ` [PATCH v2 04/14] USB: serial: ch341: fix open error handling Johan Hovold
2017-01-06 18:15 ` [PATCH v2 05/14] USB: serial: ch341: fix resume after reset Johan Hovold
4 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2017-01-06 18:15 UTC (permalink / raw)
To: linux-usb
Cc: Aidan Thornton, Grigori Goronzy, Karl Palsson, Russell Senior,
Eddi De Pieri, Johan Hovold, stable
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>
---
drivers/usb/serial/ch341.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 6279df905c14..0cc5056b304d 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -384,10 +384,6 @@ static void ch341_set_termios(struct tty_struct *tty,
ctrl |= CH341_LCR_STOP_BITS_2;
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;
r = ch341_init_set_baudrate(port->serial->dev, priv, ctrl);
@@ -395,14 +391,16 @@ static void ch341_set_termios(struct tty_struct *tty,
priv->baud_rate = tty_termios_baud_rate(old_termios);
tty_termios_copy_hw(&tty->termios, old_termios);
}
- } 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);
+ 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] 5+ messages in thread
* [PATCH v2 04/14] USB: serial: ch341: fix open error handling
[not found] <20170106181523.21324-1-johan@kernel.org>
` (2 preceding siblings ...)
2017-01-06 18:15 ` [PATCH v2 03/14] USB: serial: ch341: fix modem-control and B0 handling Johan Hovold
@ 2017-01-06 18:15 ` Johan Hovold
2017-01-06 18:15 ` [PATCH v2 05/14] USB: serial: ch341: fix resume after reset Johan Hovold
4 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2017-01-06 18:15 UTC (permalink / raw)
To: linux-usb
Cc: Aidan Thornton, Grigori Goronzy, Karl Palsson, Russell Senior,
Eddi De Pieri, Johan Hovold, stable
Make sure to stop the interrupt URB before returning on errors during
open.
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>
---
drivers/usb/serial/ch341.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 0cc5056b304d..8f41d4385f1c 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -319,7 +319,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
r = ch341_configure(serial->dev, priv);
if (r)
- goto out;
+ return r;
if (tty)
ch341_set_termios(tty, port, NULL);
@@ -329,12 +329,19 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
if (r) {
dev_err(&port->dev, "%s - failed to submit interrupt urb: %d\n",
__func__, r);
- goto out;
+ return r;
}
r = usb_serial_generic_open(tty, port);
+ if (r)
+ goto err_kill_interrupt_urb;
+
+ return 0;
+
+err_kill_interrupt_urb:
+ usb_kill_urb(port->interrupt_in_urb);
-out: return r;
+ return r;
}
/* Old_termios contains the original termios settings and
--
2.10.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 05/14] USB: serial: ch341: fix resume after reset
[not found] <20170106181523.21324-1-johan@kernel.org>
` (3 preceding siblings ...)
2017-01-06 18:15 ` [PATCH v2 04/14] USB: serial: ch341: fix open error handling Johan Hovold
@ 2017-01-06 18:15 ` Johan Hovold
4 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2017-01-06 18:15 UTC (permalink / raw)
To: linux-usb
Cc: Aidan Thornton, Grigori Goronzy, Karl Palsson, Russell Senior,
Eddi De Pieri, Johan Hovold, stable
Fix reset-resume handling which failed to resubmit the read and
interrupt URBs, thereby leaving a port that was open before suspend in a
broken state until closed and reopened.
Fixes: 1ded7ea47b88 ("USB: ch341 serial: fix port number changed after
resume")
Fixes: 2bfd1c96a9fb ("USB: serial: ch341: remove reset_resume callback")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/ch341.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 8f41d4385f1c..5343d65f3b52 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -582,14 +582,23 @@ static int ch341_tiocmget(struct tty_struct *tty)
static int ch341_reset_resume(struct usb_serial *serial)
{
- struct ch341_private *priv;
-
- priv = usb_get_serial_port_data(serial->port[0]);
+ struct usb_serial_port *port = serial->port[0];
+ struct ch341_private *priv = usb_get_serial_port_data(port);
+ int ret;
/* reconfigure ch341 serial port after bus-reset */
ch341_configure(serial->dev, priv);
- return 0;
+ if (tty_port_initialized(&port->port)) {
+ ret = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
+ if (ret) {
+ dev_err(&port->dev, "failed to submit interrupt urb: %d\n",
+ ret);
+ return ret;
+ }
+ }
+
+ return usb_serial_generic_resume(serial);
}
static struct usb_serial_driver ch341_device = {
--
2.10.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-06 18:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170106181523.21324-1-johan@kernel.org>
2017-01-06 18:15 ` [PATCH v2 01/14] USB: serial: ch341: fix initial modem-control state Johan Hovold
2017-01-06 18:15 ` [PATCH v2 02/14] USB: serial: ch341: fix open and resume after B0 Johan Hovold
2017-01-06 18:15 ` [PATCH v2 03/14] USB: serial: ch341: fix modem-control and B0 handling Johan Hovold
2017-01-06 18:15 ` [PATCH v2 04/14] USB: serial: ch341: fix open error handling Johan Hovold
2017-01-06 18:15 ` [PATCH v2 05/14] USB: serial: ch341: fix resume after reset Johan Hovold
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).