[PATCH 2/4] cmd: i3c: fix list and current needing pre-selected controller
Maniyam, Dinesh
dinesh.maniyam at altera.com
Fri Jul 3 04:35:01 CEST 2026
Hi Thilak,
On 1/7/2026 6:27 pm, Pranav Tilak wrote:
> [CAUTION: This email is from outside your organization. Unless you trust the sender, do not click on links or open attachments as it may be a fraudulent email attempting to steal your information and/or compromise your computer.]
>
> The !currdev guard in do_i3c() was placed before the list and current
> handlers, causing both to fail when no controller is pre-selected.
> Move the guard to only protect device_list, write and read which
> actually need a controller.
>
> Fixes: b875409da737 ("cmd: Add i3c command support.")
> Signed-off-by: Pranav Tilak <pranav.vinaytilak at amd.com>
> ---
> cmd/i3c.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/cmd/i3c.c b/cmd/i3c.c
> index 08957f4d447..ba99a937990 100644
> --- a/cmd/i3c.c
> +++ b/cmd/i3c.c
> @@ -240,16 +240,17 @@ static int do_i3c(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
> if (!is_i3c_subcommand(subcmd))
> return handle_i3c_select(subcmd);
>
> + if (!strcmp(subcmd, "list"))
> + return handle_i3c_list();
> + else if (!strcmp(subcmd, "current"))
> + return handle_i3c_current();
> +
> if (!currdev) {
> printf("i3c: No I3C controller selected\n");
> return CMD_RET_FAILURE;
> }
>
> - if (!strcmp(subcmd, "list"))
> - return handle_i3c_list();
> - else if (!strcmp(subcmd, "current"))
> - return handle_i3c_current();
> - else if (!strcmp(subcmd, "device_list"))
> + if (!strcmp(subcmd, "device_list"))
> return handle_i3c_device_list();
> else if (!strcmp(subcmd, "write"))
> return handle_i3c_write(argc, argv);
> --
> 2.43.0
>
The fix is correct. handle_i3c_list() enumerates the UCLASS_I3C devices and never touches currdev, and handle_i3c_current() already handles the !currdev case itself ("No current controller selected"), so gating both behind the guard was wrong. write/read also keep their own internal !currdev checks, so nothing is weakened by moving the guard down.
Reviewed-by: Dinesh Maniyam dinesh.maniyam at altera.com
More information about the U-Boot
mailing list