Skip to contentSkip to conversation

Improve logging on missing uclass

PATCH Superseded Julien Stephan 2 participants 9 messages Aug 6 – Aug 20

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Improve logging on missing uclass

While writing a MISC driver, I forgot to enable CONFIG_MISC. The only thing I got at boot was the following obscure error, with no hint about the root cause:

initcall_run_r(): initcall initr_dm() failed
### ERROR ### Please RESET the board ###

Commit 3346c87625b8 ("dm: Improve handling of a missing uclass") already tried to improve this case by returning a strange error code and adding a debug message. But since neither the debug message nor the return code are displayed by default, it was not very helpful in practice.

This series improves the situation in two ways:
- the missing uclass message is now logged at ERROR level, so it shows up by default;
- the initcall failure now prints the actual error code (and its string when ERRNO_STR is enabled), making the root cause easier to track down.

---
Julien Stephan (2):
dm: improve logging for missing uclass
initcall: display error code on error

 drivers/core/uclass.c | 5 +++--
 include/initcall.h    | 8 +++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

---
base-commit: f562ed02aa7ae4dc2775d90d2e6c40bab82e2715
change-id: 20260806-improve-logging-on-missing-uclass-a76c46acfa13

Best regards,

Signature · 1 line
Julien Stephan <[email protected]>
#1 lore raw

PATCH 1/2 dm: improve logging for missing uclass

When a uclass definition is missing for an enabled driver, the board cannot boot, and without any extra debug option enabled the following error is displayed:

initcall_run_r(): initcall initr_dm() failed ### ERROR ### Please RESET the board ###

There is a debug message using dm_warn(), which is not displayed by default. Since this is a fatal error preventing the board from booting, the log level should be at least ERROR.

---
 drivers/core/uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/core/uclass.c +3 -2
