Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide-2.6
[cascardo/linux.git] / drivers / char / selection.c
index f97b9e8..ebae344 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/selection.h>
 #include <linux/tiocl.h>
 #include <linux/console.h>
+#include <linux/smp_lock.h>
 
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
 #define isspace(c)     ((c) == ' ')
@@ -312,12 +313,20 @@ int paste_selection(struct tty_struct *tty)
        struct  tty_ldisc *ld;
        DECLARE_WAITQUEUE(wait, current);
 
+       /* always called with BTM from vt_ioctl */
+       WARN_ON(!tty_locked());
+
        acquire_console_sem();
        poke_blanked_console();
        release_console_sem();
 
-       ld = tty_ldisc_ref_wait(tty);
-       
+       ld = tty_ldisc_ref(tty);
+       if (!ld) {
+               tty_unlock();
+               ld = tty_ldisc_ref_wait(tty);
+               tty_lock();
+       }
+
        add_wait_queue(&vc->paste_wait, &wait);
        while (sel_buffer && sel_buffer_lth > pasted) {
                set_current_state(TASK_INTERRUPTIBLE);