n_tty: Factor packet mode status change for reuse
authorPeter Hurley <peter@hurleysoftware.com>
Mon, 11 Mar 2013 20:44:22 +0000 (16:44 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Mar 2013 23:32:46 +0000 (16:32 -0700)
Factor the packet mode status change from n_tty_flush_buffer
for use by follow-on patch.

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

index 16793eccc6ae5010059790974a2d0d5837470c48..7e7f6514fb53262352266e2c538403b4c8245856 100644 (file)
@@ -223,6 +223,18 @@ static void reset_buffer_flags(struct tty_struct *tty)
        n_tty_set_room(tty);
 }
 
+static void n_tty_packet_mode_flush(struct tty_struct *tty)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&tty->ctrl_lock, flags);
+       if (tty->link->packet) {
+               tty->ctrl_status |= TIOCPKT_FLUSHREAD;
+               wake_up_interruptible(&tty->link->read_wait);
+       }
+       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+}
+
 /**
  *     n_tty_flush_buffer      -       clean input queue
  *     @tty:   terminal device
@@ -237,19 +249,11 @@ static void reset_buffer_flags(struct tty_struct *tty)
 
 static void n_tty_flush_buffer(struct tty_struct *tty)
 {
-       unsigned long flags;
        /* clear everything and unthrottle the driver */
        reset_buffer_flags(tty);
 
-       if (!tty->link)
-               return;
-
-       spin_lock_irqsave(&tty->ctrl_lock, flags);
-       if (tty->link->packet) {
-               tty->ctrl_status |= TIOCPKT_FLUSHREAD;
-               wake_up_interruptible(&tty->link->read_wait);
-       }
-       spin_unlock_irqrestore(&tty->ctrl_lock, flags);
+       if (tty->link)
+               n_tty_packet_mode_flush(tty);
 }
 
 /**