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:
Gregor Herburger
2026-04-13 17:24:53 +02:00
committed by Tom Rini
parent 3abc7c1d46
commit 2c8fdd7aea
7 changed files with 26 additions and 23 deletions

View File

@@ -202,6 +202,11 @@ int console_clear(void);
*/
int console_remove_by_name(const char *name);
/**
* console_flush_stdin() - drops all pending characters from stdin
*/
void console_flush_stdin(void);
/*
* CONSOLE multiplexing.
*/