Commit 2bfe86770d875de180f698a65371417d7cd67c43

Authored by Ye Li
1 parent a4461cb2d0

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 e2a66807f3573e8344dcd285dcb7d53f0e5fcf8e)

Showing 1 changed file with 9 additions and 3 deletions Side-by-side Diff

... ... @@ -21,15 +21,21 @@
21 21 {
22 22 int rc = 0;
23 23  
24   - if (argc == 2 && strcmp(argv[1], "stop") == 0)
  24 + if (argc == 2 && strcmp(argv[1], "stop") == 0) {
  25 + sata_curr_device = -1;
25 26 return sata_stop();
  27 + }
26 28  
27 29 if (argc == 2 && strcmp(argv[1], "init") == 0) {
28 30 if (sata_curr_device != -1)
29 31 sata_stop();
30 32  
31   - return (sata_initialize() < 0) ?
32   - CMD_RET_FAILURE : CMD_RET_SUCCESS;
  33 + rc = sata_initialize();
  34 + if (rc == -1)
  35 + return CMD_RET_FAILURE;
  36 +
  37 + sata_curr_device = rc;
  38 + return CMD_RET_SUCCESS;
33 39 }
34 40  
35 41 /* If the user has not yet run `sata init`, do it now */