<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26294">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">device: Move dev_find_path() to device_early.c<br><br>Make it available early and use it in dev_find_next_pci_device().<br><br>Change-Id: I1d0ad07f37ea79dae2b9a592fcccba5e03fd86d5<br>Signed-off-by: Nico Huber <nico.huber@secunet.com><br>---<br>M src/device/device_early.c<br>M src/device/device_util.c<br>M src/include/device/device.h<br>3 files changed, 31 insertions(+), 42 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/94/26294/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/device/device_early.c b/src/device/device_early.c</span><br><span>index b5eade2..d5d5826 100644</span><br><span>--- a/src/device/device_early.c</span><br><span>+++ b/src/device/device_early.c</span><br><span>@@ -61,6 +61,33 @@</span><br><span> }</span><br><span> </span><br><span> /**</span><br><span style="color: hsl(120, 100%, 40%);">+ * Given a Device Path Type, find the device structure.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param prev_match The previously matched device instance.</span><br><span style="color: hsl(120, 100%, 40%);">+ * @param path_type The Device Path Type.</span><br><span style="color: hsl(120, 100%, 40%);">+ * @return Pointer to the device structure (if found), 0 otherwise.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+DEVTREE_CONST struct device *dev_find_path(</span><br><span style="color: hsl(120, 100%, 40%);">+          DEVTREE_CONST struct device *prev_match,</span><br><span style="color: hsl(120, 100%, 40%);">+              enum device_path_type path_type)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   DEVTREE_CONST struct device *dev, *result = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   if (prev_match == NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+               prev_match = all_devices;</span><br><span style="color: hsl(120, 100%, 40%);">+     else</span><br><span style="color: hsl(120, 100%, 40%);">+          prev_match = prev_match->next;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   for (dev = prev_match; dev; dev = dev->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (dev->path.type == path_type) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 result = dev;</span><br><span style="color: hsl(120, 100%, 40%);">+                 break;</span><br><span style="color: hsl(120, 100%, 40%);">+                }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     return result;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span>  * Given a device pointer, find the next PCI device.</span><br><span>  *</span><br><span>  * @param previous_dev A pointer to a PCI device structure.</span><br><span>@@ -69,19 +96,7 @@</span><br><span> DEVTREE_CONST struct device *dev_find_next_pci_device(</span><br><span>                 DEVTREE_CONST struct device *previous_dev)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- DEVTREE_CONST struct device *dev, *result;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      if (previous_dev == NULL)</span><br><span style="color: hsl(0, 100%, 40%);">-               previous_dev = all_devices;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     result = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-     for (dev = previous_dev->next; dev; dev = dev->next) {</span><br><span style="color: hsl(0, 100%, 40%);">-            if (dev->path.type == DEVICE_PATH_PCI) {</span><br><span style="color: hsl(0, 100%, 40%);">-                     result = dev;</span><br><span style="color: hsl(0, 100%, 40%);">-                   break;</span><br><span style="color: hsl(0, 100%, 40%);">-          }</span><br><span style="color: hsl(0, 100%, 40%);">-       }</span><br><span style="color: hsl(0, 100%, 40%);">-       return result;</span><br><span style="color: hsl(120, 100%, 40%);">+        return dev_find_path(previous_dev, DEVICE_PATH_PCI);</span><br><span> }</span><br><span> </span><br><span> /**</span><br><span>diff --git a/src/device/device_util.c b/src/device/device_util.c</span><br><span>index 85b794a..5818178 100644</span><br><span>--- a/src/device/device_util.c</span><br><span>+++ b/src/device/device_util.c</span><br><span>@@ -88,33 +88,6 @@</span><br><span> }</span><br><span> </span><br><span> /**</span><br><span style="color: hsl(0, 100%, 40%);">- * Given a Device Path Type, find the device structure.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * @param prev_match The previously matched device instance.</span><br><span style="color: hsl(0, 100%, 40%);">- * @param path_type The Device Path Type.</span><br><span style="color: hsl(0, 100%, 40%);">- * @return Pointer to the device structure (if found), 0 otherwise.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-struct device *dev_find_path(device_t prev_match,</span><br><span style="color: hsl(0, 100%, 40%);">-                             enum device_path_type path_type)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-       struct device *dev;</span><br><span style="color: hsl(0, 100%, 40%);">-     struct device *result = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   if (prev_match == NULL)</span><br><span style="color: hsl(0, 100%, 40%);">-         prev_match = all_devices;</span><br><span style="color: hsl(0, 100%, 40%);">-       else</span><br><span style="color: hsl(0, 100%, 40%);">-            prev_match = prev_match->next;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       for (dev = prev_match; dev; dev = dev->next) {</span><br><span style="color: hsl(0, 100%, 40%);">-               if (dev->path.type == path_type) {</span><br><span style="color: hsl(0, 100%, 40%);">-                   result = dev;</span><br><span style="color: hsl(0, 100%, 40%);">-                   break;</span><br><span style="color: hsl(0, 100%, 40%);">-          }</span><br><span style="color: hsl(0, 100%, 40%);">-       }</span><br><span style="color: hsl(0, 100%, 40%);">-       return result;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/**</span><br><span>  * Find a device of a given vendor and type.</span><br><span>  *</span><br><span>  * @param vendor A PCI vendor ID (e.g. 0x8086 for Intel).</span><br><span>diff --git a/src/include/device/device.h b/src/include/device/device.h</span><br><span>index f3afd60..e1b4a99 100644</span><br><span>--- a/src/include/device/device.h</span><br><span>+++ b/src/include/device/device.h</span><br><span>@@ -200,8 +200,9 @@</span><br><span> struct device *alloc_find_dev(struct bus *parent, struct device_path *path);</span><br><span> struct device *dev_find_device(u16 vendor, u16 device, struct device *from);</span><br><span> struct device *dev_find_class(unsigned int class, struct device *from);</span><br><span style="color: hsl(0, 100%, 40%);">-struct device *dev_find_path(struct device *prev_match,</span><br><span style="color: hsl(0, 100%, 40%);">-                          enum device_path_type path_type);</span><br><span style="color: hsl(120, 100%, 40%);">+DEVTREE_CONST struct device *dev_find_path(</span><br><span style="color: hsl(120, 100%, 40%);">+                DEVTREE_CONST struct device *prev_match,</span><br><span style="color: hsl(120, 100%, 40%);">+              enum device_path_type path_type);</span><br><span> struct device *dev_find_lapic(unsigned int apic_id);</span><br><span> int dev_count_cpu(void);</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26294">change 26294</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/26294"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I1d0ad07f37ea79dae2b9a592fcccba5e03fd86d5 </div>
<div style="display:none"> Gerrit-Change-Number: 26294 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>