Commit 
d97dc8a0 separated the non-command code into its own file
which caused variable sata_curr_device can not be set to a correct
value.
Before commit 
d97dc8a0, variable sata_curr_device can be set
correctly in sata_initialize().
After commit 
d97dc8a0, sata_initialize() is moved out to its own file.
Accordingly, variable sata_curr_device is removed from sata_initialize()
too. This caused sata_curr_device never gets a chance to be set properly
which prevent other commands from being executed.
This patch sets variable sata_curr_device properly.
Fixes: d97dc8a0 (dm: sata: Separate the non-command code into its
 own file)
Signed-off-by: Tang Yuantian <yuantian.tang@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
        }
 
        /* If the user has not yet run `sata init`, do it now */
-       if (sata_curr_device == -1)
-               if (sata_initialize())
-                       return 1;
+       if (sata_curr_device == -1) {
+               rc = sata_initialize();
+               if (rc == -1)
+                       return rc;
+               sata_curr_device = rc;
+       }
 
        switch (argc) {
        case 0:
 
 
 int __sata_initialize(void)
 {
-       int rc;
+       int rc, ret = -1;
        int i;
 
        for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
                if (!rc) {
                        rc = scan_sata(i);
                        if (!rc && sata_dev_desc[i].lba > 0 &&
-                           sata_dev_desc[i].blksz > 0)
+                           sata_dev_desc[i].blksz > 0) {
                                part_init(&sata_dev_desc[i]);
+                               ret = i;
+                       }
                }
        }
 
-       return rc;
+       return ret;
 }
 int sata_initialize(void) __attribute__((weak, alias("__sata_initialize")));