[PATCH] TTY layer buffering revamp
[pandora-kernel.git] / drivers / char / hvc_console.c
index cddb789..1994a92 100644 (file)
@@ -597,9 +597,7 @@ static int hvc_poll(struct hvc_struct *hp)
 
        /* Read data if any */
        for (;;) {
-               int count = N_INBUF;
-               if (count > (TTY_FLIPBUF_SIZE - tty->flip.count))
-                       count = TTY_FLIPBUF_SIZE - tty->flip.count;
+               int count = tty_buffer_request_room(tty, N_INBUF);
 
                /* If flip is full, just reschedule a later read */
                if (count == 0) {
@@ -635,7 +633,7 @@ static int hvc_poll(struct hvc_struct *hp)
                        tty_insert_flip_char(tty, buf[i], 0);
                }
 
-               if (tty->flip.count)
+               if (count)
                        tty_schedule_flip(tty);
 
                /*
@@ -839,9 +837,6 @@ int __init hvc_init(void)
        hvc_driver->flags = TTY_DRIVER_REAL_RAW;
        tty_set_operations(hvc_driver, &hvc_ops);
 
-       if (tty_register_driver(hvc_driver))
-               panic("Couldn't register hvc console driver\n");
-
        /* Always start the kthread because there can be hotplug vty adapters
         * added later. */
        hvc_task = kthread_run(khvcd, NULL, "khvcd");
@@ -851,6 +846,9 @@ int __init hvc_init(void)
                return -EIO;
        }
 
+       if (tty_register_driver(hvc_driver))
+               panic("Couldn't register hvc console driver\n");
+
        return 0;
 }
 module_init(hvc_init);