diff options
author | Simon Glass <sjg@chromium.org> | 2024-11-02 11:49:42 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-12-18 15:18:59 -0600 |
commit | fc37a73e667916e15e01e0f9d189da792df2b351 (patch) | |
tree | dfbf6aa2fd3a9af4d7900f929d06ea753b009670 /arch/sandbox/cpu/cpu.c | |
parent | 447f18d00de80384df334acdbe5972762d3d1e1e (diff) |
fdt: Swap the signature for board_fdt_blob_setup()
This returns a devicetree and updates a parameter with an error code.
Swap it, since this fits better with the way U-Boot normally works. It
also (more easily) allows leaving the existing pointer unchanged.
No yaks were harmed in this change, but there is a very small code-size
reduction.
For sifive, the OF_BOARD option must be set for the function to be
called, so there is no point in checking it again. Also OF_SEPARATE is
defined always.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
[trini: Update total_compute]
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'arch/sandbox/cpu/cpu.c')
-rw-r--r-- | arch/sandbox/cpu/cpu.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c index d1c4dcf0764..6407193c5f1 100644 --- a/arch/sandbox/cpu/cpu.c +++ b/arch/sandbox/cpu/cpu.c @@ -368,7 +368,7 @@ static int setup_auto_tree(void *blob) return 0; } -void *board_fdt_blob_setup(int *ret) +int board_fdt_blob_setup(void **fdtp) { struct sandbox_state *state = state_get_current(); const char *fname = state->fdt_fname; @@ -378,43 +378,41 @@ void *board_fdt_blob_setup(int *ret) int fd; if (gd->fdt_blob) - return (void *)gd->fdt_blob; + return -EEXIST; blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0); - *ret = 0; if (!state->fdt_fname) { err = setup_auto_tree(blob); - if (!err) - goto done; - os_printf("Unable to create empty FDT: %s\n", fdt_strerror(err)); - *ret = -EINVAL; - goto fail; + if (err) { + os_printf("Unable to create empty FDT: %s\n", + fdt_strerror(err)); + return -EINVAL; + } + *fdtp = blob; + + return 0; } err = os_get_filesize(fname, &size); if (err < 0) { os_printf("Failed to find FDT file '%s'\n", fname); - *ret = err; - goto fail; + return err; } fd = os_open(fname, OS_O_RDONLY); if (fd < 0) { os_printf("Failed to open FDT file '%s'\n", fname); - *ret = -EACCES; - goto fail; + return -EACCES; } if (os_read(fd, blob, size) != size) { os_close(fd); os_printf("Failed to read FDT file '%s'\n", fname); - *ret = -EIO; - goto fail; + return -EIO; } os_close(fd); -done: - return blob; -fail: - return NULL; + *fdtp = blob; + + return 0; } ulong timer_get_boot_us(void) |