[U-Boot] [RFC PATCH v2 09/15] main: Use autoconf for boot_delay code

Simon Glass sjg at chromium.org
Tue Feb 26 06:41:00 CET 2013


Hi Joe,

On Sun, Feb 24, 2013 at 12:40 PM, Joe Hershberger
<joe.hershberger at gmail.com> wrote:
> Hi Simon,
>
> On Sun, Feb 24, 2013 at 11:26 AM, Simon Glass <sjg at chromium.org> wrote:
>> Convert this function and its children to use autoconf instead of #ifdef.
>>
>> Some header files must now be included unconditionally, so remove some of
>> the #ifdefs from the header section, and put these header files into the
>> right order.
>>
>> Signed-off-by: Simon Glass <sjg at chromium.org>
>> ---
>> Changes in v2: None
>>
>>  common/main.c  | 104 +++++++++++++++++++++++----------------------------------
>>  include/menu.h |   2 --
>>  2 files changed, 41 insertions(+), 65 deletions(-)
>>
>> diff --git a/common/main.c b/common/main.c
>> index 4f11e58..a5d3f82 100644
>> --- a/common/main.c
>> +++ b/common/main.c
[snip]
>> @@ -258,7 +248,6 @@ static int abortboot(int bootdelay)
>>   * printing the error message to console.
>>   */
>>
>> -#ifdef CONFIG_OF_CONTROL
>>  static void secure_boot_cmd(char *cmd)
>>  {
>>         cmd_tbl_t *cmdtp;
>> @@ -311,93 +300,82 @@ static void process_fdt_options(const void *blob)
>>                             (void *)(autoconf_sys_text_base() + addr));
>>         }
>>  }
>> -#endif /* CONFIG_OF_CONTROL */
>>
>>  static void process_boot_delay(void)
>>  {
>> -#ifdef CONFIG_BOOTCOUNT_LIMIT
>>         unsigned long bootcount = 0;
>>         unsigned long bootlimit = 0;
>> -#endif /* CONFIG_BOOTCOUNT_LIMIT */
>> -#ifdef CONFIG_OF_CONTROL
>> -       char *env;
>> -#endif
>> -       char *s;
>> +       const char *s;
>>         int bootdelay;
>>
>> -#ifdef CONFIG_BOOTCOUNT_LIMIT
>> -       bootcount = bootcount_load();
>> -       bootcount++;
>> -       bootcount_store (bootcount);
>> -       setenv_ulong("bootcount", bootcount);
>> -       bootlimit = getenv_ulong("bootlimit", 10, 0);
>> -#endif /* CONFIG_BOOTCOUNT_LIMIT */
>> +       if (autoconf_bootcount_limit()) {
>> +               bootcount = bootcount_load();
>> +               bootcount++;
>> +               bootcount_store(bootcount);
>> +               setenv_ulong("bootcount", bootcount);
>> +               bootlimit = getenv_ulong("bootlimit", 10, 0);
>> +       }
>>
>>         s = getenv ("bootdelay");
>>         bootdelay = s ? (int)simple_strtol(s, NULL, 10) : autoconf_bootdelay();
>
> This would look a lot nicer as:
>    bootdelay = getenv_ulong_def("bootdelay", autoconf_bootdelay());

Yes of course, thank you.

[snip]

Regards,
Simon


More information about the U-Boot mailing list