aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_const.c
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2018-05-15 14:13:32 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2018-05-25 02:44:04 +0000
commitf6a4344c5b41c30bd918371796962bce29872676 (patch)
treea41fa95d9f426c35a484c03663b5525dbc873c42 /src/device/device_const.c
parent81ec9c0500e4b53440579ffad0011a6b077b6bdb (diff)
device: Move dev_find_path() to device_const.c
Make it available early and use it in dev_find_next_pci_device(). Change-Id: I1d0ad07f37ea79dae2b9a592fcccba5e03fd86d5 Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/26294 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Diffstat (limited to 'src/device/device_const.c')
-rw-r--r--src/device/device_const.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/device/device_const.c b/src/device/device_const.c
index 2cacb4a9ac..084d2ac385 100644
--- a/src/device/device_const.c
+++ b/src/device/device_const.c
@@ -51,22 +51,25 @@ DEVTREE_CONST struct device *dev_find_slot(unsigned int bus,
}
/**
- * Given a device pointer, find the next PCI device.
+ * Given a Device Path Type, find the device structure.
*
- * @param previous_dev A pointer to a PCI device structure.
- * @return Pointer to the next device structure (if found), 0 otherwise.
+ * @param prev_match The previously matched device instance.
+ * @param path_type The Device Path Type.
+ * @return Pointer to the device structure (if found), 0 otherwise.
*/
-DEVTREE_CONST struct device *dev_find_next_pci_device(
- DEVTREE_CONST struct device *previous_dev)
+DEVTREE_CONST struct device *dev_find_path(
+ DEVTREE_CONST struct device *prev_match,
+ enum device_path_type path_type)
{
- DEVTREE_CONST struct device *dev, *result;
+ DEVTREE_CONST struct device *dev, *result = NULL;
- if (previous_dev == NULL)
- previous_dev = all_devices;
+ if (prev_match == NULL)
+ prev_match = all_devices;
+ else
+ prev_match = prev_match->next;
- result = 0;
- for (dev = previous_dev->next; dev; dev = dev->next) {
- if (dev->path.type == DEVICE_PATH_PCI) {
+ for (dev = prev_match; dev; dev = dev->next) {
+ if (dev->path.type == path_type) {
result = dev;
break;
}
@@ -75,6 +78,18 @@ DEVTREE_CONST struct device *dev_find_next_pci_device(
}
/**
+ * 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.
+ */
+DEVTREE_CONST struct device *dev_find_next_pci_device(
+ DEVTREE_CONST struct device *previous_dev)
+{
+ return dev_find_path(previous_dev, DEVICE_PATH_PCI);
+}
+
+/**
* Given an SMBus bus and a device number, find the device structure.
*
* @param bus The bus number.