Skip to contentSkip to conversation

cmd: sata: fix init command return value

PATCH In review Gary Bisson 4 participants 4 messages Jan 11, 2017 – Jan 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd: sata: fix init command return value

Since commit aa6ab905b2, sata_initialize returns -1 if init_sata or scan_sata fails. But this return value becomes the do_sata return value which is equivalent to CMD_RET_USAGE.

In case one issues 'sata init' and that the hardware fails to initialize, there's no need to display the command usage. Instead the command shoud just return the CMD_RET_FAILURE value.

Fixes aa6ab905b2 (sata: fix sata command can not being executed bug)
---
 cmd/sata.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
cmd/sata.c +3 -2
index f56622acc2..4c53022ff6 100644
@@ -28,14 +28,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (sata_curr_device != -1)
 			sata_stop();
 
-		return sata_initialize();
+		return (sata_initialize() < 0) ?
+			CMD_RET_FAILURE : CMD_RET_SUCCESS;
 	}
 
 	/* If the user has not yet run `sata init`, do it now */
 	if (sata_curr_device == -1) {
 		rc = sata_initialize();
 		if (rc == -1)
-			return rc;
+			return CMD_RET_FAILURE;
 		sata_curr_device = rc;
 	}
 
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 cmd: sata: fix init command return value

Quoted 7 lines · Gary Bisson

Since commit aa6ab905b2, sata_initialize returns -1 if init_sata or scan_sata fails. But this return value becomes the do_sata return value which is equivalent to CMD_RET_USAGE.

In case one issues 'sata init' and that the hardware fails to initialize, there's no need to display the command usage. Instead the command shoud just return the CMD_RET_FAILURE value.

s/shoud/should/

Quoted 21 lines
Fixes aa6ab905b2 (sata: fix sata command can not being executed bug)
---
 cmd/sata.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
cmd/sata.c +2 -1
index f56622acc2..4c53022ff6 100644
@@ -28,14 +28,15 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (sata_curr_device != -1)
 			sata_stop();
 
-		return sata_initialize();
+		return (sata_initialize() < 0) ?
+			CMD_RET_FAILURE : CMD_RET_SUCCESS;
 	}

cmd/sata.c static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 42

Quoted 10 lines
cmd/sata.c +1 -1
 
 	/* If the user has not yet run `sata init`, do it now */
 	if (sata_curr_device == -1) {
 		rc = sata_initialize();
 		if (rc == -1)
-			return rc;
+			return CMD_RET_FAILURE;
 		sata_curr_device = rc;
 	}
 

Otherwise,

#2 lore raw

PATCH 1/1 cmd: sata: fix init command return value

In reply to Gary Bisson
Quoted 9 lines · Gary Bisson

Since commit aa6ab905b2, sata_initialize returns -1 if init_sata or scan_sata fails. But this return value becomes the do_sata return value which is equivalent to CMD_RET_USAGE.

In case one issues 'sata init' and that the hardware fails to initialize, there's no need to display the command usage. Instead the command shoud just return the CMD_RET_FAILURE value.

Quoted 6 lines
Fixes aa6ab905b2 (sata: fix sata command can not being executed bug)
---
 cmd/sata.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#3 lore raw
In reply to Gary Bisson
Quoted 8 lines · Gary Bisson

Since commit aa6ab905b2, sata_initialize returns -1 if init_sata or scan_sata fails. But this return value becomes the do_sata return value which is equivalent to CMD_RET_USAGE.

In case one issues 'sata init' and that the hardware fails to initialize, there's no need to display the command usage. Instead the command shoud just return the CMD_RET_FAILURE value.

Quoted 5 lines
Fixes aa6ab905b2 (sata: fix sata command can not being executed bug)

Applied to u-boot/master, thanks!

Signature · 8 lines
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/20170115/b4340c86/attachment.sig>