Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34077 )
Change subject: device/pci: Declare pcidev_path_on_bus() ......................................................................
device/pci: Declare pcidev_path_on_bus()
Change-Id: I733c645ac5581c000b4cd6cdc05829cd039324d5 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/device/device_const.c M src/include/device/device.h 2 files changed, 19 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/77/34077/1
diff --git a/src/device/device_const.c b/src/device/device_const.c index 1853b4c..c1b0b06 100644 --- a/src/device/device_const.c +++ b/src/device/device_const.c @@ -183,6 +183,24 @@ return find_dev_path(parent, &path); }
+DEVTREE_CONST struct device *pcidev_path_on_bus(unsigned int bus, pci_devfn_t devfn) +{ + DEVTREE_CONST struct bus *parent = pci_root_bus(); + DEVTREE_CONST struct device *dev = parent->children; + + /* FIXME: Write the loop with topology links. */ + while (dev) { + if (dev->path.type != DEVICE_PATH_PCI) { + dev = dev->next; + continue; + } + if (dev->bus->secondary == bus) + return pcidev_path_behind(dev->bus, devfn); + dev = dev->next; + } + return NULL; +} + DEVTREE_CONST struct bus *pci_root_bus(void) { DEVTREE_CONST struct device *pci_domain; diff --git a/src/include/device/device.h b/src/include/device/device.h index a200de0..007c51f 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -288,6 +288,7 @@ DEVTREE_CONST struct device *pcidev_path_behind(const struct bus *parent, pci_devfn_t devfn); DEVTREE_CONST struct device *pcidev_path_on_root(pci_devfn_t devfn); +DEVTREE_CONST struct device *pcidev_path_on_bus(unsigned int bus, pci_devfn_t devfn); DEVTREE_CONST struct device *pcidev_on_root(uint8_t dev, uint8_t fn); DEVTREE_CONST struct bus *pci_root_bus(void);