Skip to content

Commit 0e5342f

Browse files
committed
Merge tag 'usb-serial-6.5-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next
Johan writes: USB-serial updates for 6.5-rc1 Here are the USB-serial updates for 6.5-rc1, including: - improved error handling for break signalling - report to user space when a device does not support break signalling Included are also some new modem device ids. All have been in linux-next with no reported issues. * tag 'usb-serial-6.5-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial: USB: serial: option: add LARA-R6 01B PIDs USB: serial: report unsupported break signalling USB: serial: cp210x: disable break signalling on CP2105 SCI USB: serial: return errors from break handling
2 parents e6ecc04 + ffa5f7a commit 0e5342f

26 files changed

Lines changed: 151 additions & 73 deletions

drivers/usb/serial/ark3116.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,11 @@ static int ark3116_tiocmset(struct tty_struct *tty,
433433
return 0;
434434
}
435435

436-
static void ark3116_break_ctl(struct tty_struct *tty, int break_state)
436+
static int ark3116_break_ctl(struct tty_struct *tty, int break_state)
437437
{
438438
struct usb_serial_port *port = tty->driver_data;
439439
struct ark3116_private *priv = usb_get_serial_port_data(port);
440+
int ret;
440441

441442
/* LCR is also used for other things: protect access */
442443
mutex_lock(&priv->hw_lock);
@@ -446,9 +447,11 @@ static void ark3116_break_ctl(struct tty_struct *tty, int break_state)
446447
else
447448
priv->lcr &= ~UART_LCR_SBC;
448449

449-
ark3116_write_reg(port->serial, UART_LCR, priv->lcr);
450+
ret = ark3116_write_reg(port->serial, UART_LCR, priv->lcr);
450451

451452
mutex_unlock(&priv->hw_lock);
453+
454+
return ret;
452455
}
453456

454457
static void ark3116_update_msr(struct usb_serial_port *port, __u8 msr)

drivers/usb/serial/belkin_sa.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void belkin_sa_process_read_urb(struct urb *urb);
4646
static void belkin_sa_set_termios(struct tty_struct *tty,
4747
struct usb_serial_port *port,
4848
const struct ktermios *old_termios);
49-
static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state);
49+
static int belkin_sa_break_ctl(struct tty_struct *tty, int break_state);
5050
static int belkin_sa_tiocmget(struct tty_struct *tty);
5151
static int belkin_sa_tiocmset(struct tty_struct *tty,
5252
unsigned int set, unsigned int clear);
@@ -399,13 +399,19 @@ static void belkin_sa_set_termios(struct tty_struct *tty,
399399
spin_unlock_irqrestore(&priv->lock, flags);
400400
}
401401

402-
static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state)
402+
static int belkin_sa_break_ctl(struct tty_struct *tty, int break_state)
403403
{
404404
struct usb_serial_port *port = tty->driver_data;
405405
struct usb_serial *serial = port->serial;
406+
int ret;
406407

407-
if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
408+
ret = BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0);
409+
if (ret < 0) {
408410
dev_err(&port->dev, "Set break_ctl %d\n", break_state);
411+
return ret;
412+
}
413+
414+
return 0;
409415
}
410416

411417
static int belkin_sa_tiocmget(struct tty_struct *tty)

