Skip to content

Commit d432df7

Browse files
committed
USB: serial: kobil_sct: fix TIOCMBIS and TIOCMBIC
Asserting or deasserting a modem control line using TIOCMBIS or TIOCMBIC should not deassert any lines that are not in the mask. Fix this long-standing issue dating back to 2003 when the support for these ioctls was added with the introduction of the tiocmset() callback. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Johan Hovold <johan@kernel.org>
1 parent b6e0b30 commit d432df7

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

drivers/usb/serial/kobil_sct.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static int kobil_tiocmset(struct tty_struct *tty,
418418
struct usb_serial_port *port = tty->driver_data;
419419
struct device *dev = &port->dev;
420420
struct kobil_private *priv;
421-
int result;
421+
int result = 0;
422422
int dtr = 0;
423423
int rts = 0;
424424

@@ -435,34 +435,34 @@ static int kobil_tiocmset(struct tty_struct *tty,
435435
if (set & TIOCM_DTR)
436436
dtr = 1;
437437
if (clear & TIOCM_RTS)
438-
rts = 0;
438+
rts = 1;
439439
if (clear & TIOCM_DTR)
440-
dtr = 0;
440+
dtr = 1;
441441

442-
if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
443-
if (dtr != 0)
442+
if (dtr && priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
443+
if (set & TIOCM_DTR)
444444
dev_dbg(dev, "%s - Setting DTR\n", __func__);
445445
else
446446
dev_dbg(dev, "%s - Clearing DTR\n", __func__);
447447
result = usb_control_msg(port->serial->dev,
448448
usb_sndctrlpipe(port->serial->dev, 0),
449449
SUSBCRequest_SetStatusLinesOrQueues,
450450
USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
451-
((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
451+
((set & TIOCM_DTR) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
452452
0,
453453
NULL,
454454
0,
455455
KOBIL_TIMEOUT);
456-
} else {
457-
if (rts != 0)
456+
} else if (rts) {
457+
if (set & TIOCM_RTS)
458458
dev_dbg(dev, "%s - Setting RTS\n", __func__);
459459
else
460460
dev_dbg(dev, "%s - Clearing RTS\n", __func__);
461461
result = usb_control_msg(port->serial->dev,
462462
usb_sndctrlpipe(port->serial->dev, 0),
463463
SUSBCRequest_SetStatusLinesOrQueues,
464464
USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
465-
((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
465+
((set & TIOCM_RTS) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
466466
0,
467467
NULL,
468468
0,

0 commit comments

Comments
 (0)