From: Johan Hovold <johan@kernel.org>
To: Jari Ruusu <jariruusu@users.sourceforge.net>
Cc: Johan Hovold <johan@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: usb serial: pl2303 driver TxD "break" stays after close() bug
Date: Fri, 20 Feb 2015 10:25:33 +0700 [thread overview]
Message-ID: <20150220032533.GM12405@localhost> (raw)
In-Reply-To: <CACMCwJKsr5R2N6zK-+fKEwHLf6xM6q+ni3dAEm3jz+LkE6rM3w@mail.gmail.com>
On Thu, Feb 19, 2015 at 03:38:39PM +0200, Jari Ruusu wrote:
> On 2/19/15, Johan Hovold <johan@kernel.org> wrote:
> > What happens when you reopen the port? Is the break state cleared then?
>
> Stuck "break" signal is not cleared on re-open.
>
> To clear it, you need to poke it with ioctl(fd, TIOCCBRK, 0)
> or disconnect the device.
That's definitely a bug.
Care to test the patch below?
Thanks,
Johan
>From ee3f2d35adc59822d72f3908078da7f361c26577 Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan@kernel.org>
Date: Fri, 20 Feb 2015 10:05:51 +0700
Subject: [PATCH] USB: pl2303: disable break on shutdown
Currently an enabled break state is not disabled on final close nor on
re-open and has to be disabled manually.
Fix this by disabling break on port shutdown.
Reported-by: Jari Ruusu <jariruusu@users.sourceforge.net>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/pl2303.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 0f872e6b2c87..f6fe4737185d 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -132,6 +132,7 @@ MODULE_DEVICE_TABLE(usb, id_table);
#define UART_OVERRUN_ERROR 0x40
#define UART_CTS 0x80
+static void pl2303_set_break(struct usb_serial_port *port, bool enable);
enum pl2303_type {
TYPE_01, /* Type 0 and 1 (difference unknown) */
@@ -613,6 +614,7 @@ static void pl2303_dtr_rts(struct usb_serial_port *port, int on)
static void pl2303_close(struct usb_serial_port *port)
{
+ pl2303_set_break(port, false);
usb_serial_generic_close(port);
usb_kill_urb(port->interrupt_in_urb);
}
@@ -741,17 +743,16 @@ static int pl2303_ioctl(struct tty_struct *tty,
return -ENOIOCTLCMD;
}
-static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
+static void pl2303_set_break(struct usb_serial_port *port, bool enable)
{
- struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial;
u16 state;
int result;
- if (break_state == 0)
- state = BREAK_OFF;
- else
+ if (enable)
state = BREAK_ON;
+ else
+ state = BREAK_OFF;
dev_dbg(&port->dev, "%s - turning break %s\n", __func__,
state == BREAK_OFF ? "off" : "on");
@@ -763,6 +764,13 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
dev_err(&port->dev, "error sending break = %d\n", result);
}
+static void pl2303_break_ctl(struct tty_struct *tty, int state)
+{
+ struct usb_serial_port *port = tty->driver_data;
+
+ pl2303_set_break(port, state);
+}
+
static void pl2303_update_line_status(struct usb_serial_port *port,
unsigned char *data,
unsigned int actual_length)
--
2.0.5
next prev parent reply other threads:[~2015-02-20 3:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-05 10:56 usb serial: pl2303 driver TxD "break" stays after close() bug Jari Ruusu
2015-02-19 5:50 ` Johan Hovold
2015-02-19 13:38 ` Jari Ruusu
2015-02-20 3:25 ` Johan Hovold [this message]
2015-02-20 13:11 ` Jari Ruusu
2015-02-21 3:09 ` Johan Hovold
2015-02-26 15:50 ` [PATCH] USB: pl2303: disable break on shutdown Johan Hovold
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=20150220032533.GM12405@localhost \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jariruusu@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.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: link
Be 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.