Skip to content
Snippets Groups Projects
Commit 8547f45b authored by Gary Bisson's avatar Gary Bisson Committed by Tom Rini
Browse files

cmd: sata: fix init command return value


Since commit aa6ab905, sata_initialize returns -1 if init_sata or
scan_sata fails. But this return value becomes the do_sata return
value which is equivalent to CMD_RET_USAGE.

In case one issues 'sata init' and that the hardware fails to
initialize, there's no need to display the command usage. Instead
the command shoud just return the CMD_RET_FAILURE value.

Fixes: aa6ab905 (sata: fix sata command can not being executed bug)

Signed-off-by: default avatarGary Bisson <gary.bisson@boundarydevices.com>
Reviewed-by: default avatarEric Nelson <eric@nelint.com>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
parent 7f73ca48
No related branches found
No related tags found
No related merge requests found
...@@ -28,14 +28,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ...@@ -28,14 +28,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (sata_curr_device != -1) if (sata_curr_device != -1)
sata_stop(); sata_stop();
return sata_initialize(); return (sata_initialize() < 0) ?
CMD_RET_FAILURE : CMD_RET_SUCCESS;
} }
/* If the user has not yet run `sata init`, do it now */ /* If the user has not yet run `sata init`, do it now */
if (sata_curr_device == -1) { if (sata_curr_device == -1) {
rc = sata_initialize(); rc = sata_initialize();
if (rc == -1) if (rc == -1)
return rc; return CMD_RET_FAILURE;
sata_curr_device = rc; sata_curr_device = rc;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment