diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-02-08 08:27:01 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-02-08 08:27:01 +0100 |
commit | c0735348802c29cc46db3758b5e477f2bc8ff058 (patch) | |
tree | 957d0ef3824de67e6c1ba48002f8ff008d1d81ae /common/console.c | |
parent | a22f59c178355ea3efe376739591a43c8ac877d1 (diff) | |
parent | 36d5eea256ff81ddb108180f655dd6921fe70e8d (diff) | |
download | barebox-c0735348802c29cc46db3758b5e477f2bc8ff058.tar.gz barebox-c0735348802c29cc46db3758b5e477f2bc8ff058.tar.xz |
Merge branch 'for-next/ratp'
Diffstat (limited to 'common/console.c')
-rw-r--r-- | common/console.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/common/console.c b/common/console.c index 4a1d2576d0..a541892583 100644 --- a/common/console.c +++ b/common/console.c @@ -31,6 +31,7 @@ #include <kfifo.h> #include <module.h> #include <poller.h> +#include <ratp_bb.h> #include <magicvar.h> #include <globalvar.h> #include <linux/list.h> @@ -313,8 +314,16 @@ static int getc_raw(void) if (!(cdev->f_active & CONSOLE_STDIN)) continue; active = 1; - if (cdev->tstc(cdev)) - return cdev->getc(cdev); + if (cdev->tstc(cdev)) { + int ch = cdev->getc(cdev); + + if (IS_ENABLED(CONFIG_RATP) && ch == 0x01) { + barebox_ratp(cdev); + return -1; + } + + return ch; + } } if (!active) /* no active console found. bail out */ @@ -349,16 +358,26 @@ int getc(void) start = get_time_ns(); while (1) { if (tstc_raw()) { - kfifo_putc(console_input_fifo, getc_raw()); + int c = getc_raw(); + + if (c < 0) + break; + + kfifo_putc(console_input_fifo, c); start = get_time_ns(); } + if (is_timeout(start, 100 * USECOND) && kfifo_len(console_input_fifo)) break; } + if (!kfifo_len(console_input_fifo)) + return -1; + kfifo_getc(console_input_fifo, &ch); + return ch; } EXPORT_SYMBOL(getc); |