mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
console: add console_flush_stdin()
Add a common helper console_flush_stdin() to drain all pending characters from stdin. This consolidates the open-coded while (tstc()) getchar() pattern that appeared in multiple places across the tree. Signed-off-by: Gregor Herburger <gregor.herburger@linutronix.de> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Tom Rini
parent
3abc7c1d46
commit
2c8fdd7aea
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <ansi.h>
|
||||
#include <charset.h>
|
||||
#include <console.h>
|
||||
#include <efi_device_path.h>
|
||||
#include <malloc.h>
|
||||
#include <time.h>
|
||||
@@ -299,8 +300,7 @@ static int query_console_serial(int *rows, int *cols)
|
||||
int n[2];
|
||||
|
||||
/* Empty input buffer */
|
||||
while (tstc())
|
||||
getchar();
|
||||
console_flush_stdin();
|
||||
|
||||
/*
|
||||
* Not all terminals understand CSI [18t for querying the console size.
|
||||
@@ -960,8 +960,7 @@ static void efi_cin_check(void)
|
||||
*/
|
||||
static void efi_cin_empty_buffer(void)
|
||||
{
|
||||
while (tstc())
|
||||
getchar();
|
||||
console_flush_stdin();
|
||||
key_available = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user