[PATCH v2 010/113] of: don't report failure to of_read_file twice

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Mar 4 10:58:55 PST 2024


of_read_file already prints to log messages when it fails, so
duplicating the error message in the caller is needlessly verbose.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 commands/of_diff.c            | 5 ++---
 commands/of_display_timings.c | 4 +---
 commands/of_overlay.c         | 4 +---
 commands/oftree.c             | 4 +---
 drivers/of/overlay.c          | 4 +---
 efi/payload/init.c            | 4 +---
 6 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/commands/of_diff.c b/commands/of_diff.c
index 8b19c093ddab..623b033c7323 100644
--- a/commands/of_diff.c
+++ b/commands/of_diff.c
@@ -19,15 +19,14 @@ static struct device_node *get_tree(const char *filename, struct device_node *ro
 
 	if (!strcmp(filename, "-")) {
 		node = of_dup(root) ?: ERR_PTR(-ENOENT);
+		if (IS_ERR(node))
+			printf("Cannot duplicate live tree: %pe\n", node);
 	} else if (!strcmp(filename, "+")) {
 		return NULL;
 	} else {
 		node = of_read_file(filename);
 	}
 
-	if (IS_ERR(node))
-		printf("Cannot read %s: %pe\n", filename, node);
-
 	return node;
 }
 
diff --git a/commands/of_display_timings.c b/commands/of_display_timings.c
index 4cc79ec88d7e..232074fce786 100644
--- a/commands/of_display_timings.c
+++ b/commands/of_display_timings.c
@@ -68,10 +68,8 @@ static int do_of_display_timings(int argc, char *argv[])
 	/* Check if external dtb given */
 	if (dtbfile) {
 		root = of_read_file(dtbfile);
-		if (IS_ERR(root)) {
-			printf("Cannot open %s: %pe\n", dtbfile, root);
+		if (IS_ERR(root))
 			return PTR_ERR(root);
-		}
 	} else {
 		root = of_get_root_node();
 	}
diff --git a/commands/of_overlay.c b/commands/of_overlay.c
index fda9115a8201..2013c4b27867 100644
--- a/commands/of_overlay.c
+++ b/commands/of_overlay.c
@@ -36,10 +36,8 @@ static int do_of_overlay(int argc, char *argv[])
 	}
 
 	overlay = of_read_file(argv[optind]);
-	if (IS_ERR(overlay)) {
-		printf("Cannot open %s: %pe\n", argv[optind], overlay);
+	if (IS_ERR(overlay))
 		return PTR_ERR(overlay);
-	}
 
 	if (live_tree) {
 		ret = of_overlay_apply_tree(of_get_root_node(), overlay);
diff --git a/commands/oftree.c b/commands/oftree.c
index 7b12c86e1dc3..76227a10b033 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -76,10 +76,8 @@ static int do_oftree(int argc, char *argv[])
 
 	if (load) {
 		root = of_read_file(load);
-		if (IS_ERR(root)) {
-			printf("Cannot open %s: %pe\n", load, root);
+		if (IS_ERR(root))
 			return PTR_ERR(root);
-		}
 
 		ret = of_set_root_node(root);
 		if (ret) {
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 2d2367fc101b..73c7a91db9b5 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -315,10 +315,8 @@ int of_overlay_apply_file(struct device_node *root, const char *filename,
 		return 0;
 
 	ovl = of_read_file(filename);
-	if (IS_ERR(ovl)) {
-		pr_err("Failed to unflatten %s: %pe\n", filename, ovl);
+	if (IS_ERR(ovl))
 		return PTR_ERR(ovl);
-	}
 
 	if (filter && !of_overlay_matches_filter(NULL, ovl))
 		return 0;
diff --git a/efi/payload/init.c b/efi/payload/init.c
index bb4c156d686d..6e5ddfd22beb 100644
--- a/efi/payload/init.c
+++ b/efi/payload/init.c
@@ -400,10 +400,8 @@ static int efi_late_init(void)
 		struct state *state;
 
 		root = of_read_file(state_desc);
-		if (IS_ERR(root)) {
-			printf("Cannot open %s: %pe\n", state_desc, root);
+		if (IS_ERR(root))
 			return PTR_ERR(root);
-		}
 
 		ret = barebox_register_of(root);
 		if (ret)
-- 
2.39.2




More information about the barebox mailing list