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>
{
int rc = 0;
- if (argc == 2 && strcmp(argv[1], "stop") == 0)
+ if (argc == 2 && strcmp(argv[1], "stop") == 0) {
+ sata_curr_device = -1;
return sata_stop();
+ }
if (argc == 2 && strcmp(argv[1], "init") == 0) {
if (sata_curr_device != -1)
sata_stop();
- return (sata_initialize() < 0) ?
- CMD_RET_FAILURE : CMD_RET_SUCCESS;
+ rc = sata_initialize();
+ if (rc == -1)
+ return CMD_RET_FAILURE;
+
+ sata_curr_device = rc;
+ return CMD_RET_SUCCESS;
}
/* If the user has not yet run `sata init`, do it now */