From: Alan Cox Date: Tue, 15 Aug 2017 21:28:55 +0000 (+0100) Subject: tty: fix bugs in the maywait changes X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3a48f39e006f3503f053dc6183b7a33308e5dfda;p=FUZIX.git tty: fix bugs in the maywait changes (Courtesy of Brett and combined with my change to use uint8_t to make it work more nicely on Z80) --- diff --git a/Kernel/include/tty.h b/Kernel/include/tty.h index 822bf3c4..71e73a16 100644 --- a/Kernel/include/tty.h +++ b/Kernel/include/tty.h @@ -222,7 +222,7 @@ extern uint8_t tty_inproc(uint8_t minor, unsigned char c); extern void tty_outproc(uint8_t minor); extern void tty_echo(uint8_t minor, unsigned char c); extern void tty_erase(uint8_t minor); -extern int tty_putc_maywait(uint8_t minor, unsigned char c, uint8_t flags); +extern uint8_t tty_putc_maywait(uint8_t minor, unsigned char c, uint8_t flags); extern void tty_putc_wait(uint8_t minor, unsigned char c); typedef enum { diff --git a/Kernel/tty.c b/Kernel/tty.c index ae633284..6e1ce73a 100644 --- a/Kernel/tty.c +++ b/Kernel/tty.c @@ -483,7 +483,7 @@ void tty_erase(uint8_t minor) } -int tty_putc_maywait(uint8_t minor, unsigned char c, uint8_t flag) +uint8_t tty_putc_maywait(uint8_t minor, unsigned char c, uint8_t flag) { uint8_t t; @@ -509,10 +509,10 @@ int tty_putc_maywait(uint8_t minor, unsigned char c, uint8_t flag) */ if (!udata.u_ininterrupt) { - while ((t = tty_writeready(minor)) != TTY_READY_NOW) + while ((t = tty_writeready(minor)) != TTY_READY_NOW) { if (t == TTY_READY_LATER && flag) { udata.u_error = EAGAIN; - return -1; + return 1; } if (t != TTY_READY_SOON || need_reschedule()){ irqflags_t irq = di(); @@ -520,9 +520,10 @@ int tty_putc_maywait(uint8_t minor, unsigned char c, uint8_t flag) psleep(&ttydata[minor]); irqrestore(irq); } + } } tty_putc(minor, c); - return 1; + return 0; } void tty_putc_wait(uint8_t minor, unsigned char ch)