diff mbox

[U-Boot,6/6] autoboot: move bootdelay >= 0 check to abortboot()

Message ID 1466487167-18987-7-git-send-email-yamada.masahiro@socionext.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Masahiro Yamada June 21, 2016, 5:32 a.m. UTC
Move the bootdelay >= 0 check to the caller, which simplifies
the callees.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 common/autoboot.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Comments

Stefan Roese June 21, 2016, 5:47 a.m. UTC | #1
Hi Masahiro,

On 21.06.2016 07:32, Masahiro Yamada wrote:
> Move the bootdelay >= 0 check to the caller, which simplifies
> the callees.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
Simon Glass June 21, 2016, 4:06 p.m. UTC | #2
On 20 June 2016 at 23:47, Stefan Roese <sr@denx.de> wrote:
> Hi Masahiro,
>
> On 21.06.2016 07:32, Masahiro Yamada wrote:
>>
>> Move the bootdelay >= 0 check to the caller, which simplifies
>> the callees.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>
>
> Reviewed-by: Stefan Roese <sr@denx.de>

Reviewed-by: Simon Glass <sjg@chromium.org>
Heiko Schocher June 22, 2016, 5:57 a.m. UTC | #3
Hello Masahiro,

Am 21.06.2016 um 07:32 schrieb Masahiro Yamada:
> Move the bootdelay >= 0 check to the caller, which simplifies
> the callees.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>   common/autoboot.c | 22 ++++++++--------------
>   1 file changed, 8 insertions(+), 14 deletions(-)

Thanks!

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/autoboot.c b/common/autoboot.c
> index 2d19104..528919f 100644
> --- a/common/autoboot.c
> +++ b/common/autoboot.c
> @@ -187,9 +187,6 @@ static int __abortboot(int bootdelay)
>   	int abort;
>   	uint64_t etime = endtick(bootdelay);
>
> -	if (bootdelay < 0)
> -		return 0;
> -
>   #  ifdef CONFIG_AUTOBOOT_PROMPT
>   	/*
>   	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
> @@ -219,20 +216,16 @@ static int __abortboot(int bootdelay)
>   #ifdef CONFIG_MENUPROMPT
>   	printf(CONFIG_MENUPROMPT);
>   #else
> -	if (bootdelay >= 0)
> -		printf("Hit any key to stop autoboot: %2d ", bootdelay);
> +	printf("Hit any key to stop autoboot: %2d ", bootdelay);
>   #endif
>
>   	/*
>   	 * Check if key already pressed
> -	 * Don't check if bootdelay < 0
>   	 */
> -	if (bootdelay >= 0) {
> -		if (tstc()) {	/* we got a key press	*/
> -			(void) getc();  /* consume input	*/
> -			puts("\b\b\b 0");
> -			abort = 1;	/* don't auto boot	*/
> -		}
> +	if (tstc()) {	/* we got a key press	*/
> +		(void) getc();  /* consume input	*/
> +		puts("\b\b\b 0");
> +		abort = 1;	/* don't auto boot	*/
>   	}
>
>   	while ((bootdelay > 0) && (!abort)) {
> @@ -264,9 +257,10 @@ static int __abortboot(int bootdelay)
>
>   static int abortboot(int bootdelay)
>   {
> -	int ret;
> +	int ret = 0;
>
> -	ret = __abortboot(bootdelay);
> +	if (bootdelay >= 0)
> +		ret = __abortboot(bootdelay);
>
>   #ifdef CONFIG_SILENT_CONSOLE
>   	if (abort)
>
diff mbox

Patch

diff --git a/common/autoboot.c b/common/autoboot.c
index 2d19104..528919f 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -187,9 +187,6 @@  static int __abortboot(int bootdelay)
 	int abort;
 	uint64_t etime = endtick(bootdelay);
 
-	if (bootdelay < 0)
-		return 0;
-
 #  ifdef CONFIG_AUTOBOOT_PROMPT
 	/*
 	 * CONFIG_AUTOBOOT_PROMPT includes the %d for all boards.
@@ -219,20 +216,16 @@  static int __abortboot(int bootdelay)
 #ifdef CONFIG_MENUPROMPT
 	printf(CONFIG_MENUPROMPT);
 #else
-	if (bootdelay >= 0)
-		printf("Hit any key to stop autoboot: %2d ", bootdelay);
+	printf("Hit any key to stop autoboot: %2d ", bootdelay);
 #endif
 
 	/*
 	 * Check if key already pressed
-	 * Don't check if bootdelay < 0
 	 */
-	if (bootdelay >= 0) {
-		if (tstc()) {	/* we got a key press	*/
-			(void) getc();  /* consume input	*/
-			puts("\b\b\b 0");
-			abort = 1;	/* don't auto boot	*/
-		}
+	if (tstc()) {	/* we got a key press	*/
+		(void) getc();  /* consume input	*/
+		puts("\b\b\b 0");
+		abort = 1;	/* don't auto boot	*/
 	}
 
 	while ((bootdelay > 0) && (!abort)) {
@@ -264,9 +257,10 @@  static int __abortboot(int bootdelay)
 
 static int abortboot(int bootdelay)
 {
-	int ret;
+	int ret = 0;
 
-	ret = __abortboot(bootdelay);
+	if (bootdelay >= 0)
+		ret = __abortboot(bootdelay);
 
 #ifdef CONFIG_SILENT_CONSOLE
 	if (abort)