]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Char: tty_ioctl, use wait_event_interruptible_timeout
authorJiri Slaby <jirislaby@gmail.com>
Mon, 16 Jul 2007 06:40:18 +0000 (23:40 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 16 Jul 2007 16:05:43 +0000 (09:05 -0700)
tty_ioctl, use wait_event_interruptible_timeout

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/tty_ioctl.c

index 918e24c885f122944529f0e04702e5159b8c0a94..2b6a3847a9ee656ecb9c13bae58325b2b3734a0c 100644 (file)
@@ -52,8 +52,6 @@
 
 void tty_wait_until_sent(struct tty_struct * tty, long timeout)
 {
-       DECLARE_WAITQUEUE(wait, current);
-
 #ifdef TTY_DEBUG_WAIT_UNTIL_SENT
        char buf[64];
        
@@ -61,26 +59,13 @@ void tty_wait_until_sent(struct tty_struct * tty, long timeout)
 #endif
        if (!tty->driver->chars_in_buffer)
                return;
-       add_wait_queue(&tty->write_wait, &wait);
        if (!timeout)
                timeout = MAX_SCHEDULE_TIMEOUT;
-       do {
-#ifdef TTY_DEBUG_WAIT_UNTIL_SENT
-               printk(KERN_DEBUG "waiting %s...(%d)\n", tty_name(tty, buf),
-                      tty->driver->chars_in_buffer(tty));
-#endif
-               set_current_state(TASK_INTERRUPTIBLE);
-               if (signal_pending(current))
-                       goto stop_waiting;
-               if (!tty->driver->chars_in_buffer(tty))
-                       break;
-               timeout = schedule_timeout(timeout);
-       } while (timeout);
+       if (wait_event_interruptible_timeout(tty->write_wait,
+                       !tty->driver->chars_in_buffer(tty), timeout))
+               return;
        if (tty->driver->wait_until_sent)
                tty->driver->wait_until_sent(tty, timeout);
-stop_waiting:
-       set_current_state(TASK_RUNNING);
-       remove_wait_queue(&tty->write_wait, &wait);
 }
 
 EXPORT_SYMBOL(tty_wait_until_sent);