Commit 68270dab authored by Johan Hovold's avatar Johan Hovold

USB: serial: pl2303: fix non-supported xon/xoff

Older pl2303 devices do not support automatic xon/xoff flow control, so
add add a flag to prevent trying to enable it for legacy device types.

Refactor the IXON test into a helper function to improve readability.

Fixes: 7041d9c3 ("USB: serial: pl2303: add support for tx xon/xoff flow control")
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 79a3aaa7
...@@ -156,6 +156,7 @@ enum pl2303_type { ...@@ -156,6 +156,7 @@ enum pl2303_type {
struct pl2303_type_data { struct pl2303_type_data {
speed_t max_baud_rate; speed_t max_baud_rate;
unsigned long quirks; unsigned long quirks;
unsigned int no_autoxonxoff:1;
}; };
struct pl2303_serial_private { struct pl2303_serial_private {
...@@ -175,6 +176,7 @@ static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = { ...@@ -175,6 +176,7 @@ static const struct pl2303_type_data pl2303_type_data[TYPE_COUNT] = {
[TYPE_01] = { [TYPE_01] = {
.max_baud_rate = 1228800, .max_baud_rate = 1228800,
.quirks = PL2303_QUIRK_LEGACY, .quirks = PL2303_QUIRK_LEGACY,
.no_autoxonxoff = true,
}, },
[TYPE_HX] = { [TYPE_HX] = {
.max_baud_rate = 12000000, .max_baud_rate = 12000000,
...@@ -552,6 +554,20 @@ static bool pl2303_termios_change(const struct ktermios *a, const struct ktermio ...@@ -552,6 +554,20 @@ static bool pl2303_termios_change(const struct ktermios *a, const struct ktermio
return tty_termios_hw_change(a, b) || ixon_change; 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;
}
static void pl2303_set_termios(struct tty_struct *tty, static void pl2303_set_termios(struct tty_struct *tty,
struct usb_serial_port *port, struct ktermios *old_termios) struct usb_serial_port *port, struct ktermios *old_termios)
{ {
...@@ -681,8 +697,7 @@ static void pl2303_set_termios(struct tty_struct *tty, ...@@ -681,8 +697,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
pl2303_vendor_write(serial, 0x0, 0x41); pl2303_vendor_write(serial, 0x0, 0x41);
else else
pl2303_vendor_write(serial, 0x0, 0x61); pl2303_vendor_write(serial, 0x0, 0x61);
} else if (I_IXON(tty) && !I_IXANY(tty) && START_CHAR(tty) == 0x11 && } else if (pl2303_enable_xonxoff(tty, spriv->type)) {
STOP_CHAR(tty) == 0x13) {
pl2303_vendor_write(serial, 0x0, 0xc0); pl2303_vendor_write(serial, 0x0, 0xc0);
} else { } else {
pl2303_vendor_write(serial, 0x0, 0x0); pl2303_vendor_write(serial, 0x0, 0x0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment