aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_port.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2009-06-11 07:25:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-11 11:50:56 -0400
commit1ec739be75a6cb961a46ba0b1982d0edb7f27558 (patch)
treeb9e75b3171d1a5b715465b82c9cb2b711e6d5550 /drivers/char/tty_port.c
parentfcc8ac1825d3d0fb81f73bc1a80ebc863168bb56 (diff)
tty: Implement a drain delay in the tty port
We need this for devices that cannot flush and wait, but which do not order data and modem events. Without it we will hang up before all the data clears the hardware. Needed for the USB changes. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_port.c')
-rw-r--r--drivers/char/tty_port.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c
index 926d4a5593fa..4d08b6d27c28 100644
--- a/drivers/char/tty_port.c
+++ b/drivers/char/tty_port.c
@@ -308,6 +308,17 @@ int tty_port_close_start(struct tty_port *port, struct tty_struct *tty, struct f
308 if (port->flags & ASYNC_INITIALIZED && 308 if (port->flags & ASYNC_INITIALIZED &&
309 port->closing_wait != ASYNC_CLOSING_WAIT_NONE) 309 port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
310 tty_wait_until_sent(tty, port->closing_wait); 310 tty_wait_until_sent(tty, port->closing_wait);
311 if (port->drain_delay) {
312 unsigned int bps = tty_get_baud_rate(tty);
313 long timeout;
314
315 if (bps > 1200)
316 timeout = max_t(long, (HZ * 10 * port->drain_delay) / bps,
317 HZ / 10);
318 else
319 timeout = 2 * HZ;
320 schedule_timeout_interruptible(timeout);
321 }
311 return 1; 322 return 1;
312} 323}
313EXPORT_SYMBOL(tty_port_close_start); 324EXPORT_SYMBOL(tty_port_close_start);