[PATCH 2/2] Char: tty, add tty_schedule_wakeup

From: Jiri Slaby
Date: Thu Nov 01 2007 - 07:28:19 EST


UNTESTED so far

--
tty, add tty_schedule_wakeup

Because several drivers schedule a workqueue only for tty_wakeup, move this
functionality into tty layer and use newly added centralized work.

Signed-off-by: Jiri Slaby <jirislaby@xxxxxxxxx>
Cc: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>

---
commit 0e9d5add01e8835407bd9f67b9fd82f98e19e122
tree a566aa490d247b5d5b9ff8e6ed437268c495f86b
parent 1ce760b56883d3c99b914266bca939f8d3ade1fd
author Jiri Slaby <jirislaby@xxxxxxxxx> Thu, 01 Nov 2007 10:56:24 +0100
committer Jiri Slaby <jirislaby@xxxxxxxxx> Thu, 01 Nov 2007 10:56:24 +0100

drivers/char/tty_io.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 0eb979d..fd4a0e4 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -112,6 +112,7 @@

#define TTY_WORK_HANGUP 1
#define TTY_WORK_SAK 2
+#define TTY_WORK_WAKEUP 3

struct ktermios tty_std_termios = { /* for the benefit of tty drivers */
.c_iflag = ICRNL | IXON,
@@ -1296,6 +1297,20 @@ void tty_wakeup(struct tty_struct *tty)
EXPORT_SYMBOL_GPL(tty_wakeup);

/**
+ * tty_schedule_wakeup - request more data
+ * @tty: terminal
+ *
+ * Functionally the same as tty_wakeup, but it can be used in hot
+ * paths. since the wakeup is scheduled and done in the future.
+ */
+void tty_schedule_wakeup(struct tty_struct *tty)
+{
+ set_bit(TTY_WORK_WAKEUP, tty->work_todo);
+ schedule_work(&tty->work);
+}
+EXPORT_SYMBOL_GPL(tty_schedule_wakeup);
+
+/**
* tty_ldisc_flush - flush line discipline queue
* @tty: tty
*
@@ -3599,6 +3614,8 @@ static void tty_work(struct work_struct *work)
do_tty_hangup(tty);
if (test_and_clear_bit(TTY_WORK_SAK, tty->work_todo))
__do_SAK(tty);
+ if (test_and_clear_bit(TTY_WORK_WAKEUP, tty->work_todo))
+ tty_wakeup(tty);
}

/**
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/