console: Remember if ctrlc is disabled in console_tstc()
authorJoe Hershberger <joe.hershberger@ni.com>
Tue, 3 Jul 2018 01:06:48 +0000 (20:06 -0500)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 26 Jul 2018 19:08:16 +0000 (14:08 -0500)
We don't necessarily want to re-enable ctrl-c if it was already disabled
when calling tstc().

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/console.c

index 2ba33dc5740240092e04883c5393f6b731ad51ad..36c0568dbffd836f6f74d1759b858ca006a62edd 100644 (file)
@@ -196,20 +196,21 @@ static int console_tstc(int file)
 {
        int i, ret;
        struct stdio_dev *dev;
+       int prev;
 
-       disable_ctrlc(1);
+       prev = disable_ctrlc(1);
        for (i = 0; i < cd_count[file]; i++) {
                dev = console_devices[file][i];
                if (dev->tstc != NULL) {
                        ret = dev->tstc(dev);
                        if (ret > 0) {
                                tstcdev = dev;
-                               disable_ctrlc(0);
+                               disable_ctrlc(prev);
                                return ret;
                        }
                }
        }
-       disable_ctrlc(0);
+       disable_ctrlc(prev);
 
        return 0;
 }