[U-Boot] [PATCH] sata: fix sata command not being executed bug

yuantian.tang at nxp.com yuantian.tang at nxp.com
Wed Nov 9 10:37:06 CET 2016


From: Tang Yuantian <Yuantian.Tang at nxp.com>

Variable sata_curr_device is used to indicate if
there is a available sata disk on board.

Previously, sata_curr_device is set in sata_initialize().
Now, sata_initialize() is separated from other sata commands.
Accordingly, sata_curr_device is removed from sata_initialize() too.
This caused sata_curr_device never gets a chance to be set.
If it can't be set a proper value, other sata command will never get
a change to execute.

This patch sets variable sata_curr_device properly.

Signed-off-by: Tang Yuantian <yuantian.tang at nxp.com>
---
 cmd/sata.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/cmd/sata.c b/cmd/sata.c
index d18b523..71c785f 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -20,6 +20,7 @@ static int sata_curr_device = -1;
 static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	int rc = 0;
+	int i;
 
 	if (argc == 2 && strcmp(argv[1], "stop") == 0)
 		return sata_stop();
@@ -32,9 +33,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	/* 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();
+		for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
+			if (sata_dev_desc[i].lba > 0)
+				sata_curr_device = i;
+		}
+		if (sata_curr_device == -1)
+			return -1;
+	}
 
 	switch (argc) {
 	case 0:
-- 
2.1.0.27.g96db324



More information about the U-Boot mailing list