mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] startup: Fix do_autoboot_countdown() running multiple times
@ 2020-06-26  6:41 Sascha Hauer
  2020-06-29  8:37 ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2020-06-26  6:41 UTC (permalink / raw)
  To: Barebox List; +Cc: Ahmad Fatoum

The comment above do_autoboot_countdown() states: "This function can be
called multiple times, it is executed only the first time.". Since
1973892533 ("startup: don't clobber original autoboot state") This is no
longer the case. Bring back the old and documented behaviour.

Fixes: 1973892533 ("startup: don't clobber original autoboot state")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/startup.c | 5 ++++-
 include/common.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/startup.c b/common/startup.c
index 7e0f7d6b64..71a28a7be8 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -235,7 +235,7 @@ void set_autoboot_state(enum autoboot_state autoboot)
  */
 enum autoboot_state do_autoboot_countdown(void)
 {
-	enum autoboot_state autoboot_state;
+	static enum autoboot_state autoboot_state = AUTOBOOT_UNKNOWN;
 	unsigned flags = CONSOLE_COUNTDOWN_EXTERN;
 	int ret;
 	struct stat s;
@@ -243,6 +243,9 @@ enum autoboot_state do_autoboot_countdown(void)
 	char *abortkeys = NULL;
 	unsigned char outkey;
 
+	if (autoboot_state != AUTOBOOT_UNKNOWN)
+		return autoboot_state;
+
 	if (global_autoboot_state != AUTOBOOT_COUNTDOWN)
 		return global_autoboot_state;
 
diff --git a/include/common.h b/include/common.h
index ce16ff83af..ceb0b358bd 100644
--- a/include/common.h
+++ b/include/common.h
@@ -88,6 +88,7 @@ enum autoboot_state {
 	AUTOBOOT_ABORT,
 	AUTOBOOT_MENU,
 	AUTOBOOT_BOOT,
+	AUTOBOOT_UNKNOWN,
 };
 
 void set_autoboot_state(enum autoboot_state autoboot);
-- 
2.27.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] startup: Fix do_autoboot_countdown() running multiple times
  2020-06-26  6:41 [PATCH] startup: Fix do_autoboot_countdown() running multiple times Sascha Hauer
@ 2020-06-29  8:37 ` Ahmad Fatoum
  2020-07-01  5:26   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2020-06-29  8:37 UTC (permalink / raw)
  To: Sascha Hauer, Barebox List

Hi,

On 6/26/20 8:41 AM, Sascha Hauer wrote:
> The comment above do_autoboot_countdown() states: "This function can be
> called multiple times, it is executed only the first time.". Since
> 1973892533 ("startup: don't clobber original autoboot state") This is no
> longer the case. Bring back the old and documented behaviour.

guilty as charged. I didn't read the comment..
do_autoboot_countdown is called only once though in the code base.
How do you make use of being able to call it multiple times?

Cheers
Ahmad 

> 
> Fixes: 1973892533 ("startup: don't clobber original autoboot state")
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  common/startup.c | 5 ++++-
>  include/common.h | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/common/startup.c b/common/startup.c
> index 7e0f7d6b64..71a28a7be8 100644
> --- a/common/startup.c
> +++ b/common/startup.c
> @@ -235,7 +235,7 @@ void set_autoboot_state(enum autoboot_state autoboot)
>   */
>  enum autoboot_state do_autoboot_countdown(void)
>  {
> -	enum autoboot_state autoboot_state;
> +	static enum autoboot_state autoboot_state = AUTOBOOT_UNKNOWN;
>  	unsigned flags = CONSOLE_COUNTDOWN_EXTERN;
>  	int ret;
>  	struct stat s;
> @@ -243,6 +243,9 @@ enum autoboot_state do_autoboot_countdown(void)
>  	char *abortkeys = NULL;
>  	unsigned char outkey;
>  
> +	if (autoboot_state != AUTOBOOT_UNKNOWN)
> +		return autoboot_state;
> +
>  	if (global_autoboot_state != AUTOBOOT_COUNTDOWN)
>  		return global_autoboot_state;
>  
> diff --git a/include/common.h b/include/common.h
> index ce16ff83af..ceb0b358bd 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -88,6 +88,7 @@ enum autoboot_state {
>  	AUTOBOOT_ABORT,
>  	AUTOBOOT_MENU,
>  	AUTOBOOT_BOOT,
> +	AUTOBOOT_UNKNOWN,
>  };
>  
>  void set_autoboot_state(enum autoboot_state autoboot);
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] startup: Fix do_autoboot_countdown() running multiple times
  2020-06-29  8:37 ` Ahmad Fatoum
@ 2020-07-01  5:26   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2020-07-01  5:26 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: Barebox List

On Mon, Jun 29, 2020 at 10:37:43AM +0200, Ahmad Fatoum wrote:
> Hi,
> 
> On 6/26/20 8:41 AM, Sascha Hauer wrote:
> > The comment above do_autoboot_countdown() states: "This function can be
> > called multiple times, it is executed only the first time.". Since
> > 1973892533 ("startup: don't clobber original autoboot state") This is no
> > longer the case. Bring back the old and documented behaviour.
> 
> guilty as charged. I didn't read the comment..
> do_autoboot_countdown is called only once though in the code base.
> How do you make use of being able to call it multiple times?

We use this in a customer project. The decision whether we want to abort
boot or not has to be made earlier. That said, it's out of tree code, so
should this hurt anywhere else, we can change it and find another
solution for our customer.

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-01  5:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-26  6:41 [PATCH] startup: Fix do_autoboot_countdown() running multiple times Sascha Hauer
2020-06-29  8:37 ` Ahmad Fatoum
2020-07-01  5:26   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox