Skip to content

Commit 1d749f9

Browse files
UweBonnesgregkh
authored andcommitted
USB: ftdi_sio.c: Use ftdi async_icount structure for TIOCMIWAIT, as in other drivers
Signed-off-by: Uwe Bonnes <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 005b3cd commit 1d749f9

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

drivers/usb/serial/ftdi_sio.c

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,6 +2328,8 @@ static int ftdi_ioctl(struct tty_struct *tty,
23282328
{
23292329
struct usb_serial_port *port = tty->driver_data;
23302330
struct ftdi_private *priv = usb_get_serial_port_data(port);
2331+
struct async_icount cnow;
2332+
struct async_icount cprev;
23312333

23322334
dbg("%s cmd 0x%04x", __func__, cmd);
23332335

@@ -2347,41 +2349,30 @@ static int ftdi_ioctl(struct tty_struct *tty,
23472349
* - mask passed in arg for lines of interest
23482350
* (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
23492351
* Caller should use TIOCGICOUNT to see which one it was.
2350-
* (except that the driver doesn't support it !)
23512352
*
23522353
* This code is borrowed from linux/drivers/char/serial.c
23532354
*/
23542355
case TIOCMIWAIT:
2355-
while (priv != NULL) {
2356+
cprev = priv->icount;
2357+
while (1) {
23562358
interruptible_sleep_on(&priv->delta_msr_wait);
23572359
/* see if a signal did it */
23582360
if (signal_pending(current))
23592361
return -ERESTARTSYS;
2360-
else {
2361-
char diff = priv->diff_status;
2362-
2363-
if (diff == 0)
2364-
return -EIO; /* no change => error */
2365-
2366-
/* Consume all events */
2367-
priv->diff_status = 0;
2368-
2369-
/* Return 0 if caller wanted to know about
2370-
these bits */
2371-
if (((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) ||
2372-
((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) ||
2373-
((arg & TIOCM_CD) && (diff & FTDI_RS0_RLSD)) ||
2374-
((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS))) {
2375-
return 0;
2376-
}
2377-
/*
2378-
* Otherwise caller can't care less about what
2379-
* happened,and so we continue to wait for more
2380-
* events.
2381-
*/
2362+
cnow = priv->icount;
2363+
if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
2364+
cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
2365+
return -EIO; /* no change => error */
2366+
if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
2367+
((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
2368+
((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
2369+
((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
2370+
return 0;
23822371
}
2372+
cprev = cnow;
23832373
}
2384-
return 0;
2374+
/* not reached */
2375+
break;
23852376
case TIOCSERGETLSR:
23862377
return get_lsr_info(port, (struct serial_struct __user *)arg);
23872378
break;

0 commit comments

Comments
 (0)