console: unify fgetc function when console MUX is deactivated

Unify the fgetc function when MUX is activated or not:
- always call tstc() : it is the normal behavior expected
  by serial uclass (call tstc then getc) and that avoids
  issue when SERIAL_RX_BUFFER is activated
- reload WATCHDOG in the char waiting loop

This patch allow to have the same behavior when CONSOLE_MUX is activated
or not and avoid regression when this feature is deactivated.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
lime2-spi
Patrick Delaunay 6 years ago committed by Tom Rini
parent d3bb785854
commit 273a12526c
  1. 9
      common/console.c

@ -311,12 +311,12 @@ int serial_printf(const char *fmt, ...)
int fgetc(int file) int fgetc(int file)
{ {
if (file < MAX_FILES) { if (file < MAX_FILES) {
#if CONFIG_IS_ENABLED(CONSOLE_MUX)
/* /*
* Effectively poll for input wherever it may be available. * Effectively poll for input wherever it may be available.
*/ */
for (;;) { for (;;) {
WATCHDOG_RESET(); WATCHDOG_RESET();
#if CONFIG_IS_ENABLED(CONSOLE_MUX)
/* /*
* Upper layer may have already called tstc() so * Upper layer may have already called tstc() so
* check for that first. * check for that first.
@ -324,6 +324,10 @@ int fgetc(int file)
if (tstcdev != NULL) if (tstcdev != NULL)
return console_getc(file); return console_getc(file);
console_tstc(file); console_tstc(file);
#else
if (console_tstc(file))
return console_getc(file);
#endif
#ifdef CONFIG_WATCHDOG #ifdef CONFIG_WATCHDOG
/* /*
* If the watchdog must be rate-limited then it should * If the watchdog must be rate-limited then it should
@ -332,9 +336,6 @@ int fgetc(int file)
udelay(1); udelay(1);
#endif #endif
} }
#else
return console_getc(file);
#endif
} }
return -1; return -1;

Loading…
Cancel
Save