tty: fix bugs in the maywait changes
authorAlan Cox <alan@linux.intel.com>
Tue, 15 Aug 2017 21:28:55 +0000 (22:28 +0100)
committerAlan Cox <alan@linux.intel.com>
Tue, 15 Aug 2017 21:28:55 +0000 (22:28 +0100)
(Courtesy of Brett and combined with my change to use uint8_t to make it work
 more nicely on Z80)

Kernel/include/tty.h
Kernel/tty.c

index 822bf3c..71e73a1 100644 (file)
@@ -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 {
index ae63328..6e1ce73 100644 (file)
@@ -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)