Merge https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[platform/kernel/u-boot.git] / common / cli_readline.c
index ecded11..47b8762 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2000
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
@@ -5,13 +6,13 @@
  * Add to readline cmdline-editing by
  * (C) Copyright 2005
  * JinHua Luo, GuangDong Linux Center, <luo.jinhua@gd-linux.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <bootretry.h>
 #include <cli.h>
+#include <command.h>
+#include <time.h>
 #include <watchdog.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -67,7 +68,7 @@ static char *delete_char (char *buffer, char *p, int *colp, int *np, int plen)
 #define CREAD_HIST_CHAR                ('!')
 
 #define getcmd_putch(ch)       putc(ch)
-#define getcmd_getch()         getc()
+#define getcmd_getch()         getchar()
 #define getcmd_cbeep()         getcmd_putch('\a')
 
 #define HIST_MAX               20
@@ -274,6 +275,10 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len,
 
                ichar = getcmd_getch();
 
+               /* ichar=0x0 when error occurs in U-Boot getc */
+               if (!ichar)
+                       continue;
+
                if ((ichar == '\n') || (ichar == '\r')) {
                        putc('\n');
                        break;
@@ -566,13 +571,7 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer,
                        return -2;      /* timed out */
                WATCHDOG_RESET();       /* Trigger watchdog, if needed */
 
-#ifdef CONFIG_SHOW_ACTIVITY
-               while (!tstc()) {
-                       show_activity(0);
-                       WATCHDOG_RESET();
-               }
-#endif
-               c = getc();
+               c = getchar();
 
                /*
                 * Special character handling