aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ti_usb_3410_5052.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 15:19:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 15:19:23 -0400
commitec25e246b94a3233ab064994ef05a170bdba0e7c (patch)
tree49b7d7e4c46e13bb465c7b832961596e41e8526a /drivers/usb/serial/ti_usb_3410_5052.c
parent507ffe4f3840ac24890a8123c702cf1b7fe4d33c (diff)
parent4626b8daf9bb00ce6b4d533c1a155211ad880f32 (diff)
Merge tag 'usb-3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB patches from Greg Kroah-Hartman: "Here's the big USB pull request for 3.10-rc1. Lots of USB patches here, the majority being USB gadget changes and USB-serial driver cleanups, the rest being ARM build fixes / cleanups, and individual driver updates. We also finally got some chipidea fixes, which have been delayed for a number of kernel releases, as the maintainer has now reappeared. All of these have been in linux-next for a while" * tag 'usb-3.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (568 commits) USB: ehci-msm: USB_MSM_OTG needs USB_PHY USB: OHCI: avoid conflicting platform drivers USB: OMAP: ISP1301 needs USB_PHY USB: lpc32xx: ISP1301 needs USB_PHY USB: ftdi_sio: enable two UART ports on ST Microconnect Lite usb: phy: tegra: don't call into tegra-ehci directly usb: phy: phy core cannot yet be a module USB: Fix initconst in ehci driver usb-storage: CY7C68300A chips do not support Cypress ATACB USB: serial: option: Added support Olivetti Olicard 145 USB: ftdi_sio: correct ST Micro Connect Lite PIDs ARM: mxs_defconfig: add CONFIG_USB_PHY ARM: imx_v6_v7_defconfig: add CONFIG_USB_PHY usb: phy: remove exported function from __init section usb: gadget: zero: put function instances on unbind usb: gadget: f_sourcesink.c: correct a copy-paste misnomer usb: gadget: cdc2: fix error return code in cdc_do_config() usb: gadget: multi: fix error return code in rndis_do_config() usb: gadget: f_obex: fix error return code in obex_bind() USB: storage: convert to use module_usb_driver() ...
Diffstat (limited to 'drivers/usb/serial/ti_usb_3410_5052.c')
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c163
1 files changed, 38 insertions, 125 deletions
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 19a71a9eecf0..cac47aef2918 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -67,13 +67,10 @@
67struct ti_port { 67struct ti_port {
68 int tp_is_open; 68 int tp_is_open;
69 __u8 tp_msr; 69 __u8 tp_msr;
70 __u8 tp_lsr;
71 __u8 tp_shadow_mcr; 70 __u8 tp_shadow_mcr;
72 __u8 tp_uart_mode; /* 232 or 485 modes */ 71 __u8 tp_uart_mode; /* 232 or 485 modes */
73 unsigned int tp_uart_base_addr; 72 unsigned int tp_uart_base_addr;
74 int tp_flags; 73 int tp_flags;
75 int tp_closing_wait;/* in .01 secs */
76 struct async_icount tp_icount;
77 wait_queue_head_t tp_write_wait; 74 wait_queue_head_t tp_write_wait;
78 struct ti_device *tp_tdev; 75 struct ti_device *tp_tdev;
79 struct usb_serial_port *tp_port; 76 struct usb_serial_port *tp_port;
@@ -108,8 +105,6 @@ static void ti_throttle(struct tty_struct *tty);
108static void ti_unthrottle(struct tty_struct *tty); 105static void ti_unthrottle(struct tty_struct *tty);
109static int ti_ioctl(struct tty_struct *tty, 106static int ti_ioctl(struct tty_struct *tty,
110 unsigned int cmd, unsigned long arg); 107 unsigned int cmd, unsigned long arg);
111static int ti_get_icount(struct tty_struct *tty,
112 struct serial_icounter_struct *icount);
113static void ti_set_termios(struct tty_struct *tty, 108static void ti_set_termios(struct tty_struct *tty,
114 struct usb_serial_port *port, struct ktermios *old_termios); 109 struct usb_serial_port *port, struct ktermios *old_termios);
115static int ti_tiocmget(struct tty_struct *tty); 110static int ti_tiocmget(struct tty_struct *tty);
@@ -124,15 +119,13 @@ static void ti_recv(struct usb_serial_port *port, unsigned char *data,
124 int length); 119 int length);
125static void ti_send(struct ti_port *tport); 120static void ti_send(struct ti_port *tport);
126static int ti_set_mcr(struct ti_port *tport, unsigned int mcr); 121static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
127static int ti_get_lsr(struct ti_port *tport); 122static int ti_get_lsr(struct ti_port *tport, u8 *lsr);
128static int ti_get_serial_info(struct ti_port *tport, 123static int ti_get_serial_info(struct ti_port *tport,
129 struct serial_struct __user *ret_arg); 124 struct serial_struct __user *ret_arg);
130static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport, 125static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
131 struct serial_struct __user *new_arg); 126 struct serial_struct __user *new_arg);
132static void ti_handle_new_msr(struct ti_port *tport, __u8 msr); 127static void ti_handle_new_msr(struct ti_port *tport, __u8 msr);
133 128
134static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush);
135
136static 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);
137static 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);
138 131
@@ -235,7 +228,8 @@ static struct usb_serial_driver ti_1port_device = {
235 .set_termios = ti_set_termios, 228 .set_termios = ti_set_termios,
236 .tiocmget = ti_tiocmget, 229 .tiocmget = ti_tiocmget,
237 .tiocmset = ti_tiocmset, 230 .tiocmset = ti_tiocmset,
238 .get_icount = ti_get_icount, 231 .tiocmiwait = usb_serial_generic_tiocmiwait,
232 .get_icount = usb_serial_generic_get_icount,
239 .break_ctl = ti_break, 233 .break_ctl = ti_break,
240 .read_int_callback = ti_interrupt_callback, 234 .read_int_callback = ti_interrupt_callback,
241 .read_bulk_callback = ti_bulk_in_callback, 235 .read_bulk_callback = ti_bulk_in_callback,
@@ -265,7 +259,8 @@ static struct usb_serial_driver ti_2port_device = {
265 .set_termios = ti_set_termios, 259 .set_termios = ti_set_termios,
266 .tiocmget = ti_tiocmget, 260 .tiocmget = ti_tiocmget,
267 .tiocmset = ti_tiocmset, 261 .tiocmset = ti_tiocmset,
268 .get_icount = ti_get_icount, 262 .tiocmiwait = usb_serial_generic_tiocmiwait,
263 .get_icount = usb_serial_generic_get_icount,
269 .break_ctl = ti_break, 264 .break_ctl = ti_break,
270 .read_int_callback = ti_interrupt_callback, 265 .read_int_callback = ti_interrupt_callback,
271 .read_bulk_callback = ti_bulk_in_callback, 266 .read_bulk_callback = ti_bulk_in_callback,
@@ -430,7 +425,7 @@ static int ti_port_probe(struct usb_serial_port *port)
430 tport->tp_uart_base_addr = TI_UART1_BASE_ADDR; 425 tport->tp_uart_base_addr = TI_UART1_BASE_ADDR;
431 else 426 else
432 tport->tp_uart_base_addr = TI_UART2_BASE_ADDR; 427 tport->tp_uart_base_addr = TI_UART2_BASE_ADDR;
433 tport->tp_closing_wait = closing_wait; 428 port->port.closing_wait = msecs_to_jiffies(10 * closing_wait);
434 init_waitqueue_head(&tport->tp_write_wait); 429 init_waitqueue_head(&tport->tp_write_wait);
435 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)) {
436 kfree(tport); 431 kfree(tport);
@@ -480,8 +475,6 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
480 475
481 port_number = port->number - port->serial->minor; 476 port_number = port->number - port->serial->minor;
482 477
483 memset(&(tport->tp_icount), 0x00, sizeof(tport->tp_icount));
484
485 tport->tp_msr = 0; 478 tport->tp_msr = 0;
486 tport->tp_shadow_mcr |= (TI_MCR_RTS | TI_MCR_DTR); 479 tport->tp_shadow_mcr |= (TI_MCR_RTS | TI_MCR_DTR);
487 480
@@ -585,6 +578,8 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
585 tport->tp_is_open = 1; 578 tport->tp_is_open = 1;
586 ++tdev->td_open_port_count; 579 ++tdev->td_open_port_count;
587 580
581 port->port.drain_delay = 3;
582
588 goto release_lock; 583 goto release_lock;
589 584
590unlink_int_urb: 585unlink_int_urb:
@@ -604,6 +599,7 @@ static void ti_close(struct usb_serial_port *port)
604 int port_number; 599 int port_number;
605 int status; 600 int status;
606 int do_unlock; 601 int do_unlock;
602 unsigned long flags;
607 603
608 tdev = usb_get_serial_data(port->serial); 604 tdev = usb_get_serial_data(port->serial);
609 tport = usb_get_serial_port_data(port); 605 tport = usb_get_serial_port_data(port);
@@ -612,11 +608,12 @@ static void ti_close(struct usb_serial_port *port)
612 608
613 tport->tp_is_open = 0; 609 tport->tp_is_open = 0;
614 610
615 ti_drain(tport, (tport->tp_closing_wait*HZ)/100, 1);
616
617 usb_kill_urb(port->read_urb); 611 usb_kill_urb(port->read_urb);
618 usb_kill_urb(port->write_urb); 612 usb_kill_urb(port->write_urb);
619 tport->tp_write_urb_in_use = 0; 613 tport->tp_write_urb_in_use = 0;
614 spin_lock_irqsave(&tport->tp_lock, flags);
615 kfifo_reset_out(&tport->write_fifo);
616 spin_unlock_irqrestore(&tport->tp_lock, flags);
620 617
621 port_number = port->number - port->serial->minor; 618 port_number = port->number - port->serial->minor;
622 619
@@ -687,6 +684,8 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
687 struct ti_port *tport = usb_get_serial_port_data(port); 684 struct ti_port *tport = usb_get_serial_port_data(port);
688 int chars = 0; 685 int chars = 0;
689 unsigned long flags; 686 unsigned long flags;
687 int ret;
688 u8 lsr;
690 689
691 if (tport == NULL) 690 if (tport == NULL)
692 return 0; 691 return 0;
@@ -695,6 +694,12 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
695 chars = kfifo_len(&tport->write_fifo); 694 chars = kfifo_len(&tport->write_fifo);
696 spin_unlock_irqrestore(&tport->tp_lock, flags); 695 spin_unlock_irqrestore(&tport->tp_lock, flags);
697 696
697 if (!chars) {
698 ret = ti_get_lsr(tport, &lsr);
699 if (!ret && !(lsr & TI_LSR_TX_EMPTY))
700 chars = 1;
701 }
702
698 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); 703 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
699 return chars; 704 return chars;
700} 705}
@@ -731,38 +736,11 @@ static void ti_unthrottle(struct tty_struct *tty)
731 } 736 }
732} 737}
733 738
734static int ti_get_icount(struct tty_struct *tty,
735 struct serial_icounter_struct *icount)
736{
737 struct usb_serial_port *port = tty->driver_data;
738 struct ti_port *tport = usb_get_serial_port_data(port);
739 struct async_icount cnow = tport->tp_icount;
740
741 dev_dbg(&port->dev, "%s - TIOCGICOUNT RX=%d, TX=%d\n", __func__,
742 cnow.rx, cnow.tx);
743
744 icount->cts = cnow.cts;
745 icount->dsr = cnow.dsr;
746 icount->rng = cnow.rng;
747 icount->dcd = cnow.dcd;
748 icount->rx = cnow.rx;
749 icount->tx = cnow.tx;
750 icount->frame = cnow.frame;
751 icount->overrun = cnow.overrun;
752 icount->parity = cnow.parity;
753 icount->brk = cnow.brk;
754 icount->buf_overrun = cnow.buf_overrun;
755
756 return 0;
757}
758
759static int ti_ioctl(struct tty_struct *tty, 739static int ti_ioctl(struct tty_struct *tty,
760 unsigned int cmd, unsigned long arg) 740 unsigned int cmd, unsigned long arg)
761{ 741{
762 struct usb_serial_port *port = tty->driver_data; 742 struct usb_serial_port *port = tty->driver_data;
763 struct ti_port *tport = usb_get_serial_port_data(port); 743 struct ti_port *tport = usb_get_serial_port_data(port);
764 struct async_icount cnow;
765 struct async_icount cprev;
766 744
767 dev_dbg(&port->dev, "%s - cmd = 0x%04X\n", __func__, cmd); 745 dev_dbg(&port->dev, "%s - cmd = 0x%04X\n", __func__, cmd);
768 746
@@ -778,29 +756,6 @@ static int ti_ioctl(struct tty_struct *tty,
778 dev_dbg(&port->dev, "%s - TIOCSSERIAL\n", __func__); 756 dev_dbg(&port->dev, "%s - TIOCSSERIAL\n", __func__);
779 return ti_set_serial_info(tty, tport, 757 return ti_set_serial_info(tty, tport,
780 (struct serial_struct __user *)arg); 758 (struct serial_struct __user *)arg);
781 case TIOCMIWAIT:
782 dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__);
783 cprev = tport->tp_icount;
784 while (1) {
785 interruptible_sleep_on(&port->delta_msr_wait);
786 if (signal_pending(current))
787 return -ERESTARTSYS;
788
789 if (port->serial->disconnected)
790 return -EIO;
791
792 cnow = tport->tp_icount;
793 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
794 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
795 return -EIO; /* no change => error */
796 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
797 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
798 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
799 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)))
800 return 0;
801 cprev = cnow;
802 }
803 break;
804 } 759 }
805 return -ENOIOCTLCMD; 760 return -ENOIOCTLCMD;
806} 761}
@@ -1018,8 +973,6 @@ static void ti_break(struct tty_struct *tty, int break_state)
1018 if (tport == NULL) 973 if (tport == NULL)
1019 return; 974 return;
1020 975
1021 ti_drain(tport, (tport->tp_closing_wait*HZ)/100, 0);
1022
1023 status = ti_write_byte(port, tport->tp_tdev, 976 status = ti_write_byte(port, tport->tp_tdev,
1024 tport->tp_uart_base_addr + TI_UART_OFFSET_LCR, 977 tport->tp_uart_base_addr + TI_UART_OFFSET_LCR,
1025 TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0); 978 TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0);
@@ -1156,7 +1109,7 @@ static void ti_bulk_in_callback(struct urb *urb)
1156 else 1109 else
1157 ti_recv(port, urb->transfer_buffer, urb->actual_length); 1110 ti_recv(port, urb->transfer_buffer, urb->actual_length);
1158 spin_lock(&tport->tp_lock); 1111 spin_lock(&tport->tp_lock);
1159 tport->tp_icount.rx += urb->actual_length; 1112 port->icount.rx += urb->actual_length;
1160 spin_unlock(&tport->tp_lock); 1113 spin_unlock(&tport->tp_lock);
1161 } 1114 }
1162 1115
@@ -1264,7 +1217,7 @@ static void ti_send(struct ti_port *tport)
1264 /* TODO: reschedule ti_send */ 1217 /* TODO: reschedule ti_send */
1265 } else { 1218 } else {
1266 spin_lock_irqsave(&tport->tp_lock, flags); 1219 spin_lock_irqsave(&tport->tp_lock, flags);
1267 tport->tp_icount.tx += count; 1220 port->icount.tx += count;
1268 spin_unlock_irqrestore(&tport->tp_lock, flags); 1221 spin_unlock_irqrestore(&tport->tp_lock, flags);
1269 } 1222 }
1270 1223
@@ -1297,7 +1250,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
1297} 1250}
1298 1251
1299 1252
1300static int ti_get_lsr(struct ti_port *tport) 1253static int ti_get_lsr(struct ti_port *tport, u8 *lsr)
1301{ 1254{
1302 int size, status; 1255 int size, status;
1303 struct ti_device *tdev = tport->tp_tdev; 1256 struct ti_device *tdev = tport->tp_tdev;
@@ -1323,7 +1276,7 @@ static int ti_get_lsr(struct ti_port *tport)
1323 1276
1324 dev_dbg(&port->dev, "%s - lsr 0x%02X\n", __func__, data->bLSR); 1277 dev_dbg(&port->dev, "%s - lsr 0x%02X\n", __func__, data->bLSR);
1325 1278
1326 tport->tp_lsr = data->bLSR; 1279 *lsr = data->bLSR;
1327 1280
1328free_data: 1281free_data:
1329 kfree(data); 1282 kfree(data);
@@ -1336,10 +1289,15 @@ static int ti_get_serial_info(struct ti_port *tport,
1336{ 1289{
1337 struct usb_serial_port *port = tport->tp_port; 1290 struct usb_serial_port *port = tport->tp_port;
1338 struct serial_struct ret_serial; 1291 struct serial_struct ret_serial;
1292 unsigned cwait;
1339 1293
1340 if (!ret_arg) 1294 if (!ret_arg)
1341 return -EFAULT; 1295 return -EFAULT;
1342 1296
1297 cwait = port->port.closing_wait;
1298 if (cwait != ASYNC_CLOSING_WAIT_NONE)
1299 cwait = jiffies_to_msecs(cwait) / 10;
1300
1343 memset(&ret_serial, 0, sizeof(ret_serial)); 1301 memset(&ret_serial, 0, sizeof(ret_serial));
1344 1302
1345 ret_serial.type = PORT_16550A; 1303 ret_serial.type = PORT_16550A;
@@ -1348,7 +1306,7 @@ static int ti_get_serial_info(struct ti_port *tport,
1348 ret_serial.flags = tport->tp_flags; 1306 ret_serial.flags = tport->tp_flags;
1349 ret_serial.xmit_fifo_size = TI_WRITE_BUF_SIZE; 1307 ret_serial.xmit_fifo_size = TI_WRITE_BUF_SIZE;
1350 ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800; 1308 ret_serial.baud_base = tport->tp_tdev->td_is_3410 ? 921600 : 460800;
1351 ret_serial.closing_wait = tport->tp_closing_wait; 1309 ret_serial.closing_wait = cwait;
1352 1310
1353 if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg))) 1311 if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg)))
1354 return -EFAULT; 1312 return -EFAULT;
@@ -1361,12 +1319,17 @@ static int ti_set_serial_info(struct tty_struct *tty, struct ti_port *tport,
1361 struct serial_struct __user *new_arg) 1319 struct serial_struct __user *new_arg)
1362{ 1320{
1363 struct serial_struct new_serial; 1321 struct serial_struct new_serial;
1322 unsigned cwait;
1364 1323
1365 if (copy_from_user(&new_serial, new_arg, sizeof(new_serial))) 1324 if (copy_from_user(&new_serial, new_arg, sizeof(new_serial)))
1366 return -EFAULT; 1325 return -EFAULT;
1367 1326
1327 cwait = new_serial.closing_wait;
1328 if (cwait != ASYNC_CLOSING_WAIT_NONE)
1329 cwait = msecs_to_jiffies(10 * new_serial.closing_wait);
1330
1368 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS; 1331 tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS;
1369 tport->tp_closing_wait = new_serial.closing_wait; 1332 tport->tp_port->port.closing_wait = cwait;
1370 1333
1371 return 0; 1334 return 0;
1372} 1335}
@@ -1382,7 +1345,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1382 1345
1383 if (msr & TI_MSR_DELTA_MASK) { 1346 if (msr & TI_MSR_DELTA_MASK) {
1384 spin_lock_irqsave(&tport->tp_lock, flags); 1347 spin_lock_irqsave(&tport->tp_lock, flags);
1385 icount = &tport->tp_icount; 1348 icount = &tport->tp_port->icount;
1386 if (msr & TI_MSR_DELTA_CTS) 1349 if (msr & TI_MSR_DELTA_CTS)
1387 icount->cts++; 1350 icount->cts++;
1388 if (msr & TI_MSR_DELTA_DSR) 1351 if (msr & TI_MSR_DELTA_DSR)
@@ -1391,7 +1354,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1391 icount->dcd++; 1354 icount->dcd++;
1392 if (msr & TI_MSR_DELTA_RI) 1355 if (msr & TI_MSR_DELTA_RI)
1393 icount->rng++; 1356 icount->rng++;
1394 wake_up_interruptible(&tport->tp_port->delta_msr_wait); 1357 wake_up_interruptible(&tport->tp_port->port.delta_msr_wait);
1395 spin_unlock_irqrestore(&tport->tp_lock, flags); 1358 spin_unlock_irqrestore(&tport->tp_lock, flags);
1396 } 1359 }
1397 1360
@@ -1411,56 +1374,6 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1411} 1374}
1412 1375
1413 1376
1414static void ti_drain(struct ti_port *tport, unsigned long timeout, int flush)
1415{
1416 struct ti_device *tdev = tport->tp_tdev;
1417 struct usb_serial_port *port = tport->tp_port;
1418 wait_queue_t wait;
1419
1420 spin_lock_irq(&tport->tp_lock);
1421
1422 /* wait for data to drain from the buffer */
1423 tdev->td_urb_error = 0;
1424 init_waitqueue_entry(&wait, current);
1425 add_wait_queue(&tport->tp_write_wait, &wait);
1426 for (;;) {
1427 set_current_state(TASK_INTERRUPTIBLE);
1428 if (kfifo_len(&tport->write_fifo) == 0
1429 || timeout == 0 || signal_pending(current)
1430 || tdev->td_urb_error
1431 || port->serial->disconnected) /* disconnect */
1432 break;
1433 spin_unlock_irq(&tport->tp_lock);
1434 timeout = schedule_timeout(timeout);
1435 spin_lock_irq(&tport->tp_lock);
1436 }
1437 set_current_state(TASK_RUNNING);
1438 remove_wait_queue(&tport->tp_write_wait, &wait);
1439
1440 /* flush any remaining data in the buffer */
1441 if (flush)
1442 kfifo_reset_out(&tport->write_fifo);
1443
1444 spin_unlock_irq(&tport->tp_lock);
1445
1446 mutex_lock(&port->serial->disc_mutex);
1447 /* wait for data to drain from the device */
1448 /* wait for empty tx register, plus 20 ms */
1449 timeout += jiffies;
1450 tport->tp_lsr &= ~TI_LSR_TX_EMPTY;
1451 while ((long)(jiffies - timeout) < 0 && !signal_pending(current)
1452 && !(tport->tp_lsr&TI_LSR_TX_EMPTY) && !tdev->td_urb_error
1453 && !port->serial->disconnected) {
1454 if (ti_get_lsr(tport))
1455 break;
1456 mutex_unlock(&port->serial->disc_mutex);
1457 msleep_interruptible(20);
1458 mutex_lock(&port->serial->disc_mutex);
1459 }
1460 mutex_unlock(&port->serial->disc_mutex);
1461}
1462
1463
1464static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty) 1377static void ti_stop_read(struct ti_port *tport, struct tty_struct *tty)
1465{ 1378{
1466 unsigned long flags; 1379 unsigned long flags;