[U-Boot] [PATCH v1 4/5] scsi: Change scsi_scan() to be able to return value
Michal Simek
michal.simek at xilinx.com
Wed Nov 30 21:46:50 CET 2016
With DM_SCSI this function will return more than one return value to
cover errors.
Suggested-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---
cmd/scsi.c | 14 ++++++++++----
common/scsi.c | 3 ++-
include/scsi.h | 2 +-
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/cmd/scsi.c b/cmd/scsi.c
index a9c954a82f3d..4213ec867751 100644
--- a/cmd/scsi.c
+++ b/cmd/scsi.c
@@ -27,6 +27,8 @@ static int do_scsiboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
*/
static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
+ int ret;
+
switch (argc) {
case 0:
case 1:
@@ -35,8 +37,10 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (strncmp(argv[1], "res", 3) == 0) {
printf("\nReset SCSI\n");
scsi_bus_reset();
- scsi_scan(1);
- return 0;
+ ret = scsi_scan(1);
+ if (ret)
+ return CMD_RET_FAILURE;
+ return ret;
}
if (strncmp(argv[1], "inf", 3) == 0) {
blk_list_devices(IF_TYPE_SCSI);
@@ -51,8 +55,10 @@ static int do_scsi(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
return 0;
}
if (strncmp(argv[1], "scan", 4) == 0) {
- scsi_scan(1);
- return 0;
+ ret = scsi_scan(1);
+ if (ret)
+ return CMD_RET_FAILURE;
+ return ret;
}
if (strncmp(argv[1], "part", 4) == 0) {
if (blk_list_part(IF_TYPE_SCSI))
diff --git a/common/scsi.c b/common/scsi.c
index ba6561605810..839b30b9bb8e 100644
--- a/common/scsi.c
+++ b/common/scsi.c
@@ -524,7 +524,7 @@ removable:
* (re)-scan the scsi bus and reports scsi device info
* to the user if mode = 1
*/
-void scsi_scan(int mode)
+int scsi_scan(int mode)
{
unsigned char i, lun;
int ret;
@@ -558,6 +558,7 @@ void scsi_scan(int mode)
#ifndef CONFIG_SPL_BUILD
setenv_ulong("scsidevs", scsi_max_devs);
#endif
+ return 0;
}
#ifdef CONFIG_BLK
diff --git a/include/scsi.h b/include/scsi.h
index eed8ff971731..c8796785a465 100644
--- a/include/scsi.h
+++ b/include/scsi.h
@@ -173,7 +173,7 @@ void scsi_low_level_init(int busdevfunc);
* functions residing inside cmd_scsi.c
*/
void scsi_init(void);
-void scsi_scan(int mode);
+int scsi_scan(int mode);
#define SCSI_IDENTIFY 0xC0 /* not used */
--
1.9.1
More information about the U-Boot
mailing list