From c73acdb69eb8128bbbb3bed63cb0ca1b943027ee Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Sat, 15 Jun 2013 17:16:56 +0300 Subject: Add test to match struct device with pci_devfn_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a function to test if pci_devfn_t matches with a device instance of struct device, by comparing bus:dev.fn. Change-Id: Ic6c3148ac62c7183246d83302ee504b17064c794 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/3474 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/device/pci_device.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/device') diff --git a/src/device/pci_device.c b/src/device/pci_device.c index 4c5a81451c..1d998ca780 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -1053,6 +1053,19 @@ device_t pci_probe_dev(device_t dev, struct bus *bus, unsigned devfn) return dev; } +/** + * Test for match between romstage and ramstage device instance. + * + * @param dev Pointer to the device structure. + * @param sdev Simple device model identifier, created with PCI_DEV(). + * @return Non-zero if bus:dev.fn of device matches. + */ +unsigned int pci_match_simple_dev(device_t dev, pci_devfn_t sdev) +{ + return dev->bus->secondary == PCI_DEV2SEGBUS(sdev) && + dev->path.pci.devfn == PCI_DEV2DEVFN(sdev); +} + /** * Scan a PCI bus. * -- cgit v1.2.3