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>
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index d1c4dcf..6407193 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -368,7 +368,7 @@
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 @@
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)