From a52efe725cc4c2a032660965f7aeabb1aec1f61d Mon Sep 17 00:00:00 2001 From: Ye Li Date: Tue, 27 Mar 2018 00:56:19 -0700 Subject: [PATCH] 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 (cherry picked from commit 9bccfd01c618a5d059f332c000c42e5bf39880d9) (cherry picked from commit f162bbb14b5c9b0c4073eee5ceeea6a9d1780394) (cherry picked from commit 1707f011d5c79ae0f32b50ecf87f8aaed94944d0) --- cmd/sata.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/sata.c b/cmd/sata.c index aa396c1bbd..e0106f871a 100644 --- a/cmd/sata.c +++ b/cmd/sata.c @@ -89,8 +89,10 @@ static int do_sata(struct cmd_tbl *cmdtp, int flag, int argc, 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) { @@ -99,7 +101,11 @@ static int do_sata(struct cmd_tbl *cmdtp, int flag, int argc, 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; } } -- 2.17.1