diff mbox

[U-Boot,RFC,v2,04/15] main: Separate out the two abortboot() functions

Message ID 1361726773-18639-5-git-send-email-sjg@chromium.org
State Superseded, archived
Headers show

Commit Message

Simon Glass Feb. 24, 2013, 5:26 p.m. UTC
There are two implementations of autoboot(). Turn these into two separate
functions, and create a single autoboot() which calls either one or the
other.

Also it seems that nothing uses autoboot() outside main, so make it static.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
Changes in v2: None

 common/main.c    | 22 ++++++++++------------
 include/common.h |  3 ---
 2 files changed, 10 insertions(+), 15 deletions(-)

Comments

Joe Hershberger Feb. 24, 2013, 8:13 p.m. UTC | #1
Hi Simon,

On Sun, Feb 24, 2013 at 11:26 AM, Simon Glass <sjg@chromium.org> wrote:
> There are two implementations of autoboot(). Turn these into two separate
> functions, and create a single autoboot() which calls either one or the
> other.
>
> Also it seems that nothing uses autoboot() outside main, so make it static.

You say "autoboot" in this change log, but I think you mean to say "abortboot".

>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in v2: None
>
>  common/main.c    | 22 ++++++++++------------
>  include/common.h |  3 ---
>  2 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/common/main.c b/common/main.c
> index 2b8af2c..1e12e55 100644
> --- a/common/main.c
> +++ b/common/main.c
> @@ -92,11 +92,7 @@ extern void mdm_init(void); /* defined in board.c */
>   * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
>   */
>  #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
> -# if defined(CONFIG_AUTOBOOT_KEYED)
> -#ifndef CONFIG_MENU
> -static inline
> -#endif
> -int abortboot(int bootdelay)
> +static int abortboot_keyed(int bootdelay)
>  {
>         int abort = 0;
>         uint64_t etime = endtick(bootdelay);
> @@ -209,16 +205,11 @@ int abortboot(int bootdelay)
>         return abort;
>  }
>
> -# else /* !defined(CONFIG_AUTOBOOT_KEYED) */
> -
>  #ifdef CONFIG_MENUKEY
>  static int menukey = 0;
>  #endif
>
> -#ifndef CONFIG_MENU
> -static inline
> -#endif
> -int abortboot(int bootdelay)
> +static int abortboot_normal(int bootdelay)
>  {
>         int abort = 0;
>         unsigned long ts;
> @@ -274,7 +265,14 @@ int abortboot(int bootdelay)
>
>         return abort;
>  }
> -# endif        /* CONFIG_AUTOBOOT_KEYED */
> +
> +static int abortboot(int bootdelay)
> +{
> +       if (autoconf_autoboot_keyed())
> +               return abortboot_keyed(bootdelay);
> +       else
> +               return abortboot_normal(bootdelay);
> +}
>  #endif /* CONFIG_BOOTDELAY >= 0  */
>
>  /*
> diff --git a/include/common.h b/include/common.h
> index 491783b..fb219fd 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -297,9 +297,6 @@ int readline_into_buffer(const char *const prompt, char *buffer,
>  int    parse_line (char *, char *[]);
>  void   init_cmd_timeout(void);
>  void   reset_cmd_timeout(void);
> -#ifdef CONFIG_MENU
> -int    abortboot(int bootdelay);
> -#endif

Is CONFIG_MENU gone at this point?  Does it no longer reference abortboot()?

>  extern char console_buffer[];
>
>  /* arch/$(ARCH)/lib/board.c */
> --
> 1.8.1.3
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot


Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Simon Glass Feb. 26, 2013, 5:37 a.m. UTC | #2
Hi Joe,

On Sun, Feb 24, 2013 at 12:13 PM, Joe Hershberger
<joe.hershberger@gmail.com> wrote:
> Hi Simon,
>
> On Sun, Feb 24, 2013 at 11:26 AM, Simon Glass <sjg@chromium.org> wrote:
>> There are two implementations of autoboot(). Turn these into two separate
>> functions, and create a single autoboot() which calls either one or the
>> other.
>>
>> Also it seems that nothing uses autoboot() outside main, so make it static.
>
> You say "autoboot" in this change log, but I think you mean to say "abortboot".

Yes, will fix, thanks.

