vserver 1.9.3
[linux-2.6.git] / drivers / char / selection.c
index 598f601..4675eda 100644 (file)
 #include <linux/tiocl.h>
 #include <linux/console.h>
 
-#ifndef MIN
-#define MIN(a,b)       ((a) < (b) ? (a) : (b))
-#endif
-
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
 #define isspace(c)     ((c) == ' ')
 
@@ -281,12 +277,15 @@ int paste_selection(struct tty_struct *tty)
 {
        struct vt_struct *vt = (struct vt_struct *) tty->driver_data;
        int     pasted = 0, count;
+       struct  tty_ldisc *ld;
        DECLARE_WAITQUEUE(wait, current);
 
        acquire_console_sem();
        poke_blanked_console();
        release_console_sem();
 
+       ld = tty_ldisc_ref_wait(tty);
+       
        add_wait_queue(&vt->paste_wait, &wait);
        while (sel_buffer && sel_buffer_lth > pasted) {
                set_current_state(TASK_INTERRUPTIBLE);
@@ -295,12 +294,14 @@ int paste_selection(struct tty_struct *tty)
                        continue;
                }
                count = sel_buffer_lth - pasted;
-               count = MIN(count, tty->ldisc.receive_room(tty));
+               count = min(count, tty->ldisc.receive_room(tty));
                tty->ldisc.receive_buf(tty, sel_buffer + pasted, NULL, count);
                pasted += count;
        }
        remove_wait_queue(&vt->paste_wait, &wait);
        current->state = TASK_RUNNING;
+
+       tty_ldisc_deref(ld);
        return 0;
 }