]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
sandbox: Tidy up terminal restore
authorSimon Glass <sjg@chromium.org>
Mon, 11 May 2015 03:07:27 +0000 (21:07 -0600)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 8 Sep 2015 20:48:17 +0000 (22:48 +0200)
For some reason 'u-boot -D' does not restore the terminal correctly when
the 'reset' command is used. Call the terminal restore function explicitly
in this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
arch/sandbox/cpu/cpu.c
arch/sandbox/cpu/os.c
include/os.h

index b6aae3718a19f81baaa4a7616ec1231d67c3e80e..02c4cd366d13c0444eb28f11c35074a06d608413 100644 (file)
@@ -22,6 +22,8 @@ unsigned long map_len;
 
 void reset_cpu(ulong ignored)
 {
+       /* Do this here while it still has an effect */
+       os_fd_restore();
        if (state_uninit())
                os_exit(2);
 
index e6dd17e9efc7c62777bc6e4210c367abb2471435..8a4d719835ccb88c00b5aa6fd1e37cfdc049e8e8 100644 (file)
@@ -107,10 +107,12 @@ void os_exit(int exit_code)
 static struct termios orig_term;
 static bool term_setup;
 
-static void os_fd_restore(void)
+void os_fd_restore(void)
 {
-       if (term_setup)
+       if (term_setup) {
                tcsetattr(0, TCSANOW, &orig_term);
+               term_setup = false;
+       }
 }
 
 /* Put tty into raw mode so <tab> and <ctrl+c> work */
@@ -120,7 +122,6 @@ void os_tty_raw(int fd, bool allow_sigs)
 
        if (term_setup)
                return;
-       term_setup = true;
 
        /* If not a tty, don't complain */
        if (tcgetattr(fd, &orig_term))
@@ -134,6 +135,7 @@ void os_tty_raw(int fd, bool allow_sigs)
        if (tcsetattr(fd, TCSANOW, &term))
                return;
 
+       term_setup = true;
        atexit(os_fd_restore);
 }
 
index ffbdce84643e0f593f8d6d684753b1b32af13447..954a48c9919e78a9259b615d6be12aa01c1ef4b3 100644 (file)
@@ -111,6 +111,14 @@ void os_exit(int exit_code) __attribute__((noreturn));
  */
 void os_tty_raw(int fd, bool allow_sigs);
 
+/**
+ * Restore the tty to its original mode
+ *
+ * Call this to restore the original terminal mode, after it has been changed
+ * by os_tty_raw(). This is an internal function.
+ */
+void os_fd_restore(void);
+
 /**
  * Acquires some memory from the underlying os.
  *