All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] sata: fix sata command can not being executed bug
@ 2016-11-21  2:24 yuantian.tang at nxp.com
  2016-11-24  2:20 ` Simon Glass
  2016-11-29  1:06 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: yuantian.tang at nxp.com @ 2016-11-21  2:24 UTC (permalink / raw)
  To: u-boot

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

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>
---
v3:
  - refine the commit message
v2:
  - refined this patch and updated the commit title and message

 cmd/sata.c    | 9 ++++++---
 common/sata.c | 8 +++++---
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/cmd/sata.c b/cmd/sata.c
index d18b523..f56622a 100644
--- a/cmd/sata.c
+++ b/cmd/sata.c
@@ -32,9 +32,12 @@ 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();
+		if (rc == -1)
+			return rc;
+		sata_curr_device = rc;
+	}
 
 	switch (argc) {
 	case 0:
diff --git a/common/sata.c b/common/sata.c
index 88f08c9..42ff5c7 100644
--- a/common/sata.c
+++ b/common/sata.c
@@ -51,7 +51,7 @@ static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start,
 
 int __sata_initialize(void)
 {
-	int rc;
+	int rc, ret = -1;
 	int i;
 
 	for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
@@ -71,12 +71,14 @@ int __sata_initialize(void)
 		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")));
 
-- 
2.1.0.27.g96db324

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] sata: fix sata command can not being executed bug
  2016-11-21  2:24 [U-Boot] [PATCH] sata: fix sata command can not being executed bug yuantian.tang at nxp.com
@ 2016-11-24  2:20 ` Simon Glass
  2016-11-29  1:06 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2016-11-24  2:20 UTC (permalink / raw)
  To: u-boot

On 20 November 2016 at 19:24,  <yuantian.tang@nxp.com> wrote:
> From: Tang Yuantian <Yuantian.Tang@nxp.com>
>
> 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>
> ---
> v3:
>   - refine the commit message
> v2:
>   - refined this patch and updated the commit title and message
>
>  cmd/sata.c    | 9 ++++++---
>  common/sata.c | 8 +++++---
>  2 files changed, 11 insertions(+), 6 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] sata: fix sata command can not being executed bug
  2016-11-21  2:24 [U-Boot] [PATCH] sata: fix sata command can not being executed bug yuantian.tang at nxp.com
  2016-11-24  2:20 ` Simon Glass
@ 2016-11-29  1:06 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-11-29  1:06 UTC (permalink / raw)
  To: u-boot

On Mon, Nov 21, 2016 at 10:24:20AM +0800, tang yuantian wrote:

> From: Tang Yuantian <Yuantian.Tang@nxp.com>
> 
> 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161128/3dbd6eae/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-29  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-21  2:24 [U-Boot] [PATCH] sata: fix sata command can not being executed bug yuantian.tang at nxp.com
2016-11-24  2:20 ` Simon Glass
2016-11-29  1:06 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.