From 467794e88dc08f61e1068c510c97baa9a12b841d Mon Sep 17 00:00:00 2001
From: Nicolas PLANEL <nicolas.planel@xxxxxxxxxxxx>
Date: Tue, 17 Feb 2015 00:59:14 -0500
Subject: [PATCH] USB: ch341: set tty baud speed according to tty struct
The ch341_set_baudrate() function initialize the device baud speed according
to the value on priv->baud_rate. By default the ch341_open() set it to a
hardcoded value (DEFAULT_BAUD_RATE 9600). Unfortunately, the tty_struct is
not initialized with the same default value. (usually 56700)
This means that the tty_struct and the device baud rate generator are not
synchronized after opening the port.
Fixup is elementary simple by calling tty_get_baud_rate() and
tty_encode_baud_rate() helper to sync up the baud rate during the
ch341_open() call.
Signed-off-by: Nicolas PLANEL <nicolas.planel@xxxxxxxxxxxx>
---
drivers/usb/serial/ch341.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index 2d72aa3564a3..2dbbbf6d4187 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -307,9 +307,13 @@ static int ch341_open(struct tty_struct *tty,
struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
struct ch341_private *priv = usb_get_serial_port_data(port);
+ unsigned baud;
int r;
priv->baud_rate = DEFAULT_BAUD_RATE;
+ baud = tty_get_baud_rate(tty);
+ if (baud)
+ priv->baud_rate = baud;
r = ch341_configure(serial->dev, priv);
if (r)
@@ -323,6 +327,9 @@ static int ch341_open(struct tty_struct *tty, struct
usb_serial_port *port)
if (r)
goto out;
+ baud = priv->baud_rate;
+ tty_encode_baud_rate(tty, baud, baud);
+
dev_dbg(&port->dev, "%s - submitting interrupt urb\n", __func__);
r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (r) {
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html