[PATCH v2 3/3] initcall: initcall_evt: display error code on error

Julien Stephan <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <20260824-improve-logging-on-missing-uclass-v2-3-4bee2cdff72b@baylibre.com>
Currently when an initcall/initcall_evt 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 | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/initcall.h b/include/initcall.h
index 220a55ad84d..12e5235f506 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -14,18 +14,20 @@ _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=%dE)\n", \
+			       __func__, #_call, _ret); \
 			hang(); \
 		} \
 	} while (0)
 
 #define INITCALL_EVT(_evt) \
 	do { \
-		if (event_notify_null(_evt)) { \
-			printf("%s(): event %d/%s failed\n", __func__, _evt, \
-			       event_type_name(_evt)) ; \
+		int _ret = event_notify_null(_evt); \
+		if (_ret) { \
+			printf("%s(): event %d/%s failed (err=%dE)\n", \
+			       __func__, _evt, event_type_name(_evt), _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.