]> Pileus Git - ~andy/linux/blobdiff - drivers/tty/vt/selection.c
Merge tag 'boards-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
[~andy/linux] / drivers / tty / vt / selection.c
index 60b7b69260592e9b413b599dcf572117f8487450..ea27804d87af9ec2485b1043f8ad97b30c05713f 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/selection.h>
 #include <linux/tiocl.h>
 #include <linux/console.h>
+#include <linux/tty_flip.h>
 
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
 #define isspace(c)     ((c) == ' ')
@@ -346,8 +347,8 @@ int paste_selection(struct tty_struct *tty)
        console_unlock();
 
        ld = tty_ldisc_ref_wait(tty);
+       tty_buffer_lock_exclusive(&vc->port);
 
-       /* FIXME: this is completely unsafe */
        add_wait_queue(&vc->paste_wait, &wait);
        while (sel_buffer && sel_buffer_lth > pasted) {
                set_current_state(TASK_INTERRUPTIBLE);
@@ -356,13 +357,14 @@ int paste_selection(struct tty_struct *tty)
                        continue;
                }
                count = sel_buffer_lth - pasted;
-               count = min(count, tty->receive_room);
-               ld->ops->receive_buf(tty, sel_buffer + pasted, NULL, count);
+               count = tty_ldisc_receive_buf(ld, sel_buffer + pasted, NULL,
+                                             count);
                pasted += count;
        }
        remove_wait_queue(&vc->paste_wait, &wait);
        __set_current_state(TASK_RUNNING);
 
+       tty_buffer_unlock_exclusive(&vc->port);
        tty_ldisc_deref(ld);
        return 0;
 }