>
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>> Changes in v2: None
>>
>>  common/main.c    | 22 ++++++++++------------
>>  include/common.h |  3 ---
>>  2 files changed, 10 insertions(+), 15 deletions(-)
>>
>> diff --git a/common/main.c b/common/main.c
>> index 2b8af2c..1e12e55 100644
>> --- a/common/main.c
>> +++ b/common/main.c
>> @@ -92,11 +92,7 @@ extern void mdm_init(void); /* defined in board.c */
>>   * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
>>   */
>>  #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
>> -# if defined(CONFIG_AUTOBOOT_KEYED)
>> -#ifndef CONFIG_MENU
>> -static inline
>> -#endif
>> -int abortboot(int bootdelay)
>> +static int abortboot_keyed(int bootdelay)
>>  {
>>         int abort = 0;
>>         uint64_t etime = endtick(bootdelay);
>> @@ -209,16 +205,11 @@ int abortboot(int bootdelay)
>>         return abort;
>>  }
>>
>> -# else /* !defined(CONFIG_AUTOBOOT_KEYED) */
>> -
>>  #ifdef CONFIG_MENUKEY
>>  static int menukey = 0;
>>  #endif
>>
>> -#ifndef CONFIG_MENU
>> -static inline
>> -#endif
>> -int abortboot(int bootdelay)
>> +static int abortboot_normal(int bootdelay)
>>  {
>>         int abort = 0;
>>         unsigned long ts;
>> @@ -274,7 +265,14 @@ int abortboot(int bootdelay)
>>
>>         return abort;
>>  }
>> -# endif        /* CONFIG_AUTOBOOT_KEYED */
>> +
>> +static int abortboot(int bootdelay)
>> +{
>> +       if (autoconf_autoboot_keyed())
>> +               return abortboot_keyed(bootdelay);
>> +       else
>> +               return abortboot_normal(bootdelay);
>> +}
>>  #endif /* CONFIG_BOOTDELAY >= 0  */
>>
>>  /*
>> diff --git a/include/common.h b/include/common.h
>> index 491783b..fb219fd 100644
>> --- a/include/common.h
>> +++ b/include/common.h
>> @@ -297,9 +297,6 @@ int readline_into_buffer(const char *const prompt, char *buffer,
>>  int    parse_line (char *, char *[]);
>>  void   init_cmd_timeout(void);
>>  void   reset_cmd_timeout(void);
>> -#ifdef CONFIG_MENU
>> -int    abortboot(int bootdelay);
>> -#endif
>
> Is CONFIG_MENU gone at this point?  Does it no longer reference abortboot()?

Well it isn't needed in this file. In fact it seems since commit
8594753b this code is not needed any more.

>
>>  extern char console_buffer[];
>>
>>  /* arch/$(ARCH)/lib/board.c */
>> --
>> 1.8.1.3
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot@lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
>
>
> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>

Regards,
Simon
diff mbox

Patch

diff --git a/common/main.c b/common/main.c
index 2b8af2c..1e12e55 100644
--- a/common/main.c
+++ b/common/main.c
@@ -92,11 +92,7 @@  extern void mdm_init(void); /* defined in board.c */
  * returns: 0 -  no key string, allow autoboot 1 - got key string, abort
  */
 #if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
-# if defined(CONFIG_AUTOBOOT_KEYED)
-#ifndef CONFIG_MENU
-static inline
-#endif
-int abortboot(int bootdelay)
+static int abortboot_keyed(int bootdelay)
 {
 	int abort = 0;
 	uint64_t etime = endtick(bootdelay);
@@ -209,16 +205,11 @@  int abortboot(int bootdelay)
 	return abort;
 }
 
-# else	/* !defined(CONFIG_AUTOBOOT_KEYED) */
-
 #ifdef CONFIG_MENUKEY
 static int menukey = 0;
 #endif
 
-#ifndef CONFIG_MENU
-static inline
-#endif
-int abortboot(int bootdelay)
+static int abortboot_normal(int bootdelay)
 {
 	int abort = 0;
 	unsigned long ts;
@@ -274,7 +265,14 @@  int abortboot(int bootdelay)
 
 	return abort;
 }
-# endif	/* CONFIG_AUTOBOOT_KEYED */
+
+static int abortboot(int bootdelay)
+{
+	if (autoconf_autoboot_keyed())
+		return abortboot_keyed(bootdelay);
+	else
+		return abortboot_normal(bootdelay);
+}
 #endif	/* CONFIG_BOOTDELAY >= 0  */
 
 /*
diff --git a/include/common.h b/include/common.h
index 491783b..fb219fd 100644
--- a/include/common.h
+++ b/include/common.h
@@ -297,9 +297,6 @@  int	readline_into_buffer(const char *const prompt, char *buffer,
 int	parse_line (char *, char *[]);
 void	init_cmd_timeout(void);
 void	reset_cmd_timeout(void);
-#ifdef CONFIG_MENU
-int	abortboot(int bootdelay);
-#endif
 extern char console_buffer[];
 
 /* arch/$(ARCH)/lib/board.c */