From 29727f3bc2e691d59c521ff09b4d59a743b5d9a3 Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Wed, 20 Mar 2013 11:46:10 -0400 Subject: Revert "USB: quatech2: only write to the tty if the port is open." This reverts commit 27b351c5546008c640b3e65152f60ca74b3706f1. Calling tty_flip_buffer_push on an unopened tty is legal, so the driver doesn't need track if port has been opened. Reverting this allows the entire is_open logic to be removed. Signed-off-by: Bill Pemberton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/quatech2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'drivers/usb/serial/quatech2.c') diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index d643a4d4d77..00e6c9bac8a 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -661,9 +661,7 @@ void qt2_process_read_urb(struct urb *urb) __func__); break; } - - if (port_priv->is_open) - tty_flip_buffer_push(&port->port); + tty_flip_buffer_push(&port->port); newport = *(ch + 3); @@ -706,8 +704,7 @@ void qt2_process_read_urb(struct urb *urb) tty_insert_flip_string(&port->port, ch, 1); } - if (port_priv->is_open) - tty_flip_buffer_push(&port->port); + tty_flip_buffer_push(&port->port); } static void qt2_write_bulk_callback(struct urb *urb) -- cgit v1.2.3-70-g09d2 From 0a4142fb9ceddb7e8c48570431038a91bbee7c7c Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 21 Mar 2013 12:37:22 +0100 Subject: USB: quatech2: switch to generic get_icount implementation Switch to the generic get_icount implementation. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/quatech2.c | 51 ++++++++++--------------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) (limited to 'drivers/usb/serial/quatech2.c') diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 80a8bc30a87..3506a2c5e4e 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -128,8 +128,6 @@ struct qt2_port_private { u8 shadowLSR; u8 shadowMSR; - struct async_icount icount; - struct usb_serial_port *port; }; @@ -501,16 +499,16 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) unsigned long flags; spin_lock_irqsave(&priv->lock, flags); - prev = priv->icount; + prev = port->icount; spin_unlock_irqrestore(&priv->lock, flags); while (1) { wait_event_interruptible(port->delta_msr_wait, (port->serial->disconnected || - (priv->icount.rng != prev.rng) || - (priv->icount.dsr != prev.dsr) || - (priv->icount.dcd != prev.dcd) || - (priv->icount.cts != prev.cts))); + (port->icount.rng != prev.rng) || + (port->icount.dsr != prev.dsr) || + (port->icount.dcd != prev.dcd) || + (port->icount.cts != prev.cts))); if (signal_pending(current)) return -ERESTARTSYS; @@ -519,7 +517,7 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) return -EIO; spin_lock_irqsave(&priv->lock, flags); - cur = priv->icount; + cur = port->icount; spin_unlock_irqrestore(&priv->lock, flags); if ((prev.rng == cur.rng) && @@ -537,28 +535,6 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) return 0; } -static int qt2_get_icount(struct tty_struct *tty, - struct serial_icounter_struct *icount) -{ - struct usb_serial_port *port = tty->driver_data; - struct qt2_port_private *priv = usb_get_serial_port_data(port); - struct async_icount cnow = priv->icount; - - icount->cts = cnow.cts; - icount->dsr = cnow.dsr; - icount->rng = cnow.rng; - icount->dcd = cnow.dcd; - icount->rx = cnow.rx; - icount->tx = cnow.tx; - icount->frame = cnow.frame; - icount->overrun = cnow.overrun; - icount->parity = cnow.parity; - icount->brk = cnow.brk; - icount->buf_overrun = cnow.buf_overrun; - - return 0; -} - static int qt2_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { @@ -958,16 +934,13 @@ static void qt2_update_msr(struct usb_serial_port *port, unsigned char *ch) if (newMSR & UART_MSR_ANY_DELTA) { /* update input line counters */ if (newMSR & UART_MSR_DCTS) - port_priv->icount.cts++; - + port->icount.cts++; if (newMSR & UART_MSR_DDSR) - port_priv->icount.dsr++; - + port->icount.dsr++; if (newMSR & UART_MSR_DDCD) - port_priv->icount.dcd++; - + port->icount.dcd++; if (newMSR & UART_MSR_TERI) - port_priv->icount.rng++; + port->icount.rng++; wake_up_interruptible(&port->delta_msr_wait); } @@ -989,7 +962,7 @@ static void qt2_update_lsr(struct usb_serial_port *port, unsigned char *ch) port_priv->shadowLSR = newLSR; spin_unlock_irqrestore(&port_priv->lock, flags); - icount = &port_priv->icount; + icount = &port->icount; if (newLSR & UART_LSR_BRK_ERROR_BITS) { @@ -1099,7 +1072,7 @@ static struct usb_serial_driver qt2_device = { .break_ctl = qt2_break_ctl, .tiocmget = qt2_tiocmget, .tiocmset = qt2_tiocmset, - .get_icount = qt2_get_icount, + .get_icount = usb_serial_generic_get_icount, .ioctl = qt2_ioctl, .set_termios = qt2_set_termios, }; -- cgit v1.2.3-70-g09d2 From b59597047ace8531ce9d469e1de0d85792e8cef1 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 21 Mar 2013 12:37:23 +0100 Subject: USB: quatech2: switch to generic TIOCMIWAIT implementation Switch to the generic TIOCMIWAIT implementation. This also fixes the issue with processes waiting for modem-status-changes not being woken up at disconnect. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/quatech2.c | 50 ++----------------------------------------- 1 file changed, 2 insertions(+), 48 deletions(-) (limited to 'drivers/usb/serial/quatech2.c') diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 3506a2c5e4e..085cad471c4 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -492,49 +492,6 @@ static int get_serial_info(struct usb_serial_port *port, return 0; } -static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) -{ - struct qt2_port_private *priv = usb_get_serial_port_data(port); - struct async_icount prev, cur; - unsigned long flags; - - spin_lock_irqsave(&priv->lock, flags); - prev = port->icount; - spin_unlock_irqrestore(&priv->lock, flags); - - while (1) { - wait_event_interruptible(port->delta_msr_wait, - (port->serial->disconnected || - (port->icount.rng != prev.rng) || - (port->icount.dsr != prev.dsr) || - (port->icount.dcd != prev.dcd) || - (port->icount.cts != prev.cts))); - - if (signal_pending(current)) - return -ERESTARTSYS; - - if (port->serial->disconnected) - return -EIO; - - spin_lock_irqsave(&priv->lock, flags); - cur = port->icount; - spin_unlock_irqrestore(&priv->lock, flags); - - if ((prev.rng == cur.rng) && - (prev.dsr == cur.dsr) && - (prev.dcd == cur.dcd) && - (prev.cts == cur.cts)) - return -EIO; - - if ((arg & TIOCM_RNG && (prev.rng != cur.rng)) || - (arg & TIOCM_DSR && (prev.dsr != cur.dsr)) || - (arg & TIOCM_CD && (prev.dcd != cur.dcd)) || - (arg & TIOCM_CTS && (prev.cts != cur.cts))) - return 0; - } - return 0; -} - static int qt2_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { @@ -544,10 +501,6 @@ static int qt2_ioctl(struct tty_struct *tty, case TIOCGSERIAL: return get_serial_info(port, (struct serial_struct __user *)arg); - - case TIOCMIWAIT: - return wait_modem_info(port, arg); - default: break; } @@ -942,7 +895,7 @@ static void qt2_update_msr(struct usb_serial_port *port, unsigned char *ch) if (newMSR & UART_MSR_TERI) port->icount.rng++; - wake_up_interruptible(&port->delta_msr_wait); + wake_up_interruptible(&port->port.delta_msr_wait); } } @@ -1072,6 +1025,7 @@ static struct usb_serial_driver qt2_device = { .break_ctl = qt2_break_ctl, .tiocmget = qt2_tiocmget, .tiocmset = qt2_tiocmset, + .tiocmiwait = usb_serial_generic_tiocmiwait, .get_icount = usb_serial_generic_get_icount, .ioctl = qt2_ioctl, .set_termios = qt2_set_termios, -- cgit v1.2.3-70-g09d2 From 81ae1b3c31a91358950011fee16698226a1bda45 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 21 Mar 2013 12:37:46 +0100 Subject: USB: quatech2: always disable uart on close Always try to disable the uart on close. Since the switch to tty ports, close will be called as part of shutdown before disconnect returns. Hence there is no need to check the disconnected flag, and we can put devices in disabled states also on driver unbind. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/quatech2.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/usb/serial/quatech2.c') diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index 085cad471c4..3c278521f7e 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c @@ -422,12 +422,6 @@ static void qt2_close(struct usb_serial_port *port) port_priv->urb_in_use = false; spin_unlock_irqrestore(&port_priv->urb_lock, flags); - mutex_lock(&port->serial->disc_mutex); - if (port->serial->disconnected) { - mutex_unlock(&port->serial->disc_mutex); - return; - } - /* flush the port transmit buffer */ i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), @@ -458,8 +452,6 @@ static void qt2_close(struct usb_serial_port *port) if (i < 0) dev_err(&port->dev, "%s - close port failed %i\n", __func__, i); - - mutex_unlock(&port->serial->disc_mutex); } static void qt2_disconnect(struct usb_serial *serial) -- cgit v1.2.3-70-g09d2