dm: pci: scsi: Use driver-model PCI API
authorSimon Glass <sjg@chromium.org>
Sun, 29 Nov 2015 20:17:51 +0000 (13:17 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 12 Jan 2016 17:19:09 +0000 (10:19 -0700)
Adjust the SCSI command to use driver model for its PCI interface.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
common/cmd_scsi.c

index 31c43195e45150525f516ce195b0b7c9b9d17c83..86954089fe78aa234434306e37aba9bee9ec1d91 100644 (file)
@@ -184,7 +184,7 @@ int scsi_get_disk_count(void)
 #if defined(CONFIG_PCI) && !defined(CONFIG_SCSI_AHCI_PLAT)
 void scsi_init(void)
 {
-       int busdevfunc;
+       int busdevfunc = -1;
        int i;
        /*
         * Find a device from the list, this driver will support a single
@@ -192,9 +192,21 @@ void scsi_init(void)
         */
        for (i = 0; i < ARRAY_SIZE(scsi_device_list); i++) {
                /* get PCI Device ID */
+#ifdef CONFIG_DM_PCI
+               struct udevice *dev;
+               int ret;
+
+               ret = dm_pci_find_device(scsi_device_list[i].vendor,
+                                        scsi_device_list[i].device, 0, &dev);
+               if (!ret) {
+                       busdevfunc = dm_pci_get_bdf(dev);
+                       break;
+               }
+#else
                busdevfunc = pci_find_device(scsi_device_list[i].vendor,
                                             scsi_device_list[i].device,
                                             0);
+#endif
                if (busdevfunc != -1)
                        break;
        }