MLK-14930-1 cmd: sata: Fix sata init and stop issue
authorYe Li <ye.li@nxp.com>
Tue, 27 Mar 2018 07:56:19 +0000 (00:56 -0700)
committerYe Li <ye.li@nxp.com>
Thu, 29 Apr 2021 05:03:37 +0000 (22:03 -0700)
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)
(cherry picked from commit 1707f011d5c79ae0f32b50ecf87f8aaed94944d0)

cmd/sata.c

index aa396c1..e0106f8 100644 (file)
@@ -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;
                }
        }