[coreboot-gerrit] Patch set updated for coreboot: src/device: Get device structure by path type

Subrata Banik (subrata.banik@intel.com) gerrit at coreboot.org
Tue Dec 6 15:41:34 CET 2016


Subrata Banik (subrata.banik at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17731

-gerrit

commit cd556271df994523a3b494ee2b465cc556a4c9ed
Author: Subrata Banik <subrata.banik at intel.com>
Date:   Tue Dec 6 18:06:30 2016 +0530

    src/device: Get device structure by path type
    
    Add helper function to find a device by path type
    in the device tree.
    
    Change-Id: I8846f63bd2488788ea3c7ab5154e7cf431a252bc
    Credits-to: Aaron Durbin <adurbin at chromium.org>
    Signed-off-by: Subrata Banik <subrata.banik at intel.com>
    Signed-off-by: Dhaval V Sharma <dhaval.v.sharma at intel.com>
---
 src/device/device_util.c    | 23 +++++++++++++++++++++++
 src/include/device/device.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/src/device/device_util.c b/src/device/device_util.c
index 56afefd..837012c 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -131,6 +131,29 @@ device_t dev_find_lapic(unsigned apic_id)
 }
 
 /**
+ * Given a Device Path Type, find the device structure.
+ *
+ * @param dev The starting device instance.
+ * @param path_type The Device Path Type.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+device_t dev_find_path(device_t start_dev, unsigned int path_type)
+{
+	device_t dev, result = NULL;
+
+	if (start_dev == NULL)
+		start_dev = all_devices;
+
+	for (dev = start_dev; dev; dev = dev->next) {
+		if (dev->path.type == path_type) {
+			result = dev;
+			break;
+		}
+	}
+	return result;
+}
+
+/**
  * Find a device of a given vendor and type.
  *
  * @param vendor A PCI vendor ID (e.g. 0x8086 for Intel).
diff --git a/src/include/device/device.h b/src/include/device/device.h
index 95fabf4..ea71c4d 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -195,6 +195,7 @@ device_t find_dev_path(struct bus *parent, struct device_path *path);
 device_t alloc_find_dev(struct bus *parent, struct device_path *path);
 device_t dev_find_device (u16 vendor, u16 device, device_t from);
 device_t dev_find_class (unsigned int class, device_t from);
+device_t dev_find_path(device_t start_dev, unsigned int path_type);
 device_t dev_find_slot (unsigned int bus, unsigned int devfn);
 device_t dev_find_slot_on_smbus (unsigned int bus, unsigned int addr);
 device_t dev_find_slot_pnp(u16 port, u16 device);



More information about the coreboot-gerrit mailing list