[coreboot-gerrit] New patch to review for coreboot: 5efaf68 devicetree: Search PnP device node from the tree by path

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Wed Jan 28 21:21:03 CET 2015


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8297

-gerrit

commit 5efaf68e94fa1e5bdf9f53c3428e795c06da22aa
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Wed Jan 28 22:03:46 2015 +0200

    devicetree: Search PnP device node from the tree by path
    
    Copied from device_util.c with added ROMSTAGE_CONST.
    
    Change-Id: If872631ed96a79b9a0b15e09382d6f81098c8db3
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/device/device_romstage.c | 21 +++++++++++++++++++++
 src/include/device/device.h  |  1 +
 2 files changed, 22 insertions(+)

diff --git a/src/device/device_romstage.c b/src/device/device_romstage.c
index 987fdad..df0df6a 100644
--- a/src/device/device_romstage.c
+++ b/src/device/device_romstage.c
@@ -101,3 +101,24 @@ ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
 	}
 	return result;
 }
+
+/**
+ * Given a PnP port and a device number, find the device structure.
+ *
+ * @param port The I/O port.
+ * @param device Logical device number.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device)
+{
+	ROMSTAGE_CONST struct device *dev;
+
+	for (dev = all_devices; dev; dev = dev->next) {
+		if ((dev->path.type == DEVICE_PATH_PNP) &&
+		    (dev->path.pnp.port == port) &&
+		    (dev->path.pnp.device == device)) {
+			return dev;
+		}
+	}
+	return 0;
+}
diff --git a/src/include/device/device.h b/src/include/device/device.h
index c67205c..30226bf 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -261,6 +261,7 @@ 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);
+ROMSTAGE_CONST struct device * dev_find_slot_pnp(u16 port, u16 device);
 
 #endif
 



More information about the coreboot-gerrit mailing list