diff mbox series

[v5,07/17] bootmenu: flush input buffer before waiting user key input

Message ID 20220428080950.23509-8-masahisa.kojima@linaro.org
State New
Headers show
Series enable menu-driven boot device selection | expand

Commit Message

Masahisa Kojima April 28, 2022, 8:09 a.m. UTC
Before waiting user key input to stop autoboot, the input buffer
must be flushed.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
---
Change in v5:
- newly created, split into separate patch

 cmd/bootmenu.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Heinrich Schuchardt April 29, 2022, 7:46 p.m. UTC | #1
On 4/28/22 10:09, Masahisa Kojima wrote:
> Before waiting user key input to stop autoboot, the input buffer
> must be flushed.

I am not sure if this is desirable.

The default time for autoboot stopping is just 2 seconds. So it is nice
to be able to type ahead.

On the other hand I have seen boards not booting because after the
serial driver was initialized it found some random byte in the input buffer.

I would prefer flushing of input in serial_init().

Best regards

Heinrich

>
> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
> ---
> Change in v5:
> - newly created, split into separate patch
>
>   cmd/bootmenu.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
> index d573487272..9a32a18b19 100644
> --- a/cmd/bootmenu.c
> +++ b/cmd/bootmenu.c
> @@ -87,6 +87,10 @@ static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
>   	int i, c;
>
>   	if (menu->delay > 0) {
> +		/* flush input */
> +		while (tstc())
> +			getchar();
> +
>   		printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
>   		printf("  Hit any key to stop autoboot: %2d ", menu->delay);
>   	}
Masahisa Kojima May 9, 2022, 8:33 a.m. UTC | #2
Hi Heinrich,

On Sat, 30 Apr 2022 at 04:46, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 4/28/22 10:09, Masahisa Kojima wrote:
> > Before waiting user key input to stop autoboot, the input buffer
> > must be flushed.
>
> I am not sure if this is desirable.
>
> The default time for autoboot stopping is just 2 seconds. So it is nice
> to be able to type ahead.
>
> On the other hand I have seen boards not booting because after the
> serial driver was initialized it found some random byte in the input buffer.

OK, I agree. I drop this patch.

Thanks,
Masahisa Kojima

>
> I would prefer flushing of input in serial_init().
>
> Best regards
>
> Heinrich
>
> >
> > Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
> > ---
> > Change in v5:
> > - newly created, split into separate patch
> >
> >   cmd/bootmenu.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
> > index d573487272..9a32a18b19 100644
> > --- a/cmd/bootmenu.c
> > +++ b/cmd/bootmenu.c
> > @@ -87,6 +87,10 @@ static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
> >       int i, c;
> >
> >       if (menu->delay > 0) {
> > +             /* flush input */
> > +             while (tstc())
> > +                     getchar();
> > +
> >               printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
> >               printf("  Hit any key to stop autoboot: %2d ", menu->delay);
> >       }
>
diff mbox series

Patch

diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index d573487272..9a32a18b19 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -87,6 +87,10 @@  static void bootmenu_autoboot_loop(struct bootmenu_data *menu,
 	int i, c;
 
 	if (menu->delay > 0) {
+		/* flush input */
+		while (tstc())
+			getchar();
+
 		printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
 		printf("  Hit any key to stop autoboot: %2d ", menu->delay);
 	}