summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/device/device_const.c37
-rw-r--r--src/device/device_util.c27
-rw-r--r--src/include/device/device.h5
3 files changed, 29 insertions, 40 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.
diff --git a/src/device/device_util.c b/src/device/device_util.c
index 3315e480fc..4275d6e256 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -65,33 +65,6 @@ struct device *dev_find_lapic(unsigned apic_id)
}
/**
- * Given a Device Path Type, find the device structure.
- *
- * @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.
- */
-struct device *dev_find_path(struct device *prev_match,
- enum device_path_type path_type)
-{
- struct device *dev;
- struct device *result = NULL;
-
- if (prev_match == NULL)
- prev_match = all_devices;
- else
- prev_match = prev_match->next;
-
- for (dev = prev_match; 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 f3afd60b2c..e1b4a99cca 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -200,8 +200,9 @@ struct device *find_dev_path(struct bus *parent, struct device_path *path);
struct device *alloc_find_dev(struct bus *parent, struct device_path *path);
struct device *dev_find_device(u16 vendor, u16 device, struct device *from);
struct device *dev_find_class(unsigned int class, struct device *from);
-struct device *dev_find_path(struct device *prev_match,
- enum device_path_type path_type);
+DEVTREE_CONST struct device *dev_find_path(
+ DEVTREE_CONST struct device *prev_match,
+ enum device_path_type path_type);
struct device *dev_find_lapic(unsigned int apic_id);
int dev_count_cpu(void);