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);
#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);