lkml.org 
[lkml]   [2013]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 5/6] TTY: clean up port drain-delay handling
Date
Move port drain-delay handling to a separate function.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
---
drivers/tty/tty_port.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
index cd65f7e..048cc85 100644
--- a/drivers/tty/tty_port.c
+++ b/drivers/tty/tty_port.c
@@ -408,6 +408,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)
{
@@ -446,17 +460,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);

--
1.8.1.1


\
 
 \ /
  Last update: 2013-03-07 21:43    [W:0.138 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site