index 5365ac68f9e..be0159155f0 100644
@@ -60,8 +60,9 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
 	*ucp = NULL;
 	uc_drv = lists_uclass_lookup(id);
 	if (!uc_drv) {
-		dm_warn("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
-			id);
+		log(LOGC_DM, LOGL_ERR,
+		    "Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
+		    id);
 		/*
 		 * Use a strange error to make this case easier to find. When
 		 * a uclass is not available it can prevent driver model from
Signature · 1 line
2.54.0
#2 lore raw

Re: [PATCH 1/2] dm: improve logging for missing uclass

Hi Julien,

Quoted 20 lines · Julien Stephan

dm: improve logging for missing uclass

When a uclass definition is missing for an enabled driver, the board cannot boot, and without any extra debug option enabled the following error is displayed:

initcall_run_r(): initcall initr_dm() failed ### ERROR ### Please RESET the board ###

There is a debug message using dm_warn(), which is not displayed by default. Since this is a fatal error preventing the board from booting, the log level should be at least ERROR.

drivers/core/uclass.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)

drivers/core/uclass.c static int uclass_add(enum uclass_id id, struct uclass **ucp) · line 65

Quoted 8 lines
drivers/core/uclass.c +3 -2
@@ -60,8 +60,9 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
      *ucp = NULL;
      uc_drv = lists_uclass_lookup(id);
      if (!uc_drv) {
-             dm_warn("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
-                     id);
+             log(LOGC_DM, LOGL_ERR,
+                 "Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
+                 id);

This file sets LOG_CATEGORY to LOGC_DM at the top, so log_err() would be cleaner:

log_err("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

            id);

The idea with this was that by returning -EPFNOSUPPORT (unused elsewhere in U-Boot (he says...)) it would indicate this problem, without bloating the code with a large message. This code is used in SPL where code size is at a premium. I don't see the error number though, which I added here:

13123276806 initcall: Adjust the failure message and return value

Hmm yes it was dropped in the initcall move back to the header file.

We already have DM_WARN to help people with debugging, so perhaps instead we should just enable that by default in U-Boot proper?

Regards,
Simon

#3 lore raw

Re: [PATCH 1/2] dm: improve logging for missing uclass

Quoted 46 lines · Simon Glass

Hi Julien,

Quoted 20 lines · Julien Stephan

dm: improve logging for missing uclass

When a uclass definition is missing for an enabled driver, the board cannot boot, and without any extra debug option enabled the following error is displayed:

initcall_run_r(): initcall initr_dm() failed ### ERROR ### Please RESET the board ###

There is a debug message using dm_warn(), which is not displayed by default. Since this is a fatal error preventing the board from booting, the log level should be at least ERROR.

drivers/core/uclass.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)

drivers/core/uclass.c static int uclass_add(enum uclass_id id, struct uclass **ucp) · line 65

Quoted 8 lines
drivers/core/uclass.c +3 -2
@@ -60,8 +60,9 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
      *ucp = NULL;
      uc_drv = lists_uclass_lookup(id);
      if (!uc_drv) {
-             dm_warn("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
-                     id);
+             log(LOGC_DM, LOGL_ERR,
+                 "Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
+                 id);

This file sets LOG_CATEGORY to LOGC_DM at the top, so log_err() would be cleaner:

log_err("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

            id);

The idea with this was that by returning -EPFNOSUPPORT (unused elsewhere in U-Boot (he says...)) it would indicate this problem, without bloating the code with a large message. This code is used in SPL where code size is at a premium. I don't see the error number though, which I added here:

Quoted 7 lines

13123276806 initcall: Adjust the failure message and return value

Hmm yes it was dropped in the initcall move back to the header file.

We already have DM_WARN to help people with debugging, so perhaps instead we should just enable that by default in U-Boot proper?

Hi Simon,

I didn't think about the impact on SPL. I understand your point, but I do feel a fatal error deserves a proper message.

So what about reducing this long message to something shorter, using log_err() as you suggested:

log_err("uclass %d: no UCLASS_DRIVER()\n", id);

That keeps a readable, greppable hint while cutting most of the SPL size overhead.

I didn't audit all the dm_warn() callers, but enabling DM_WARN by default feels overkill. I suspect several of them are genuinely non-fatal warnings.

Otherwise, we could just drop this patch, since patch 2 now prints the -EPFNOSUPPORT value on failure.

What do you think?

Cheers,
Julien

Quoted 2 lines

Regards,
Simon

#4 lore raw

Re: [PATCH 1/2] dm: improve logging for missing uclass

Hi Julien,

Quoted 69 lines · Julien Stephan
Quoted 46 lines · Simon Glass

Hi Julien,

Quoted 20 lines · Julien Stephan

dm: improve logging for missing uclass

When a uclass definition is missing for an enabled driver, the board cannot boot, and without any extra debug option enabled the following error is displayed:

initcall_run_r(): initcall initr_dm() failed ### ERROR ### Please RESET the board ###

There is a debug message using dm_warn(), which is not displayed by default. Since this is a fatal error preventing the board from booting, the log level should be at least ERROR.

drivers/core/uclass.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)

drivers/core/uclass.c static int uclass_add(enum uclass_id id, struct uclass **ucp) · line 65

Quoted 8 lines
drivers/core/uclass.c +3 -2
@@ -60,8 +60,9 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
      *ucp = NULL;
      uc_drv = lists_uclass_lookup(id);
      if (!uc_drv) {
-             dm_warn("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
-                     id);
+             log(LOGC_DM, LOGL_ERR,
+                 "Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
+                 id);

This file sets LOG_CATEGORY to LOGC_DM at the top, so log_err() would be cleaner:

log_err("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

            id);

The idea with this was that by returning -EPFNOSUPPORT (unused elsewhere in U-Boot (he says...)) it would indicate this problem, without bloating the code with a large message. This code is used in SPL where code size is at a premium. I don't see the error number though, which I added here:

Quoted 7 lines

13123276806 initcall: Adjust the failure message and return value

Hmm yes it was dropped in the initcall move back to the header file.

We already have DM_WARN to help people with debugging, so perhaps instead we should just enable that by default in U-Boot proper?

Hi Simon,

I didn't think about the impact on SPL. I understand your point, but I do feel a fatal error deserves a proper message.

So what about reducing this long message to something shorter, using log_err() as you suggested:

log_err("uclass %d: no UCLASS_DRIVER()\n", id);

That keeps a readable, greppable hint while cutting most of the SPL size overhead.

Quoted 8 lines

I didn't audit all the dm_warn() callers, but enabling DM_WARN by default feels overkill. I suspect several of them are genuinely non-fatal warnings.

Otherwise, we could just drop this patch, since patch 2 now prints the -EPFNOSUPPORT value on failure.

What do you think?

I tend to agree that a message would be better. But any SPL growth is painful...perhaps we could have a Kconfig to control just this case (default y in TPL/SPL/Proper) so people can turn it off for production?

Regards,
SImon

#5 lore raw

Re: [PATCH 1/2] dm: improve logging for missing uclass

Quoted 80 lines · Simon Glass

Hi Julien,

Quoted 76 lines · Julien Stephan
Quoted 46 lines · Simon Glass

Hi Julien,

Quoted 20 lines · Julien Stephan

dm: improve logging for missing uclass

When a uclass definition is missing for an enabled driver, the board cannot boot, and without any extra debug option enabled the following error is displayed:

initcall_run_r(): initcall initr_dm() failed ### ERROR ### Please RESET the board ###

There is a debug message using dm_warn(), which is not displayed by default. Since this is a fatal error preventing the board from booting, the log level should be at least ERROR.

drivers/core/uclass.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)

drivers/core/uclass.c static int uclass_add(enum uclass_id id, struct uclass **ucp) · line 65

Quoted 8 lines
drivers/core/uclass.c +3 -2
@@ -60,8 +60,9 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
      *ucp = NULL;
      uc_drv = lists_uclass_lookup(id);
      if (!uc_drv) {
-             dm_warn("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
-                     id);
+             log(LOGC_DM, LOGL_ERR,
+                 "Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
+                 id);

This file sets LOG_CATEGORY to LOGC_DM at the top, so log_err() would be cleaner:

log_err("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

            id);

The idea with this was that by returning -EPFNOSUPPORT (unused elsewhere in U-Boot (he says...)) it would indicate this problem, without bloating the code with a large message. This code is used in SPL where code size is at a premium. I don't see the error number though, which I added here:

Quoted 7 lines

13123276806 initcall: Adjust the failure message and return value

Hmm yes it was dropped in the initcall move back to the header file.

We already have DM_WARN to help people with debugging, so perhaps instead we should just enable that by default in U-Boot proper?

Hi Simon,

I didn't think about the impact on SPL. I understand your point, but I do feel a fatal error deserves a proper message.

So what about reducing this long message to something shorter, using log_err() as you suggested:

log_err("uclass %d: no UCLASS_DRIVER()\n", id);

That keeps a readable, greppable hint while cutting most of the SPL size overhead.

I didn't audit all the dm_warn() callers, but enabling DM_WARN by default feels overkill. I suspect several of them are genuinely non-fatal warnings.

Otherwise, we could just drop this patch, since patch 2 now prints the -EPFNOSUPPORT value on failure.

Quoted 6 lines
Quoted 1 line

What do you think?

I tend to agree that a message would be better. But any SPL growth is painful...perhaps we could have a Kconfig to control just this case (default y in TPL/SPL/Proper) so people can turn it off for production?

Hi Simon,

Sorry for my late reply, I was on vacation last week.

I've been thinking about this, and here is my suggestion for you to review before I send a v2 (not tested yet): convert DM_WARN into a choice with DM_NONE / DM_ERR / DM_WARN to control the verbosity of driver model logs. Something like:

drivers/core/Kconfig (same for the SPL/TPL variants):

kconfig
choice
prompt "Driver model log verbosity"
depends on DM
default DM_ERR
help
Select which driver model messages are compiled into the binary. Each level includes the levels below it. Lower verbosity saves code size by compiling the message strings out (useful for production builds), while higher verbosity helps with debugging.

config DM_NONE
bool "No messages"
help
Compile out all driver model messages. This gives the smallest code size, but a fatal condition gives no hint about its root cause.

config DM_ERR
bool "Errors"
help
Emit driver model error messages via dm_err(), at ERROR level. These report fatal conditions that typically prevent the board from booting. Warnings are compiled out.

config DM_WARN
bool "Warnings and errors"
help
Emit driver model warnings via dm_warn() (WARNING level) in addition to errors. This is the most verbose and uses the most code space.

Warnings may help with debugging, such as when expected devices do not bind correctly.

endchoice

include/dm/util.h:

-#if CONFIG_IS_ENABLED(DM_WARN)
+#if CONFIG_IS_ENABLED(DM_WARN) /* warnings and errors */
#define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt)
-#else
+#define dm_err(fmt...) log(LOGC_DM, LOGL_ERR, ##fmt)
+#elif CONFIG_IS_ENABLED(DM_ERR) /* errors only */
+#define dm_warn(fmt...) log(LOGC_DM, LOGL_DEBUG, ##fmt) +#define dm_err(fmt...) log(LOGC_DM, LOGL_ERR, ##fmt)
+#else /* no messages */
#define dm_warn(fmt...) log(LOGC_DM, LOGL_DEBUG, ##fmt)
+#define dm_err(fmt...) log(LOGC_DM, LOGL_DEBUG, ##fmt)
#endif

This gives a reusable dm_err() mechanism, and existing dm_warn() callers keep working: nothing selects DM_WARN, there is no #ifdef CONFIG_DM_WARN in C (only the CONFIG_IS_ENABLED() above), and a choice member named DM_WARN is still =y when selected. Only one defconfig sets CONFIG_DM_WARN=y today, and it still resolves fine (I can refresh it as part of a v2).

One deliberate change: with default DM_ERR, driver model errors are now emitted by default, whereas today they are silent unless DM_WARN is enabled.

While working on this I also noticed that a DM_DEBUG symbol already exists, and it works completely differently: it adds -DDEBUG directly in drivers/core/Makefile (proper only), so it's orthogonal to which log strings get compiled in. My inclination is to leave DM_DEBUG as-is for now and keep this series focused on the NONE/ERR/WARN choice; folding it in as a top "debug" tier (and adding a dm_dbg()) could be a follow-up, since it would change DM_DEBUG's scope and touch the Makefile. Note that DM_DEBUG and DM_WARN also couldn't both be selected if it became a choice member.

So, what do you think? Is the DM_NONE / DM_ERR / DM_WARN choice the right direction? And does leaving DM_DEBUG out of it for now (as a possible follow-up) sound reasonable, or would you rather see it unified into the choice from the start?

Cheers,
Julien

Quoted 3 lines

Regards,
SImon

#6 lore raw

Re: [PATCH 1/2] dm: improve logging for missing uclass

Hi Julien,

Quoted 171 lines · Julien Stephan
Quoted 80 lines · Simon Glass

Hi Julien,

Quoted 76 lines · Julien Stephan
Quoted 46 lines · Simon Glass

Hi Julien,

Quoted 20 lines · Julien Stephan

dm: improve logging for missing uclass

When a uclass definition is missing for an enabled driver, the board cannot boot, and without any extra debug option enabled the following error is displayed:

initcall_run_r(): initcall initr_dm() failed ### ERROR ### Please RESET the board ###

There is a debug message using dm_warn(), which is not displayed by default. Since this is a fatal error preventing the board from booting, the log level should be at least ERROR.

drivers/core/uclass.c | 5 +++--

 1 file changed, 3 insertions(+), 2 deletions(-)

drivers/core/uclass.c static int uclass_add(enum uclass_id id, struct uclass **ucp) · line 65

Quoted 8 lines
drivers/core/uclass.c +3 -2
@@ -60,8 +60,9 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
      *ucp = NULL;
      uc_drv = lists_uclass_lookup(id);
      if (!uc_drv) {
-             dm_warn("Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
-                     id);
+             log(LOGC_DM, LOGL_ERR,
+                 "Cannot find uclass for id %d: please add the UCLASS_DRIVER() declaration for this UCLASS_... id\n",
+                 id);

This file sets LOG_CATEGORY to LOGC_DM at the top, so log_err() would be cleaner:

log_err("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

            id);

The idea with this was that by returning -EPFNOSUPPORT (unused elsewhere in U-Boot (he says...)) it would indicate this problem, without bloating the code with a large message. This code is used in SPL where code size is at a premium. I don't see the error number though, which I added here:

Quoted 7 lines

13123276806 initcall: Adjust the failure message and return value

Hmm yes it was dropped in the initcall move back to the header file.

We already have DM_WARN to help people with debugging, so perhaps instead we should just enable that by default in U-Boot proper?

Hi Simon,

I didn't think about the impact on SPL. I understand your point, but I do feel a fatal error deserves a proper message.

So what about reducing this long message to something shorter, using log_err() as you suggested:

log_err("uclass %d: no UCLASS_DRIVER()\n", id);

That keeps a readable, greppable hint while cutting most of the SPL size overhead.

I didn't audit all the dm_warn() callers, but enabling DM_WARN by default feels overkill. I suspect several of them are genuinely non-fatal warnings.

Otherwise, we could just drop this patch, since patch 2 now prints the -EPFNOSUPPORT value on failure.

Quoted 6 lines
Quoted 1 line

What do you think?

I tend to agree that a message would be better. But any SPL growth is painful...perhaps we could have a Kconfig to control just this case (default y in TPL/SPL/Proper) so people can turn it off for production?

Hi Simon,

Sorry for my late reply, I was on vacation last week.

I've been thinking about this, and here is my suggestion for you to review before I send a v2 (not tested yet): convert DM_WARN into a choice with DM_NONE / DM_ERR / DM_WARN to control the verbosity of driver model logs. Something like:

drivers/core/Kconfig (same for the SPL/TPL variants):

kconfig
choice
prompt "Driver model log verbosity"
depends on DM
default DM_ERR
help
Select which driver model messages are compiled into the binary. Each level includes the levels below it. Lower verbosity saves code size by compiling the message strings out (useful for production builds), while higher verbosity helps with debugging.

config DM_NONE
bool "No messages"
help
Compile out all driver model messages. This gives the smallest code size, but a fatal condition gives no hint about its root cause.

config DM_ERR
bool "Errors"
help
Emit driver model error messages via dm_err(), at ERROR level. These report fatal conditions that typically prevent the board from booting. Warnings are compiled out.

config DM_WARN
bool "Warnings and errors"
help
Emit driver model warnings via dm_warn() (WARNING level) in addition to errors. This is the most verbose and uses the most code space.

Warnings may help with debugging, such as when expected devices do not bind correctly.

endchoice

include/dm/util.h:

(quoted diff) +7 -2
-#if CONFIG_IS_ENABLED(DM_WARN)
+#if CONFIG_IS_ENABLED(DM_WARN)               /* warnings and errors */
 #define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt)
-#else
+#define dm_err(fmt...) log(LOGC_DM, LOGL_ERR, ##fmt)
+#elif CONFIG_IS_ENABLED(DM_ERR)              /* errors only */
+#define dm_warn(fmt...) log(LOGC_DM, LOGL_DEBUG, ##fmt)
+#define dm_err(fmt...) log(LOGC_DM, LOGL_ERR, ##fmt)
+#else                                        /* no messages */
 #define dm_warn(fmt...) log(LOGC_DM, LOGL_DEBUG, ##fmt)
+#define dm_err(fmt...) log(LOGC_DM, LOGL_DEBUG, ##fmt)
 #endif

This gives a reusable dm_err() mechanism, and existing dm_warn() callers keep working: nothing selects DM_WARN, there is no #ifdef CONFIG_DM_WARN in C (only the CONFIG_IS_ENABLED() above), and a choice member named DM_WARN is still =y when selected. Only one defconfig sets CONFIG_DM_WARN=y today, and it still resolves fine (I can refresh it as part of a v2).

One deliberate change: with default DM_ERR, driver model errors are now emitted by default, whereas today they are silent unless DM_WARN is enabled.

While working on this I also noticed that a DM_DEBUG symbol already exists, and it works completely differently: it adds -DDEBUG directly in drivers/core/Makefile (proper only), so it's orthogonal to which log strings get compiled in. My inclination is to leave DM_DEBUG as-is for now and keep this series focused on the NONE/ERR/WARN choice; folding it in as a top "debug" tier (and adding a dm_dbg()) could be a follow-up, since it would change DM_DEBUG's scope and touch the Makefile. Note that DM_DEBUG and DM_WARN also couldn't both be selected if it became a choice member.

Quoted 4 lines

So, what do you think? Is the DM_NONE / DM_ERR / DM_WARN choice the right direction? And does leaving DM_DEBUG out of it for now (as a possible follow-up) sound reasonable, or would you rather see it unified into the choice from the start?

This seems good to me. You might be able to de-duplicate your code to just select which LOGL value to use, with your dm_warn/err() macros then using that.

Regards,
Simon

#7 lore raw

PATCH 2/2 initcall: display error code on error

In reply to Julien Stephan

Currently when an initcall fails the error code is not displayed. Display it, along with the corresponding error string if ERRNO_STR is enabled.

---
 include/initcall.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
include/initcall.h +5 -3
index 220a55ad84d..f1f3c2fc088 100644
@@ -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)
Signature · 1 line
2.54.0
#8 lore raw

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

Hi Julien,

Quoted 16 lines · Julien Stephan

initcall: display error code on error

Currently when an initcall fails the error code is not displayed. Display it, along with the corresponding error string if ERRNO_STR is enabled.

include/initcall.h | 8 +++++---

 1 file changed, 5 insertions(+), 3 deletions(-)
include/initcall.h +0 -0
@@ -14,9 +15,10 @@ _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits");
 
 #define INITCALL(_call) \
      do { \

include/initcall.h _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits"); · line 24

Quoted 10 lines
include/initcall.h +4 -3
-             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)

When CONFIG_ERRNO_STR is disabled errno_str() returns an empty string, so this prints '... failed (err=-19: )' with a dangling ': '. There is a %dE which will print the error string if available.

include/initcall.h _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits"); · line 21

Quoted 12 lines
include/initcall.h +4 -3
@@ -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)); \

Since you are here, INITCALL_EVT() just below has the same problem - event_notify_null() returns an error code that would be equally useful. What do you think about giving it the same treatment in this patch?

Regards,
Simon