Commit 9bccfd01c618a5d059f332c000c42e5bf39880d9

Authored by Ye Li
1 parent 8cca3efba0

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>

Showing 1 changed file with 8 additions and 2 deletions Side-by-side Diff

... ... @@ -91,8 +91,10 @@
91 91  
92 92 if (argc == 3)
93 93 devnum = (int)simple_strtoul(argv[2], NULL, 10);
94   - if (!strcmp(argv[1], "stop"))
  94 + if (!strcmp(argv[1], "stop")) {
  95 + sata_curr_device = -1;
95 96 return sata_remove(devnum);
  97 + }
96 98  
97 99 if (!strcmp(argv[1], "init")) {
98 100 if (sata_curr_device != -1) {
... ... @@ -101,7 +103,11 @@
101 103 return rc;
102 104 }
103 105  
104   - return sata_probe(devnum);
  106 + rc = sata_probe(devnum);
  107 + if (rc < 0)
  108 + return CMD_RET_FAILURE;
  109 + sata_curr_device = rc;
  110 + return CMD_RET_SUCCESS;
105 111 }
106 112 }
107 113