drivers/usb/serial/ch341.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,12 @@ static void ch341_set_termios(struct tty_struct *tty,
562562
* TCSBRKP. Due to how the simulation is implemented the duration can't be
563563
* controlled. The duration is always about (1s / 46bd * 9bit) = 196ms.
564564
*/
565-
static void ch341_simulate_break(struct tty_struct *tty, int break_state)
565+
static int ch341_simulate_break(struct tty_struct *tty, int break_state)
566566
{
567567
struct usb_serial_port *port = tty->driver_data;
568568
struct ch341_private *priv = usb_get_serial_port_data(port);
569569
unsigned long now, delay;
570-
int r;
570+
int r, r2;
571571

572572
if (break_state != 0) {
573573
dev_dbg(&port->dev, "enter break state requested\n");
@@ -599,7 +599,7 @@ static void ch341_simulate_break(struct tty_struct *tty, int break_state)
599599
*/
600600
priv->break_end = jiffies + (11 * HZ / CH341_MIN_BPS);
601601

602-
return;
602+
return 0;
603603
}
604604

605605
dev_dbg(&port->dev, "leave break state requested\n");
@@ -615,17 +615,22 @@ static void ch341_simulate_break(struct tty_struct *tty, int break_state)
615615
schedule_timeout_interruptible(delay);
616616
}
617617

618+
r = 0;
618619
restore:
619620
/* Restore original baud rate */
620-
r = ch341_set_baudrate_lcr(port->serial->dev, priv, priv->baud_rate,
621-
priv->lcr);
622-
if (r < 0)
621+
r2 = ch341_set_baudrate_lcr(port->serial->dev, priv, priv->baud_rate,
622+
priv->lcr);
623+
if (r2 < 0) {
623624
dev_err(&port->dev,
624625
"restoring original baud rate of %u failed: %d\n",
625-
priv->baud_rate, r);
626+
priv->baud_rate, r2);
627+
return r2;
628+
}
629+
630+
return r;
626631
}
627632

628-
static void ch341_break_ctl(struct tty_struct *tty, int break_state)
633+
static int ch341_break_ctl(struct tty_struct *tty, int break_state)
629634
{
630635
const uint16_t ch341_break_reg =
631636
((uint16_t) CH341_REG_LCR << 8) | CH341_REG_BREAK;
@@ -635,17 +640,17 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state)
635640
uint16_t reg_contents;
636641
uint8_t break_reg[2];
637642

638-
if (priv->quirks & CH341_QUIRK_SIMULATE_BREAK) {
639-
ch341_simulate_break(tty, break_state);
640-
return;
641-
}
643+
if (priv->quirks & CH341_QUIRK_SIMULATE_BREAK)
644+
return ch341_simulate_break(tty, break_state);
642645

643646
r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG,
644647
ch341_break_reg, 0, break_reg, 2);
645648
if (r) {
646649
dev_err(&port->dev, "%s - USB control read error (%d)\n",
647650
__func__, r);
648-
return;
651+
if (r > 0)
652+
r = -EIO;
653+
return r;
649654
}
650655
dev_dbg(&port->dev, "%s - initial ch341 break register contents - reg1: %x, reg2: %x\n",
651656
__func__, break_reg[0], break_reg[1]);
@@ -663,9 +668,13 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state)
663668
reg_contents = get_unaligned_le16(break_reg);
664669
r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG,
665670
ch341_break_reg, reg_contents);
666-
if (r < 0)
671+
if (r < 0) {
667672
dev_err(&port->dev, "%s - USB control write error (%d)\n",
668673
__func__, r);
674+
return r;
675+
}
676+
677+
return 0;
669678
}
670679

671680
static int ch341_tiocmset(struct tty_struct *tty,

drivers/usb/serial/cp210x.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int cp210x_tiocmget(struct tty_struct *);
3939
static int cp210x_tiocmset(struct tty_struct *, unsigned int, unsigned int);
4040
static int cp210x_tiocmset_port(struct usb_serial_port *port,
4141
unsigned int, unsigned int);
42-
static void cp210x_break_ctl(struct tty_struct *, int);
42+
static int cp210x_break_ctl(struct tty_struct *, int);
4343
static int cp210x_attach(struct usb_serial *);
4444
static void cp210x_disconnect(struct usb_serial *);
4545
static void cp210x_release(struct usb_serial *);
@@ -1434,18 +1434,26 @@ static int cp210x_tiocmget(struct tty_struct *tty)
14341434
return result;
14351435
}
14361436

