diff options
author | Ye Li <ye.li@nxp.com> | 2018-03-27 00:56:19 -0700 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2020-04-26 23:24:19 -0700 |
commit | aefaf1b93a578da133c017c21758ef8bfcd1b009 (patch) | |
tree | 304503619fefe4731af95fa62b4dd72964e39373 /cmd | |
parent | 10500f4f6905c2d606e648f2deb1c2745bf75823 (diff) |
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>
(cherry picked from commit 9bccfd01c618a5d059f332c000c42e5bf39880d9)
(cherry picked from commit f162bbb14b5c9b0c4073eee5ceeea6a9d1780394)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/sata.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cmd/sata.c b/cmd/sata.c index 6bdb516cb5..6f9bc93ba3 100644 --- a/cmd/sata.c +++ b/cmd/sata.c @@ -87,8 +87,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) { @@ -97,7 +99,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; } } |