tty: allow -1 return from waitready to indicate the driver knows sleeping is good
authorAlan Cox <alan@linux.intel.com>
Sat, 24 Jan 2015 23:39:03 +0000 (23:39 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 24 Jan 2015 23:39:03 +0000 (23:39 +0000)
Kernel/tty.c

index 9762498..190b360 100644 (file)
@@ -374,6 +374,7 @@ void tty_erase(uint8_t minor)
 
 void tty_putc_wait(uint8_t minor, unsigned char c)
 {
+        uint8_t t;
 #ifdef CONFIG_DEV_PTY
        if (minor >= PTY_OFFSET)
                ptty_putc_wait(minor, c);
@@ -381,10 +382,13 @@ void tty_putc_wait(uint8_t minor, unsigned char c)
 #endif
         /* For slower platforms it's not worth the task switching and return
            costs versus waiting a bit. A box with tx interrupts and sufficient
-           performance can buffer or sleep in in tty_putc instead. */
+           performance can buffer or sleep in in tty_putc instead.
+
+           The driver should return 1 - send bytes, 0 - spinning may be useful,
+           -1 - blocked, don't spin (eg flow controlled) */
        if (!udata.u_ininterrupt) {
-               while (!tty_writeready(minor))
-                       if (need_resched())
+               while ((t = tty_writeready(minor)) != 1)
+                       if (t || need_resched())
                                psleep(&ttydata[minor]);
        }
        tty_putc(minor, c);