aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-04-18 11:33:23 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-19 13:24:14 -0400
commitf1175daa5312dd1b3f5940413c7c41ed195066f7 (patch)
treedf0dc419e1f6ab31168000d34d9d4711a6e88ee1
parentc0419024332a73f299bdd7a6875a00cf3942a054 (diff)
USB: ti_usb_3410_5052: kill custom closing_wait
Kill custom closing_wait implementation and let the tty-layer handle it instead. Note that the port drain-delay is set to three characters to keep the 20ms delay after wait_until_sent at low baudrates (1200 baud) during close. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c69
1 files changed, 15 insertions, 54 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 6a40823e85c4..4b52132812c1 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -71,7 +71,6 @@ struct ti_port {
71 __u8 tp_uart_mode; /* 232 or 485 modes */ 71 __u8 tp_uart_mode; /* 232 or 485 modes */
72 unsigned int tp_uart_base_addr; 72 unsigned int tp_uart_base_addr;
73 int tp_flags; 73 int tp_flags;
74 int tp_closing_wait;/* in .01 secs */
75 wait_queue_head_t tp_write_wait; 74 wait_queue_head_t tp_write_wait;
76 struct ti_device *tp_tdev; 75 struct ti_device *tp_tdev;
77 struct usb_serial_port *tp_port; 76 struct usb_serial_port *tp_port;
@@ -127,8 +126,6 @@ static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
127 struct serial_struct __user *new_arg); 126 struct serial_struct __user *new_arg);
128static void ti_handle_new_msr(struct ti_port *tport, __u8 msr); 127static void ti_handle_new_msr(struct ti_port *tport, __u8 msr);
129 128
130static void ti_drain(struct ti_port *tport, unsigned long timeout);
131
132static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty); 129static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty);
133static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty); 130static int ti_restart_read(struct ti_port *tport, struct tty_struct *tty);
134 131
@@ -428,7 +425,7 @@ static int ti_port_probe(struct usb_serial_port *port)
428 tport->tp_uart_base_addr = TI_UART1_BASE_ADDR; 425 tport->tp_uart_base_addr = TI_UART1_BASE_ADDR;
429 else 426 else
430 tport->tp_uart_base_addr = TI_UART2_BASE_ADDR; 427 tport->tp_uart_base_addr = TI_UART2_BASE_ADDR;
431 tport->tp_closing_wait = closing_wait; 428 port->port.closing_wait = msecs_to_jiffies(10 * closing_wait);
432 init_waitqueue_head(&tport->tp_write_wait); 429 init_waitqueue_head(&tport->tp_write_wait);
433 if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) { 430 if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) {
434 kfree(tport); 431 kfree(tport);
@@ -581,6 +578,8 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
581 tport->tp_is_open = 1; 578 tport->tp_is_open = 1;
582 ++tdev->td_open_port_count; 579 ++tdev->td_open_port_count;
583 580
581 port->port.drain_delay = 3;
582
584 goto release_lock; 583 goto release_lock;
585 584
586unlink_int_urb: 585unlink_int_urb:
@@ -609,8 +608,6 @@ static void ti_close(struct usb_serial_port *port)
609 608
610 tport->tp_is_open = 0; 609 tport->tp_is_open = 0;
611 610
612 ti_drain(tport, (tport->tp_closing_wait*HZ)/100);
613
614 usb_kill_urb(port->read_urb); 611 usb_kill_urb(port->read_urb);
615 usb_kill_urb(port->write_urb); 612 usb_kill_urb(port->write_urb);
616 tport->tp_write_urb_in_use = 0; 613 tport->tp_write_urb_in_use = 0;
@@ -1295,10 +1292,15 @@ static int ti_get_serial_info(struct ti_port *tport,
1295{ 1292{
1296 struct usb_serial_port *port = tport->tp_port; 1293 struct usb_serial_port *port = tport->tp_port;
1297 struct serial_struct ret_serial; 1294 struct serial_struct ret_serial;
1295 unsigned cwait;
1298 1296
1299 if (!ret_arg) 1297 if (!ret_arg)
1300 return -EFAULT; 1298 return -EFAULT;
1301 1299
1300 cwait = port->port.closing_wait;
1301 if (cwait != ASYNC_CLOSING_WAIT_NONE)
1302 cwait = jiffies_to_msecs(cwait) / 10;
1303
1302 memset(&ret_serial, 0, sizeof(ret_serial)); 1304 memset(&ret_serial, 0, sizeof(ret_serial));
1303 1305
1304 ret_serial.type = PORT_16550A; 1306 ret_serial.type = PORT_16550A;
@@ -1307,7 +1309,7 @@ static int ti_get_serial_info(struct ti_port *tport,
1307 ret_serial.flags = tport->tp_flags; 1309 ret_serial.flags = tport->tp_flags;
1308 ret_serial.xmit_fifo_size = TI_WRITE_BUF_SIZE; 1310 ret_serial.xmit_fifo_size = TI_WRITE_BUF_SIZE;
1309 ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; 1311 ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800;
1310 ret_serial.closing_wait = tport->tp_closing_wait; 1312 ret_serial.closing_wait = cwait;
1311 1313
1312 if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg))) 1314 if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg)))
1313 return -EFAULT; 1315 return -EFAULT;
@@ -1320,12 +1322,17 @@ static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
1320 struct serial_struct __user *new_arg) 1322 struct serial_struct __user *new_arg)
1321{ 1323{
1322 struct serial_struct new_serial; 1324 struct serial_struct new_serial;
1325 unsigned cwait;
1323 1326
1324 if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) 1327 if (copy_from_user(&new_serial, new_arg, sizeof(new_serial)))
1325 return -EFAULT; 1328 return -EFAULT;
1326 1329
1330 cwait = new_serial.closing_wait;
1331 if (cwait != ASYNC_CLOSING_WAIT_NONE)
1332 cwait = msecs_to_jiffies(10 * new_serial.closing_wait);
1333
1327 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS; 1334 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS;
1328 tport->tp_closing_wait = new_serial.closing_wait; 1335 tport->tp_port->port.closing_wait = cwait;
1329 1336
1330 return 0; 1337 return 0;
1331} 1338}
@@ -1370,52 +1377,6 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1370} 1377}
1371 1378
1372 1379
1373static void ti_drain(struct ti_port *tport, unsigned long timeout)
1374{
1375 struct ti_device *tdev = tport->tp_tdev;
1376 struct usb_serial_port *port = tport->tp_port;
1377 wait_queue_t wait;
1378 u8 lsr;
1379
1380 spin_lock_irq(&tport->tp_lock);
1381
1382 /* wait for data to drain from the buffer */
1383 tdev->td_urb_error = 0;
1384 init_waitqueue_entry(&wait, current);
1385 add_wait_queue(&tport->tp_write_wait, &wait);
1386 for (;;) {
1387 set_current_state(TASK_INTERRUPTIBLE);
1388 if (kfifo_len(&tport->write_fifo) == 0
1389 || timeout == 0 || signal_pending(current)
1390 || tdev->td_urb_error
1391 || port->serial->disconnected) /* disconnect */
1392 break;
1393 spin_unlock_irq(&tport->tp_lock);
1394 timeout = schedule_timeout(timeout);
1395 spin_lock_irq(&tport->tp_lock);
1396 }
1397 set_current_state(TASK_RUNNING);
1398 remove_wait_queue(&tport->tp_write_wait, &wait);
1399 spin_unlock_irq(&tport->tp_lock);
1400
1401 mutex_lock(&port->serial->disc_mutex);
1402 /* wait for data to drain from the device */
1403 /* wait for empty tx register, plus 20 ms */
1404 timeout += jiffies;
1405 lsr = 0;
1406 while ((long)(jiffies - timeout) < 0 && !signal_pending(current)
1407 && !(lsr & TI_LSR_TX_EMPTY) && !tdev->td_urb_error
1408 && !port->serial->disconnected) {
1409 if (ti_get_lsr(tport, &lsr))
1410 break;
1411 mutex_unlock(&port->serial->disc_mutex);
1412 msleep_interruptible(20);
1413 mutex_lock(&port->serial->disc_mutex);
1414 }
1415 mutex_unlock(&port->serial->disc_mutex);
1416}
1417
1418
1419static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty) 1380static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty)
1420{ 1381{
1421 unsigned long flags; 1382 unsigned long flags;