[U-Boot] [PATCH v2 08/12] dm: pci: Remove the unnecessary pci_bus_find_devfn() in pci_bind_bus_devices()
Bin Meng
bmeng.cn at gmail.com
Thu Aug 20 15:40:24 CEST 2015
During pci_bind_bus_devices() before finding a proper driver to bind
the device, pci_bus_find_devfn() is called to find if this device
already exists. However since device is even not bound, this call
always returns -ENODEV. It is really unnecessary hence remove it.
Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---
Changes in v2: None
drivers/pci/pci-uclass.c | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index c90e7ac..63e85b9 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -551,6 +551,8 @@ int pci_bind_bus_devices(struct udevice *bus)
ulong header_type;
pci_dev_t bdf, end;
bool found_multi;
+ struct pci_device_id find_id;
+ ulong val;
int ret;
found_multi = false;
@@ -585,30 +587,21 @@ int pci_bind_bus_devices(struct udevice *bus)
PCI_SIZE_32);
class >>= 8;
- /* Find this device in the device tree */
- ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev);
-
/* Search for a driver */
- /* If nothing in the device tree, bind a generic device */
- if (ret == -ENODEV) {
- struct pci_device_id find_id;
- ulong val;
-
- memset(&find_id, '\0', sizeof(find_id));
- find_id.vendor = vendor;
- find_id.device = device;
- find_id.class = class;
- if ((header_type & 0x7f) == PCI_HEADER_TYPE_NORMAL) {
- pci_bus_read_config(bus, bdf,
- PCI_SUBSYSTEM_VENDOR_ID,
- &val, PCI_SIZE_32);
- find_id.subvendor = val & 0xffff;
- find_id.subdevice = val >> 16;
- }
- ret = pci_find_and_bind_driver(bus, &find_id, bdf,
- &dev);
+ memset(&find_id, '\0', sizeof(find_id));
+ find_id.vendor = vendor;
+ find_id.device = device;
+ find_id.class = class;
+ if ((header_type & 0x7f) == PCI_HEADER_TYPE_NORMAL) {
+ pci_bus_read_config(bus, bdf,
+ PCI_SUBSYSTEM_VENDOR_ID,
+ &val, PCI_SIZE_32);
+ find_id.subvendor = val & 0xffff;
+ find_id.subdevice = val >> 16;
}
+ ret = pci_find_and_bind_driver(bus, &find_id, bdf,
+ &dev);
if (ret)
return ret;
--
1.8.2.1
More information about the U-Boot
mailing list