1437-
static void cp210x_break_ctl(struct tty_struct *tty, int break_state)
1437+
static int cp210x_break_ctl(struct tty_struct *tty, int break_state)
14381438
{
14391439
struct usb_serial_port *port = tty->driver_data;
1440+
struct cp210x_serial_private *priv = usb_get_serial_data(port->serial);
14401441
u16 state;
14411442

1443+
if (priv->partnum == CP210X_PARTNUM_CP2105) {
1444+
if (cp210x_interface_num(port->serial) == 1)
1445+
return -ENOTTY;
1446+
}
1447+
14421448
if (break_state == 0)
14431449
state = BREAK_OFF;
14441450
else
14451451
state = BREAK_ON;
1452+
14461453
dev_dbg(&port->dev, "%s - turning break %s\n", __func__,
14471454
state == BREAK_OFF ? "off" : "on");
1448-
cp210x_write_u16_reg(port, CP210X_SET_BREAK, state);
1455+
1456+
return cp210x_write_u16_reg(port, CP210X_SET_BREAK, state);
14491457
}
14501458

14511459
#ifdef CONFIG_GPIOLIB

drivers/usb/serial/digi_acceleport.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static void digi_rx_unthrottle(struct tty_struct *tty);
217217
static void digi_set_termios(struct tty_struct *tty,
218218
struct usb_serial_port *port,
219219
const struct ktermios *old_termios);
220-
static void digi_break_ctl(struct tty_struct *tty, int break_state);
220+
static int digi_break_ctl(struct tty_struct *tty, int break_state);
221221
static int digi_tiocmget(struct tty_struct *tty);
222222
static int digi_tiocmset(struct tty_struct *tty, unsigned int set,
223223
unsigned int clear);
@@ -839,7 +839,7 @@ static void digi_set_termios(struct tty_struct *tty,
839839
}
840840

841841

842-
static void digi_break_ctl(struct tty_struct *tty, int break_state)
842+
static int digi_break_ctl(struct tty_struct *tty, int break_state)
843843
{
844844
struct usb_serial_port *port = tty->driver_data;
845845
unsigned char buf[4];
@@ -848,7 +848,8 @@ static void digi_break_ctl(struct tty_struct *tty, int break_state)
848848
buf[1] = 2; /* length */
849849
buf[2] = break_state ? 1 : 0;
850850
buf[3] = 0; /* pad */
851-
digi_write_inb_command(port, buf, 4, 0);
851+
852+
return digi_write_inb_command(port, buf, 4, 0);
852853
}
853854

854855

drivers/usb/serial/f81232.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static void f81534a_process_read_urb(struct urb *urb)
448448
tty_flip_buffer_push(&port->port);
449449
}
450450

451-
static void f81232_break_ctl(struct tty_struct *tty, int break_state)
451+
static int f81232_break_ctl(struct tty_struct *tty, int break_state)
452452
{
453453
struct usb_serial_port *port = tty->driver_data;
454454
struct f81232_private *priv = usb_get_serial_port_data(port);
@@ -467,6 +467,8 @@ static void f81232_break_ctl(struct tty_struct *tty, int break_state)
467467
dev_err(&port->dev, "set break failed: %d\n", status);
468468

469469
mutex_unlock(&priv->lock);
470+
471+
return status;
470472
}
471473

472474
static int f81232_find_clk(speed_t baudrate)

drivers/usb/serial/f81534.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ static int f81534_set_port_config(struct usb_serial_port *port,
656656
return status;
657657
}
658658

659-
static void f81534_break_ctl(struct tty_struct *tty, int break_state)
659+
static int f81534_break_ctl(struct tty_struct *tty, int break_state)
660660
{
661661
struct usb_serial_port *port = tty->driver_data;
662662
struct f81534_port_private *port_priv = usb_get_serial_port_data(port);
@@ -675,6 +675,8 @@ static void f81534_break_ctl(struct tty_struct *tty, int break_state)
675675
dev_err(&port->dev, "set break failed: %d\n", status);
676676

677677
mutex_unlock(&port_priv->lcr_mutex);
678+
679+
return status;
678680
}
679681

