Switch to the generic TIOCMIWAIT implementation which does not suffer
from the races involved when using the deprecated sleep_on functions.

Signed-off-by: Johan Hovold <jhov...@gmail.com>
---
 drivers/usb/serial/io_ti.c | 38 ++++----------------------------------
 1 file changed, 4 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index db12f02..31897ba 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -86,9 +86,7 @@ struct edgeport_port {
        int baud_rate;
        int close_pending;
        int lsr_event;
-       wait_queue_head_t       delta_msr_wait; /* for handling sleeping while
-                                                  waiting for msr change to
-                                                  happen */
+
        struct edgeport_serial  *edge_serial;
        struct usb_serial_port  *port;
        __u8 bUartMode;         /* Port type, 0: RS232, etc. */
@@ -1458,7 +1456,7 @@ static void handle_new_msr(struct edgeport_port 
*edge_port, __u8 msr)
                        icount->dcd++;
                if (msr & EDGEPORT_MSR_DELTA_RI)
                        icount->rng++;
-               wake_up_interruptible(&edge_port->delta_msr_wait);
+               wake_up_interruptible(&edge_port->port->delta_msr_wait);
        }
 
        /* Save the new modem status */
@@ -1752,8 +1750,6 @@ static int edge_open(struct tty_struct *tty, struct 
usb_serial_port *port)
 
        dev = port->serial->dev;
 
-       init_waitqueue_head(&edge_port->delta_msr_wait);
-
        /* turn off loopback */
        status = ti_do_config(edge_port, UMPC_SET_CLR_LOOPBACK, 0);
        if (status) {
@@ -2397,8 +2393,6 @@ static int edge_ioctl(struct tty_struct *tty,
 {
        struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct async_icount cnow;
-       struct async_icount cprev;
 
        dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, 
port->number, cmd);
 
@@ -2407,30 +2401,6 @@ static int edge_ioctl(struct tty_struct *tty,
                dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__);
                return get_serial_info(edge_port,
                                (struct serial_struct __user *) arg);
-       case TIOCMIWAIT:
-               dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__);
-               cprev = edge_port->port->icount;
-               while (1) {
-                       interruptible_sleep_on(&edge_port->delta_msr_wait);
-                       /* see if a signal did it */
-                       if (signal_pending(current))
-                               return -ERESTARTSYS;
-
-                       if (port->serial->disconnected)
-                               return -EIO;
-
-                       cnow = edge_port->port->icount;
-
-                       if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
-                           ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
-                           ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
-                           ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
-                               return 0;
-                       }
-                       cprev = cnow;
-               }
-               /* not reached */
-               break;
        }
        return -ENOIOCTLCMD;
 }
@@ -2526,8 +2496,6 @@ static int edge_port_remove(struct usb_serial_port *port)
 
        edge_port = usb_get_serial_port_data(port);
 
-       wake_up_interruptible(&edge_port->delta_msr_wait);
-
        edge_remove_sysfs_attrs(port);
        kfifo_free(&edge_port->write_fifo);
        kfree(edge_port);
@@ -2599,6 +2567,7 @@ static struct usb_serial_driver edgeport_1port_device = {
        .set_termios            = edge_set_termios,
        .tiocmget               = edge_tiocmget,
        .tiocmset               = edge_tiocmset,
+       .tiocmiwait             = usb_serial_generic_tiocmiwait,
        .get_icount             = usb_serial_generic_get_icount,
        .write                  = edge_write,
        .write_room             = edge_write_room,
@@ -2630,6 +2599,7 @@ static struct usb_serial_driver edgeport_2port_device = {
        .set_termios            = edge_set_termios,
        .tiocmget               = edge_tiocmget,
        .tiocmset               = edge_tiocmset,
+       .tiocmiwait             = usb_serial_generic_tiocmiwait,
        .get_icount             = usb_serial_generic_get_icount,
        .write                  = edge_write,
        .write_room             = edge_write_room,
-- 
1.8.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to