tty: Abstract tty buffer work
authorPeter Hurley <peter@hurleysoftware.com>
Sat, 17 Oct 2015 20:36:23 +0000 (16:36 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 18 Oct 2015 04:32:21 +0000 (21:32 -0700)
Introduce API functions to restart and cancel tty buffer work, rather
than manipulate buffer work directly.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_tty.c
drivers/tty/tty_buffer.c
drivers/tty/tty_io.c
drivers/tty/tty_port.c
include/linux/tty.h

index fb8ccbfdbb30bfa41ef67dfd70e4d61e78d31241..13844261cd5f3cdad44131a3e215f97d2ecae2f4 100644 (file)
@@ -201,7 +201,7 @@ static void n_tty_kick_worker(struct tty_struct *tty)
                 */
                WARN_RATELIMIT(test_bit(TTY_LDISC_HALTED, &tty->flags),
                               "scheduling buffer work for halted ldisc\n");
-               queue_work(system_unbound_wq, &tty->port->buf.work);
+               tty_buffer_restart_work(tty->port);
        }
 }
 
index a660ab181cca7357c59c7256303628eb8bb929a9..7cc16db37e0e7ae6be67b6f81515de10ea83a0da 100644 (file)
@@ -587,3 +587,13 @@ void tty_buffer_set_lock_subclass(struct tty_port *port)
 {
        lockdep_set_subclass(&port->buf.lock, TTY_LOCK_SLAVE);
 }
+
+bool tty_buffer_restart_work(struct tty_port *port)
+{
+       return queue_work(system_unbound_wq, &port->buf.work);
+}
+
+bool tty_buffer_cancel_work(struct tty_port *port)
+{
+       return cancel_work_sync(&port->buf.work);
+}
index 173fdeba09870d2de43a3f69b2a53721a7e8adf2..0c41dbcb90b8bc7d8ab430d562206e7c2469411f 100644 (file)
@@ -1689,7 +1689,7 @@ static void release_tty(struct tty_struct *tty, int idx)
        tty->port->itty = NULL;
        if (tty->link)
                tty->link->port->itty = NULL;
-       cancel_work_sync(&tty->port->buf.work);
+       tty_buffer_cancel_work(tty->port);
 
        tty_kref_put(tty->link);
        tty_kref_put(tty);
index e04a8cfb16f764b460f5c3072820c7092f63b18e..482f33f2004336abd3c99686600cf9bc2382f2ad 100644 (file)
@@ -130,7 +130,7 @@ EXPORT_SYMBOL(tty_port_free_xmit_buf);
  */
 void tty_port_destroy(struct tty_port *port)
 {
-       cancel_work_sync(&port->buf.work);
+       tty_buffer_cancel_work(port);
        tty_buffer_free_all(port);
 }
 EXPORT_SYMBOL(tty_port_destroy);
index 533d7f6e248190854e19e338a8cb30db7b49d8c4..5b04b0a5375b338dabbfa4a68b8482e04ffbbbc9 100644 (file)
@@ -467,6 +467,8 @@ extern void tty_buffer_free_all(struct tty_port *port);
 extern void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld);
 extern void tty_buffer_init(struct tty_port *port);
 extern void tty_buffer_set_lock_subclass(struct tty_port *port);
+extern bool tty_buffer_restart_work(struct tty_port *port);
+extern bool tty_buffer_cancel_work(struct tty_port *port);
 extern speed_t tty_termios_baud_rate(struct ktermios *termios);
 extern speed_t tty_termios_input_baud_rate(struct ktermios *termios);
 extern void tty_termios_encode_baud_rate(struct ktermios *termios,