Commit 1364a0e48a64a29930a8b22620f420e8f4984cc7
Committed by
Tom Rini
1 parent
9272a9b4f6
Exists in
v2017.01-smarct4x
and in
40 other branches
Simplify the main loop
The main loop is easier to follow if the code is grouped into separate functions. Make this change, so that main_loop() is easier to read. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 32 additions and 27 deletions Side-by-side Diff
common/main.c
... | ... | @@ -22,20 +22,8 @@ |
22 | 22 | void inline __show_boot_progress (int val) {} |
23 | 23 | void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); |
24 | 24 | |
25 | -void main_loop(void) | |
25 | +static void modem_init(void) | |
26 | 26 | { |
27 | -#ifdef CONFIG_PREBOOT | |
28 | - char *p; | |
29 | -#endif | |
30 | - | |
31 | - bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); | |
32 | - | |
33 | -#ifndef CONFIG_SYS_GENERIC_BOARD | |
34 | - puts("Warning: Your board does not use generic board. Please read\n"); | |
35 | - puts("doc/README.generic-board and take action. Boards not\n"); | |
36 | - puts("upgraded by the late 2014 may break or be removed.\n"); | |
37 | -#endif | |
38 | - | |
39 | 27 | #ifdef CONFIG_MODEM_SUPPORT |
40 | 28 | debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init); |
41 | 29 | if (gd->do_mdm_init) { |
42 | 30 | |
43 | 31 | |
... | ... | @@ -46,22 +34,13 @@ |
46 | 34 | mdm_init(); /* wait for modem connection */ |
47 | 35 | } |
48 | 36 | #endif /* CONFIG_MODEM_SUPPORT */ |
37 | +} | |
49 | 38 | |
50 | -#ifdef CONFIG_VERSION_VARIABLE | |
51 | - { | |
52 | - setenv("ver", version_string); /* set version variable */ | |
53 | - } | |
54 | -#endif /* CONFIG_VERSION_VARIABLE */ | |
55 | - | |
56 | -#ifdef CONFIG_SYS_HUSH_PARSER | |
57 | - u_boot_hush_start(); | |
58 | -#endif | |
59 | - | |
60 | -#if defined(CONFIG_HUSH_INIT_VAR) | |
61 | - hush_init_var(); | |
62 | -#endif | |
63 | - | |
39 | +static void run_preboot_environment_command(void) | |
40 | +{ | |
64 | 41 | #ifdef CONFIG_PREBOOT |
42 | + char *p; | |
43 | + | |
65 | 44 | p = getenv("preboot"); |
66 | 45 | if (p != NULL) { |
67 | 46 | # ifdef CONFIG_AUTOBOOT_KEYED |
... | ... | @@ -75,6 +54,32 @@ |
75 | 54 | # endif |
76 | 55 | } |
77 | 56 | #endif /* CONFIG_PREBOOT */ |
57 | +} | |
58 | + | |
59 | +void main_loop(void) | |
60 | +{ | |
61 | + bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); | |
62 | + | |
63 | +#ifndef CONFIG_SYS_GENERIC_BOARD | |
64 | + puts("Warning: Your board does not use generic board. Please read\n"); | |
65 | + puts("doc/README.generic-board and take action. Boards not\n"); | |
66 | + puts("upgraded by the late 2014 may break or be removed.\n"); | |
67 | +#endif | |
68 | + | |
69 | + modem_init(); | |
70 | +#ifdef CONFIG_VERSION_VARIABLE | |
71 | + setenv("ver", version_string); /* set version variable */ | |
72 | +#endif /* CONFIG_VERSION_VARIABLE */ | |
73 | + | |
74 | +#ifdef CONFIG_SYS_HUSH_PARSER | |
75 | + u_boot_hush_start(); | |
76 | +#endif | |
77 | + | |
78 | +#if defined(CONFIG_HUSH_INIT_VAR) | |
79 | + hush_init_var(); | |
80 | +#endif | |
81 | + | |
82 | + run_preboot_environment_command(); | |
78 | 83 | |
79 | 84 | #if defined(CONFIG_UPDATE_TFTP) |
80 | 85 | update_tftp(0UL); |