]> err.no Git - linux-2.6/blobdiff - drivers/usb/serial/ti_usb_3410_5052.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
[linux-2.6] / drivers / usb / serial / ti_usb_3410_5052.c
index 995fdf3c489820f7ef635ad7f1dad9591c3d8237..e3d241f67afc39996d95d4d2ac76c290e4cc9c29 100644 (file)
@@ -265,8 +265,8 @@ static struct usb_serial_driver ti_1port_device = {
        .description            = "TI USB 3410 1 port adapter",
        .usb_driver             = &ti_usb_driver,
        .id_table               = ti_id_table_3410,
-       .num_interrupt_in       = 1,
-       .num_bulk_in            = 1,
+       .num_interrupt_in       = NUM_DONT_CARE,
+       .num_bulk_in            = NUM_DONT_CARE,
        .num_bulk_out           = 1,
        .num_ports              = 1,
        .attach                 = ti_startup,
@@ -581,7 +581,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
                }
        }
 
-       ti_set_termios(port, NULL);
+       ti_set_termios(port, port->tty->termios);
 
        dbg("%s - sending TI_OPEN_PORT", __FUNCTION__);
        status = ti_command_out_sync(tdev, TI_OPEN_PORT,
@@ -618,7 +618,7 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        usb_clear_halt(dev, port->write_urb->pipe);
        usb_clear_halt(dev, port->read_urb->pipe);
 
-       ti_set_termios(port, NULL);
+       ti_set_termios(port, port->tty->termios);
 
        dbg("%s - sending TI_OPEN_PORT (2)", __FUNCTION__);
        status = ti_command_out_sync(tdev, TI_OPEN_PORT,
@@ -897,24 +897,11 @@ static void ti_set_termios(struct usb_serial_port *port,
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
-       if (!tty || !tty->termios) {
-               dbg("%s - no tty or termios", __FUNCTION__);
-               return;
-       }
-
        cflag = tty->termios->c_cflag;
        iflag = tty->termios->c_iflag;
 
-       if (old_termios && cflag == old_termios->c_cflag
-       && iflag == old_termios->c_iflag) {
-               dbg("%s - nothing to change", __FUNCTION__);
-               return;
-       }
-
-       dbg("%s - clfag %08x, iflag %08x", __FUNCTION__, cflag, iflag);
-
-       if (old_termios)
-               dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag);
+       dbg("%s - cflag %08x, iflag %08x", __FUNCTION__, cflag, iflag);
+       dbg("%s - old clfag %08x, old iflag %08x", __FUNCTION__, old_termios->c_cflag, old_termios->c_iflag);
 
        if (tport == NULL)
                return;
@@ -948,6 +935,9 @@ static void ti_set_termios(struct usb_serial_port *port,
                            break;
        }
 
+       /* CMSPAR isn't supported by this driver */
+       tty->termios->c_cflag &= ~CMSPAR;
+
        if (cflag & PARENB) {
                if (cflag & PARODD) {
                        config->wFlags |= TI_UART_ENABLE_PARITY_CHECKING;
@@ -990,12 +980,17 @@ static void ti_set_termios(struct usb_serial_port *port,
        }
 
        baud = tty_get_baud_rate(tty);
-       if (!baud) baud = 9600;
+       if (!baud)
+               baud = 9600;
        if (tport->tp_tdev->td_is_3410)
                config->wBaudRate = (__u16)((923077 + baud/2) / baud);
        else
                config->wBaudRate = (__u16)((461538 + baud/2) / baud);
 
+       /* FIXME: Should calculate resulting baud here and report it back */
+       if ((cflag & CBAUD) != B0)
+               tty_encode_baud_rate(tty, baud, baud);
+
        dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d",
        __FUNCTION__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode);
 
@@ -1498,11 +1493,10 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush)
        struct ti_device *tdev = tport->tp_tdev;
        struct usb_serial_port *port = tport->tp_port;
        wait_queue_t wait;
-       unsigned long flags;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
 
-       spin_lock_irqsave(&tport->tp_lock, flags);
+       spin_lock_irq(&tport->tp_lock);
 
        /* wait for data to drain from the buffer */
        tdev->td_urb_error = 0;
@@ -1513,11 +1507,11 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush)
                if (ti_buf_data_avail(tport->tp_write_buf) == 0
                || timeout == 0 || signal_pending(current)
                || tdev->td_urb_error
-               || !usb_get_intfdata(port->serial->interface))  /* disconnect */
+               || port->serial->disconnected)  /* disconnect */
                        break;
-               spin_unlock_irqrestore(&tport->tp_lock, flags);
+               spin_unlock_irq(&tport->tp_lock);
                timeout = schedule_timeout(timeout);
-               spin_lock_irqsave(&tport->tp_lock, flags);
+               spin_lock_irq(&tport->tp_lock);
        }
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&tport->tp_write_wait, &wait);
@@ -1526,19 +1520,23 @@ static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush)
        if (flush)
                ti_buf_clear(tport->tp_write_buf);
 
-       spin_unlock_irqrestore(&tport->tp_lock, flags);
+       spin_unlock_irq(&tport->tp_lock);
 
+       mutex_lock(&port->serial->disc_mutex);
        /* wait for data to drain from the device */
        /* wait for empty tx register, plus 20 ms */
        timeout += jiffies;
        tport->tp_lsr &= ~TI_LSR_TX_EMPTY;
        while ((long)(jiffies - timeout) < 0 && !signal_pending(current)
        && !(tport->tp_lsr&TI_LSR_TX_EMPTY) && !tdev->td_urb_error
-       && usb_get_intfdata(port->serial->interface)) {  /* not disconnected */
+       && !port->serial->disconnected) {
                if (ti_get_lsr(tport))
                        break;
+               mutex_unlock(&port->serial->disc_mutex);
                msleep_interruptible(20);
+               mutex_lock(&port->serial->disc_mutex);
        }
+       mutex_unlock(&port->serial->disc_mutex);
 }