[PATCH 2/2] initcall: display error code on error

Julien Stephan <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <20260806-improve-logging-on-missing-uclass-v1-2-d477f0054f48@baylibre.com>
Currently when an initcall fails the error code is not displayed.
Display it, along with the corresponding error string if ERRNO_STR is
enabled.

Signed-off-by: Julien Stephan <[email protected]>
---
 include/initcall.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/initcall.h b/include/initcall.h
index 220a55ad84d..f1f3c2fc088 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -7,6 +7,7 @@
 #define __INITCALL_H
 
 #include <asm/types.h>
+#include <errno.h>
 #include <event.h>
 #include <hang.h>
 
@@ -14,9 +15,10 @@ _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits");
 
 #define INITCALL(_call) \
 	do { \
-		if (_call()) { \
-			printf("%s(): initcall %s() failed\n", __func__, \
-			       #_call); \
+		int _ret = _call(); \
+		if (_ret) { \
+			printf("%s(): initcall %s() failed (err=%d: %s)\n", \
+			       __func__, #_call, _ret, errno_str(_ret)); \
 			hang(); \
 		} \
 	} while (0)

-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.