summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/device/device_romstage.c24
-rw-r--r--src/include/device/device.h2
2 files changed, 26 insertions, 0 deletions
diff --git a/src/device/device_romstage.c b/src/device/device_romstage.c
index 591cf886ef..6dcf6d2ad3 100644
--- a/src/device/device_romstage.c
+++ b/src/device/device_romstage.c
@@ -55,6 +55,30 @@ ROMSTAGE_CONST struct device *dev_find_slot(unsigned int bus,
}
/**
+ * Given a device pointer, find the next PCI device.
+ *
+ * @param previous_dev A pointer to a PCI device structure.
+ * @return Pointer to the next device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_next_pci_device(
+ ROMSTAGE_CONST struct device *previous_dev)
+{
+ ROMSTAGE_CONST struct device *dev, *result;
+
+ if (previous_dev == NULL)
+ previous_dev = all_devices;
+
+ result = 0;
+ for (dev = previous_dev->next; dev; dev = dev->next) {
+ if (dev->path.type == DEVICE_PATH_PCI) {
+ result = dev;
+ break;
+ }
+ }
+ return result;
+}
+
+/**
* Given an SMBus bus and a device number, find the device structure.
*
* @param bus The bus number.
diff --git a/src/include/device/device.h b/src/include/device/device.h
index a4ef456add..dcd93f687f 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -236,6 +236,8 @@ u32 find_pci_tolm(struct bus *bus);
ROMSTAGE_CONST struct device * dev_find_slot (unsigned int bus,
unsigned int devfn);
+ROMSTAGE_CONST struct device *dev_find_next_pci_device(
+ ROMSTAGE_CONST struct device *previous_dev);
ROMSTAGE_CONST struct device * dev_find_slot_on_smbus (unsigned int bus,
unsigned int addr);