aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-08-21 21:16:51 -0600
committerTom Rini <trini@konsulko.com>2023-08-31 13:16:54 -0400
commit468e372e9ad4c551d513b2e73c1f5c1cbb2e4097 (patch)
tree0289b3ca2c7773b9b33c0f33c9553f80aa2eac86
parent7d2e23394ffbbc1d5b5f2479e0c52db52907cc40 (diff)
downloadu-boot-468e372e9ad4c551d513b2e73c1f5c1cbb2e4097.tar.gz
initcall: Adjust the loop logic
Use a variable to hold the function, so we don't need to repeat the pointer access each time. Rename the init pointer to 'ptr' since we only refer to it in the for() statement now. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--lib/initcall.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/initcall.c b/lib/initcall.c
index 89a68b2444f..81c5d245073 100644
--- a/lib/initcall.c
+++ b/lib/initcall.c
@@ -33,25 +33,25 @@ static ulong calc_reloc_ofs(void)
int initcall_run_list(const init_fnc_t init_sequence[])
{
ulong reloc_ofs = calc_reloc_ofs();
- const init_fnc_t *init_fnc_ptr;
+ const init_fnc_t *ptr;
+ init_fnc_t func;
+ int ret = 0;
- for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
- int ret;
-
- if (reloc_ofs)
+ for (ptr = init_sequence; func = *ptr, !ret && func; ptr++) {
+ if (reloc_ofs) {
debug("initcall: %p (relocated to %p)\n",
- (char *)*init_fnc_ptr - reloc_ofs,
- (char *)*init_fnc_ptr);
- else
- debug("initcall: %p\n", (char *)*init_fnc_ptr - reloc_ofs);
+ (char *)func - reloc_ofs, func);
+ } else {
+ debug("initcall: %p\n", (char *)func - reloc_ofs);
+ }
- ret = (*init_fnc_ptr)();
+ ret = func();
if (ret) {
printf("initcall sequence %p failed at call %p (err=%d)\n",
- init_sequence,
- (char *)*init_fnc_ptr - reloc_ofs, ret);
+ init_sequence, (char *)func - reloc_ofs, ret);
return -1;
}
}
+
return 0;
}