cmd: sata: fix init command return value
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.
--- cmd/sata.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
cmd/sata.c +3 -2
@@ -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
PATCH 1/1 cmd: sata: fix init command return value
Quoted 7 lines · Gary Bisson
Since commit
aa6ab905b2,sata_initializereturns -1 ifinit_sataorscan_satafails. But this return value becomes thedo_satareturn value which is equivalent toCMD_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_FAILUREvalue.
s/shoud/should/
Quoted 21 lines
Fixes aa6ab905b2 (sata: fix sata command can not being executed bug)Signed-off-by Gary Bisson <[email protected]>--- cmd/sata.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)cmd/sata.c +2
-1@@ -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,
PATCH 1/1 cmd: sata: fix init command return value
In reply to Gary BissonQuoted 9 lines · Gary Bisson
Since commit
aa6ab905b2,sata_initializereturns -1 ifinit_sataorscan_satafails. But this return value becomes thedo_satareturn value which is equivalent toCMD_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_FAILUREvalue.
Quoted 6 lines
Fixes aa6ab905b2 (sata: fix sata command can not being executed bug)Signed-off-by Gary Bisson <[email protected]>--- cmd/sata.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 8 lines · Gary Bisson
Since commit
aa6ab905b2,sata_initializereturns -1 ifinit_sataorscan_satafails. But this return value becomes thedo_satareturn value which is equivalent toCMD_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_FAILUREvalue.
Quoted 5 lines
Fixes aa6ab905b2 (sata: fix sata command can not being executed bug)Signed-off-by Gary Bisson <[email protected]>Reviewed-by Eric Nelson <[email protected]>Reviewed-by Simon Glass <[email protected]>
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>