From acf0cc27460f0879159a3cc47a34b9c7f9d6102b Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 7 Mar 2013 15:55:52 +0100 Subject: [PATCH] --- yaml --- r: 364243 b: refs/heads/master c: b74414f5f3227d9db309bfaaea3ae889af01430a h: refs/heads/master i: 364241: a8041a58dec41e9786f30c8963b366836fe1ccef 364239: f7dde2fda1d33d5e8dc162fe9b6eb1396f0de566 v: v3 --- [refs] | 2 +- trunk/drivers/tty/tty_port.c | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/[refs] b/[refs] index a84e0698e822..7b8a82f4145c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 957dacaee56d18e5c2cbe722429de5a746a3cf44 +refs/heads/master: b74414f5f3227d9db309bfaaea3ae889af01430a diff --git a/trunk/drivers/tty/tty_port.c b/trunk/drivers/tty/tty_port.c index 0af8d9aa5b02..20426ccbd58b 100644 --- a/trunk/drivers/tty/tty_port.c +++ b/trunk/drivers/tty/tty_port.c @@ -441,6 +441,20 @@ int tty_port_block_til_ready(struct tty_port *port, } EXPORT_SYMBOL(tty_port_block_til_ready); +static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty) +{ + unsigned int bps = tty_get_baud_rate(tty); + long timeout; + + if (bps > 1200) { + timeout = (HZ * 10 * port->drain_delay) / bps; + timeout = max_t(long, timeout, HZ / 10); + } else { + timeout = 2 * HZ; + } + schedule_timeout_interruptible(timeout); +} + int tty_port_close_start(struct tty_port *port, struct tty_struct *tty, struct file *filp) { @@ -479,17 +493,8 @@ int tty_port_close_start(struct tty_port *port, if (test_bit(ASYNCB_INITIALIZED, &port->flags) && port->closing_wait != ASYNC_CLOSING_WAIT_NONE) tty_wait_until_sent_from_close(tty, port->closing_wait); - if (port->drain_delay) { - unsigned int bps = tty_get_baud_rate(tty); - long timeout; - - if (bps > 1200) - timeout = max_t(long, - (HZ * 10 * port->drain_delay) / bps, HZ / 10); - else - timeout = 2 * HZ; - schedule_timeout_interruptible(timeout); - } + if (port->drain_delay) + tty_port_drain_delay(port, tty); /* Flush the ldisc buffering */ tty_ldisc_flush(tty);