[coreboot-gerrit] Patch set updated for coreboot: 2eff4d8 device_romstage: Add a way to move to the next device

Martin Roth (martin.roth@se-eng.com) gerrit at coreboot.org
Mon May 19 21:52:34 CEST 2014


Martin Roth (martin.roth at se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5732

-gerrit

commit 2eff4d8049fbda2002a713ded62cdd7414752de4
Author: Martin Roth <gaumless at gmail.com>
Date:   Mon May 12 17:38:59 2014 -0600

    device_romstage: Add a way to move to the next device
    
    When trying to loop through all the devices in romstage, there was
    no function to just go from one to the next.
    
    This allows an easy way to go all the way down the chain of devices.
    
    Change-Id: Id205b24610d75de060b0d48fa283a2ab92d1df0a
    Signed-off-by: Martin Roth <gaumless at gmail.com>
---
 src/device/device_romstage.c | 22 ++++++++++++++++++++++
 src/include/device/device.h  |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/src/device/device_romstage.c b/src/device/device_romstage.c
index 591cf88..d37dd8e 100644
--- a/src/device/device_romstage.c
+++ b/src/device/device_romstage.c
@@ -55,6 +55,28 @@ 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_device(
+		ROMSTAGE_CONST struct device *previous_dev)
+{
+	ROMSTAGE_CONST struct device *dev, *result;
+
+	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 a4ef456..7f7ad39 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_device(
+						ROMSTAGE_CONST struct device *previous_dev);
 ROMSTAGE_CONST struct device * dev_find_slot_on_smbus (unsigned int bus,
 							unsigned int addr);
 



More information about the coreboot-gerrit mailing list