MLK-14930-1 cmd: sata: Fix sata init and stop issue

When sata stop is executed, the sata_curr_device is not reset to -1, so
any following sata commands will not initialize the sata again and cause
problem.

Additional, in sata init implementation, the sata_curr_device should be updated,
otherwise sata will be initialized again when doing other sata commands like
read/write/info/part/device.

Signed-off-by: Ye Li <ye.li@nxp.com>
This commit is contained in:
Ye Li 2018-03-27 00:56:19 -07:00
parent 8cca3efba0
commit 9bccfd01c6
1 changed files with 8 additions and 2 deletions

View File

@ -91,8 +91,10 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (argc == 3)
devnum = (int)simple_strtoul(argv[2], NULL, 10);
if (!strcmp(argv[1], "stop"))
if (!strcmp(argv[1], "stop")) {
sata_curr_device = -1;
return sata_remove(devnum);
}
if (!strcmp(argv[1], "init")) {
if (sata_curr_device != -1) {
@ -101,7 +103,11 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return rc;
}
return sata_probe(devnum);
rc = sata_probe(devnum);
if (rc < 0)
return CMD_RET_FAILURE;
sata_curr_device = rc;
return CMD_RET_SUCCESS;
}
}