680682
static int f81534_update_mctrl(struct usb_serial_port *port, unsigned int set,

drivers/usb/serial/ftdi_sio.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,11 +2550,12 @@ static void ftdi_process_read_urb(struct urb *urb)
25502550
tty_flip_buffer_push(&port->port);
25512551
}
25522552

2553-
static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2553+
static int ftdi_break_ctl(struct tty_struct *tty, int break_state)
25542554
{
25552555
struct usb_serial_port *port = tty->driver_data;
25562556
struct ftdi_private *priv = usb_get_serial_port_data(port);
25572557
u16 value;
2558+
int ret;
25582559

25592560
/* break_state = -1 to turn on break, and 0 to turn off break */
25602561
/* see drivers/char/tty_io.c to see it used */
@@ -2565,19 +2566,22 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
25652566
else
25662567
value = priv->last_set_data_value;
25672568

2568-
if (usb_control_msg(port->serial->dev,
2569+
ret = usb_control_msg(port->serial->dev,
25692570
usb_sndctrlpipe(port->serial->dev, 0),
25702571
FTDI_SIO_SET_DATA_REQUEST,
25712572
FTDI_SIO_SET_DATA_REQUEST_TYPE,
25722573
value, priv->channel,
2573-
NULL, 0, WDR_TIMEOUT) < 0) {
2574+
NULL, 0, WDR_TIMEOUT);
2575+
if (ret < 0) {
25742576
dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n",
25752577
__func__, break_state);
2578+
return ret;
25762579
}
25772580

25782581
dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__,
25792582
break_state, value);
25802583

2584+
return 0;
25812585
}
25822586

25832587
static bool ftdi_tx_empty(struct usb_serial_port *port)

drivers/usb/serial/io_edgeport.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,12 +1560,12 @@ static int edge_ioctl(struct tty_struct *tty,
15601560
* SerialBreak
15611561
* this function sends a break to the port
15621562
*****************************************************************************/
1563-
static void edge_break(struct tty_struct *tty, int break_state)
1563+
static int edge_break(struct tty_struct *tty, int break_state)
15641564
{
15651565
struct usb_serial_port *port = tty->driver_data;
15661566
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
15671567
struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial);
1568-
int status;
1568+
int status = 0;
15691569

15701570
if (!edge_serial->is_epic ||
15711571
edge_serial->epic_descriptor.Supports.IOSPChase) {
@@ -1597,6 +1597,8 @@ static void edge_break(struct tty_struct *tty, int break_state)
15971597
dev_dbg(&port->dev, "%s - error sending break set/clear command.\n",
15981598
__func__);
15991599
}
1600+
1601+
return status;
16001602
}
16011603

16021604

drivers/usb/serial/io_ti.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,7 +2421,7 @@ static int edge_tiocmget(struct tty_struct *tty)
24212421
return result;
24222422
}
24232423

2424-
static void edge_break(struct tty_struct *tty, int break_state)
2424+
static int edge_break(struct tty_struct *tty, int break_state)
24252425
{
24262426
struct usb_serial_port *port = tty->driver_data;
24272427
struct edgeport_port *edge_port = usb_get_serial_port_data(port);
@@ -2430,10 +2430,15 @@ static void edge_break(struct tty_struct *tty, int break_state)
24302430

24312431
if (break_state == -1)
24322432
bv = 1; /* On */
2433+
24332434
status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv);
2434-
if (status)
2435+
if (status) {
24352436
dev_dbg(&port->dev, "%s - error %d sending break set/clear command.\n",
24362437
__func__, status);
2438+
return status;
2439+
}
2440+
2441+
return 0;
24372442
}
24382443

24392444
static void edge_heartbeat_schedule(struct edgeport_serial *edge_serial)

0 commit comments

Comments
 (0)