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

Julien Stephan <[email protected]> Thu, 06 Aug 2026 15:05:20 +0200
Newsgroups gmane.comp.boot-loaders.u-boot
Message-ID <20260806-improve-logging-on-missing-uclass-v1-2-d477f0054f48__4872.82445408113$1786021546$gmane$org@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