diff options
author | Simon Glass <sjg@chromium.org> | 2015-11-29 13:17:52 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-01-12 10:19:09 -0700 |
commit | a0eb835635abe0952529e3eb5207a24ac36fa000 (patch) | |
tree | aac75f8b2e09e09890e6a74ef7f5c3078b1d689f /drivers/pci/pci-uclass.c | |
parent | 9fbdb94667b7316ef2a48fce325ae2da147d7d66 (diff) |
dm: pci: Add a driver-model version of pci_find_class()
Add a function which scans the driver model device information rather
than scanning the PCI bus again.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/pci/pci-uclass.c')
-rw-r--r-- | drivers/pci/pci-uclass.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index af6de51482..dea0cb6e06 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -234,6 +234,26 @@ int dm_pci_find_device(unsigned int vendor, unsigned int device, int index, return -ENODEV; } +int dm_pci_find_class(uint find_class, int index, struct udevice **devp) +{ + struct udevice *dev; + + /* Scan all known buses */ + for (pci_find_first_device(&dev); + dev; + pci_find_next_device(&dev)) { + struct pci_child_platdata *pplat = dev_get_parent_platdata(dev); + + if (pplat->class == find_class && !index--) { + *devp = dev; + return device_probe(*devp); + } + } + *devp = NULL; + + return -ENODEV; +} + int pci_bus_write_config(struct udevice *bus, pci_dev_t bdf, int offset, unsigned long value, enum pci_size_t size) { |