diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2023-05-02 13:13:29 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-05-22 13:29:46 +0200 |
commit | ee1da2710f85ea560dd206ef4b6fddc56bde4535 (patch) | |
tree | d1dd2bb2c1ac6e42bd4c9aa14fddc7370684b17f /common/efi | |
parent | d62d399630e24c76cb90e8a19d7e7b95d72258b6 (diff) | |
download | barebox-ee1da2710f85ea560dd206ef4b6fddc56bde4535.tar.gz barebox-ee1da2710f85ea560dd206ef4b6fddc56bde4535.tar.xz |
of: add function to read a file as unflattened device tree
There are several places in the tree that read in a dtb file
and unflatten it. Add a of_read_file() helper function for that
and use it where appropriately.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/efi')
-rw-r--r-- | common/efi/payload/init.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/common/efi/payload/init.c b/common/efi/payload/init.c index 3ee5d66d60..b990b54b26 100644 --- a/common/efi/payload/init.c +++ b/common/efi/payload/init.c @@ -322,31 +322,15 @@ static int efi_late_init(void) state_desc = xasprintf("/boot/EFI/barebox/state.dtb"); if (state_desc) { - void *fdt; - size_t size; struct device_node *root = NULL; struct device_node *np = NULL; struct state *state; - fdt = read_file(state_desc, &size); - if (!fdt) { - pr_err("unable to read %s: %s\n", state_desc, - strerror(errno)); - return -errno; - } - - if (file_detect_type(fdt, size) != filetype_oftree) { - pr_err("%s is not an oftree file.\n", state_desc); - free(fdt); - return -EINVAL; - } - - root = of_unflatten_dtb(fdt, size); - - free(fdt); - - if (IS_ERR(root)) + root = of_read_file(state_desc); + if (IS_ERR(root)) { + printf("Cannot open %s: %pe\n", state_desc, root); return PTR_ERR(root); + } ret = barebox_register_of(root); if (ret) |