From patchwork Mon Oct 29 15:23:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot, v3, 05/22] scsi: Add function and env var to report number of scsi drives Date: Mon, 29 Oct 2012 05:23:48 -0000 From: Simon Glass X-Patchwork-Id: 195048 Message-Id: <1351524245-19584-6-git-send-email-sjg@chromium.org> To: U-Boot Mailing List Cc: Tom Rini , Stefan Reinauer , Rob Herring From: Stefan Reinauer Add a new function to find out the number of available SCSI disks. Also set the 'scsidevs' environment variable after each scan. Signed-off-by: Stefan Reinauer Signed-off-by: Simon Glass --- Changes in v3: - Fix setenv operation to use correct function Changes in v2: - Set 'scsidevs' environment variable to number of SCSI disks README | 3 +++ common/cmd_scsi.c | 8 ++++++++ include/scsi.h | 2 ++ 3 files changed, 13 insertions(+), 0 deletions(-) diff --git a/README b/README index 69da2b8..801772c 100644 --- a/README +++ b/README @@ -1039,6 +1039,9 @@ The following options need to be configured: devices. CONFIG_SYS_SCSI_SYM53C8XX_CCF to fix clock timing (80Mhz) + The environment variable 'scsidevs' is set to the number of + SCSI devices found during the last scan. + - NETWORK Support (PCI): CONFIG_E1000 Support for Intel 8254x/8257x gigabit chips. diff --git a/common/cmd_scsi.c b/common/cmd_scsi.c index 31ea788..9bd8ec9 100644 --- a/common/cmd_scsi.c +++ b/common/cmd_scsi.c @@ -184,6 +184,14 @@ removable: scsi_curr_dev=0; else scsi_curr_dev = -1; + + printf("Found %d device(s).\n", scsi_max_devs); + setenv_ulong("scsidevs", scsi_max_devs); +} + +int scsi_get_disk_count(void) +{ + return scsi_max_devs; } #ifdef CONFIG_PCI diff --git a/include/scsi.h b/include/scsi.h index 89ae45f..9681d19 100644 --- a/include/scsi.h +++ b/include/scsi.h @@ -189,6 +189,8 @@ void scsi_low_level_init(int busdevfunc); void scsi_init(void); void scsi_scan(int mode); +/** @return the number of scsi disks */ +int scsi_get_disk_count(void); #define SCSI_IDENTIFY 0xC0 /* not used */