Hi Julien,

On 2026-08-06T13:05:19, Julien Stephan <[email protected]> wrote:
> 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.
>
> Signed-off-by: Julien Stephan <[email protected]>
>
> drivers/core/uclass.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

> diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
> @@ -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

Reply via email to