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

Reply via email to