aboutsummaryrefslogtreecommitdiff
path: root/drivers/scsi
diff options
context:
space:
mode:
authorSimon Glass2017-06-14 21:28:45 -0600
committerSimon Glass2017-07-11 10:08:19 -0600
commit5c56176318c8a602fa78813ac273f16a10278a2d (patch)
treee5b96c93ea8ed53607d47ab6ce0438c4246a7a84 /drivers/scsi
parentf6580ef39b332387f84334d238320ce99115af67 (diff)
dm: scsi: Split out the bus scanning code
Split out the code that scans a single SCSI bus into a separate function. This will allow it to be used from driver model. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/scsi.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 80c5ce699e6..2b87548bd31 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -601,9 +601,30 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
return 0;
}
+int scsi_scan_dev(struct udevice *dev, bool verbose)
+{
+ struct scsi_platdata *uc_plat; /* scsi controller platdata */
+ int ret;
+ int i;
+ int lun;
+
+ /* probe SCSI controller driver */
+ ret = device_probe(dev);
+ if (ret)
+ return ret;
+
+ /* Get controller platdata */
+ uc_plat = dev_get_uclass_platdata(dev);
+
+ for (i = 0; i < uc_plat->max_id; i++)
+ for (lun = 0; lun < uc_plat->max_lun; lun++)
+ do_scsi_scan_one(dev, i, lun, verbose);
+
+ return 0;
+}
+
int scsi_scan(bool verbose)
{
- unsigned char i, lun;
struct uclass *uc;
struct udevice *dev; /* SCSI controller */
int ret;
@@ -618,19 +639,9 @@ int scsi_scan(bool verbose)
return ret;
uclass_foreach_dev(dev, uc) {
- struct scsi_platdata *plat; /* scsi controller platdata */
-
- /* probe SCSI controller driver */
- ret = device_probe(dev);
+ ret = scsi_scan_dev(dev, verbose);
if (ret)
return ret;
-
- /* Get controller platdata */
- plat = dev_get_uclass_platdata(dev);
-
- for (i = 0; i < plat->max_id; i++)
- for (lun = 0; lun < plat->max_lun; lun++)
- do_scsi_scan_one(dev, i, lun, verbose);
}
return 0;