Skip to content

Commit aa03bda

Browse files
committed
Merge tag 'usb-serial-6.13-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next
Johan writes: USB-serial updates for 6.13-rc1 Here are the USB-serial updates for 6.13-rc1, including: - improved support for quirky pl2303 hxd devices - make sure ftdi_sio TIOCGSERIAL returns consistent data Everything has been in linux-next with no reported issues. * tag 'usb-serial-6.13-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial: USB: serial: ftdi_sio: Fix atomicity violation in get_serial_info() USB: serial: pl2303: account for deficits of clones
2 parents d6fa15b + 8b52494 commit aa03bda

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

drivers/usb/serial/ftdi_sio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,9 +1443,11 @@ static void get_serial_info(struct tty_struct *tty, struct serial_struct *ss)
14431443
struct usb_serial_port *port = tty->driver_data;
14441444
struct ftdi_private *priv = usb_get_serial_port_data(port);
14451445

1446+
mutex_lock(&priv->cfg_lock);
14461447
ss->flags = priv->flags;
14471448
ss->baud_base = priv->baud_base;
14481449
ss->custom_divisor = priv->custom_divisor;
1450+
mutex_unlock(&priv->cfg_lock);
14491451
}
14501452

14511453
static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss)

drivers/usb/serial/pl2303.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#define PL2303_QUIRK_UART_STATE_IDX0 BIT(0)
3232
#define PL2303_QUIRK_LEGACY BIT(1)
3333
#define PL2303_QUIRK_ENDPOINT_HACK BIT(2)
34+
#define PL2303_QUIRK_NO_BREAK_GETLINE BIT(3)
3435

3536
static const struct usb_device_id id_table[] = {
3637
{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID),
@@ -467,6 +468,25 @@ static int pl2303_detect_type(struct usb_serial *serial)
467468
return -ENODEV;
468469
}
469470

471+
static bool pl2303_is_hxd_clone(struct usb_serial *serial)
472+
{
473+
struct usb_device *udev = serial->dev;
474+
unsigned char *buf;
475+
int ret;
476+
477+
buf = kmalloc(7, GFP_KERNEL);
478+
if (!buf)
479+
return false;
480+
481+
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
482+
GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
483+
0, 0, buf, 7, 100);
484+
485+
kfree(buf);
486+
487+
return ret == -EPIPE;
488+
}
489+
470490
static int pl2303_startup(struct usb_serial *serial)
471491
{
472492
struct pl2303_serial_private *spriv;
@@ -489,6 +509,9 @@ static int pl2303_startup(struct usb_serial *serial)
489509
spriv->quirks = (unsigned long)usb_get_serial_data(serial);
490510
spriv->quirks |= spriv->type->quirks;
491511

512+
if (type == TYPE_HXD && pl2303_is_hxd_clone(serial))
513+
spriv->quirks |= PL2303_QUIRK_NO_BREAK_GETLINE;
514+
492515
usb_set_serial_data(serial, spriv);
493516

494517
if (type != TYPE_HXN) {
@@ -725,9 +748,18 @@ static void pl2303_encode_baud_rate(struct tty_struct *tty,
725748
static int pl2303_get_line_request(struct usb_serial_port *port,
726749
unsigned char buf[7])
727750
{
728-
struct usb_device *udev = port->serial->dev;
751+
struct usb_serial *serial = port->serial;
752+
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
753+
struct usb_device *udev = serial->dev;
729754
int ret;
730755

756+
if (spriv->quirks & PL2303_QUIRK_NO_BREAK_GETLINE) {
757+
struct pl2303_private *priv = usb_get_serial_port_data(port);
758+
759+
memcpy(buf, priv->line_settings, 7);
760+
return 0;
761+
}
762+
731763
ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
732764
GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
733765
0, 0, buf, 7, 100);
@@ -1064,9 +1096,13 @@ static int pl2303_carrier_raised(struct usb_serial_port *port)
10641096
static int pl2303_set_break(struct usb_serial_port *port, bool enable)
10651097
{
10661098
struct usb_serial *serial = port->serial;
1099+
struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
10671100
u16 state;
10681101
int result;
10691102

1103+
if (spriv->quirks & PL2303_QUIRK_NO_BREAK_GETLINE)
1104+
return -ENOTTY;
1105+
10701106
if (enable)
10711107
state = BREAK_ON;
10721108
else

0 commit comments

Comments
 (0)