[coreboot-gerrit] Change in coreboot[master]: device: Move dev_find_path() to device_early.c

Nico Huber (Code Review) gerrit at coreboot.org
Tue May 15 14:22:50 CEST 2018


Nico Huber has uploaded this change for review. ( https://review.coreboot.org/26294


Change subject: device: Move dev_find_path() to device_early.c
......................................................................

device: Move dev_find_path() to device_early.c

Make it available early and use it in dev_find_next_pci_device().

Change-Id: I1d0ad07f37ea79dae2b9a592fcccba5e03fd86d5
Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
M src/device/device_early.c
M src/device/device_util.c
M src/include/device/device.h
3 files changed, 31 insertions(+), 42 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/94/26294/1

diff --git a/src/device/device_early.c b/src/device/device_early.c
index b5eade2..d5d5826 100644
--- a/src/device/device_early.c
+++ b/src/device/device_early.c
@@ -61,6 +61,33 @@
 }
 
 /**
+ * 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.
+ */
+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 = 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;
+}
+
+/**
  * Given a device pointer, find the next PCI device.
  *
  * @param previous_dev A pointer to a PCI device structure.
@@ -69,19 +96,7 @@
 DEVTREE_CONST struct device *dev_find_next_pci_device(
 		DEVTREE_CONST struct device *previous_dev)
 {
-	DEVTREE_CONST struct device *dev, *result;
-
-	if (previous_dev == NULL)
-		previous_dev = all_devices;
-
-	result = 0;
-	for (dev = previous_dev->next; dev; dev = dev->next) {
-		if (dev->path.type == DEVICE_PATH_PCI) {
-			result = dev;
-			break;
-		}
-	}
-	return result;
+	return dev_find_path(previous_dev, DEVICE_PATH_PCI);
 }
 
 /**
diff --git a/src/device/device_util.c b/src/device/device_util.c
index 85b794a..5818178 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -88,33 +88,6 @@
 }
 
 /**
- * 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(device_t 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 f3afd60..e1b4a99 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -200,8 +200,9 @@
 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);
 

-- 
To view, visit https://review.coreboot.org/26294
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d0ad07f37ea79dae2b9a592fcccba5e03fd86d5
Gerrit-Change-Number: 26294
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h at gmx.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180515/d056eb58/attachment-0001.html>


More information about the coreboot-gerrit mailing list