[PATCH 011/112] efi: payload: make missing state reporting less verbose
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jan 3 10:11:31 PST 2024
A non-existing state may not be a problem if barebox state is unused.
An error message is printed in that case inside of_read_file and failing
the initcall results in a second error message, which is annoying.
Change this to only print an info message and move along.
of_unflatten_dtb() will report errors to parse the file on its own.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
efi/payload/init.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/efi/payload/init.c b/efi/payload/init.c
index caab28741cc5..b0612276654e 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -385,28 +385,31 @@ postcore_initcall(efi_postcore_init);
static int efi_late_init(void)
{
- char *state_desc;
+ const char *state_desc = "/boot/EFI/barebox/state.dtb";
+ struct device_node *state_root = NULL;
+ size_t size;
+ void *fdt;
int ret;
if (!IS_ENABLED(CONFIG_STATE))
return 0;
- state_desc = xasprintf("/boot/EFI/barebox/state.dtb");
+ fdt = read_file(state_desc, &size);
+ if (!fdt) {
+ pr_info("unable to read %s: %m\n", state_desc);
+ return 0;
+ }
- if (state_desc) {
- struct device_node *root = NULL;
+ state_root = of_unflatten_dtb(fdt, size);
+ if (!IS_ERR(state_root)) {
struct device_node *np = NULL;
struct state *state;
- root = of_read_file(state_desc);
- if (IS_ERR(root))
- return PTR_ERR(root);
-
- ret = barebox_register_of(root);
+ ret = barebox_register_of(state_root);
if (ret)
pr_warn("Failed to register device-tree: %pe\n", ERR_PTR(ret));
- np = of_find_node_by_alias(root, "state");
+ np = of_find_node_by_alias(state_root, "state");
state = state_new_from_node(np, false);
if (IS_ERR(state))
--
2.39.2
More information about the barebox
mailing list