<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/26292">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">device: Always build device_simple.c for less code duplication<br><br>Change-Id: Iec0a11d67d7641996f26b3a01352be762006ebb6<br>Signed-off-by: Nico Huber <nico.huber@secunet.com><br>---<br>M src/device/Makefile.inc<br>M src/device/device.c<br>M src/device/device_simple.c<br>M src/device/device_util.c<br>4 files changed, 9 insertions(+), 51 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/92/26292/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/device/Makefile.inc b/src/device/Makefile.inc</span><br><span>index 82d4b36..e86aa2c 100644</span><br><span>--- a/src/device/Makefile.inc</span><br><span>+++ b/src/device/Makefile.inc</span><br><span>@@ -26,6 +26,7 @@</span><br><span> smm-y += device_simple.c</span><br><span> verstage-y += device_simple.c</span><br><span> romstage-y += device_simple.c</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-y += device_simple.c</span><br><span> romstage-$(CONFIG_PCI) += pci_early.c</span><br><span> </span><br><span> subdirs-y += oprom dram</span><br><span>diff --git a/src/device/device.c b/src/device/device.c</span><br><span>index 02209d9..1cee963 100644</span><br><span>--- a/src/device/device.c</span><br><span>+++ b/src/device/device.c</span><br><span>@@ -51,8 +51,6 @@</span><br><span> #endif</span><br><span> #include <timer.h></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/** Linked list of ALL devices */</span><br><span style="color: hsl(0, 100%, 40%);">-struct device *all_devices = &dev_root;</span><br><span> /** Pointer to the last device */</span><br><span> extern struct device *last_dev;</span><br><span> /** Linked list of free resources */</span><br><span>diff --git a/src/device/device_simple.c b/src/device/device_simple.c</span><br><span>index e6a6e8f..b5eade2 100644</span><br><span>--- a/src/device/device_simple.c</span><br><span>+++ b/src/device/device_simple.c</span><br><span>@@ -23,6 +23,7 @@</span><br><span> #include <device/path.h></span><br><span> #include <device/pci.h></span><br><span> #include <device/resource.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <stddef.h></span><br><span> </span><br><span> /** Linked list of ALL devices */</span><br><span> DEVTREE_CONST struct device * DEVTREE_CONST all_devices = &dev_root;</span><br><span>@@ -39,11 +40,13 @@</span><br><span> {</span><br><span>    DEVTREE_CONST struct device *dev, *result;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-  printk(BIOS_WARNING,</span><br><span style="color: hsl(0, 100%, 40%);">-            "WARNING: Using the simple device version of %s() "</span><br><span style="color: hsl(0, 100%, 40%);">-           "is considered\ndangerous. Secondary bus numbers are not "</span><br><span style="color: hsl(0, 100%, 40%);">-            "available, yet. Please update the\n code of your platform.\n",</span><br><span style="color: hsl(0, 100%, 40%);">-               __func__);</span><br><span style="color: hsl(120, 100%, 40%);">+    if (DEVTREE_EARLY) {</span><br><span style="color: hsl(120, 100%, 40%);">+          printk(BIOS_WARNING,</span><br><span style="color: hsl(120, 100%, 40%);">+                  "WARNING: Using the simple device version of %s() "</span><br><span style="color: hsl(120, 100%, 40%);">+                 "is considered\ndangerous. Secondary bus numbers are "</span><br><span style="color: hsl(120, 100%, 40%);">+                      "not available, yet. Please update the\n code of your "</span><br><span style="color: hsl(120, 100%, 40%);">+                     "platform.\n", __func__);</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span> </span><br><span>        result = 0;</span><br><span>  for (dev = all_devices; dev; dev = dev->next) {</span><br><span>diff --git a/src/device/device_util.c b/src/device/device_util.c</span><br><span>index aad3b4b..85b794a 100644</span><br><span>--- a/src/device/device_util.c</span><br><span>+++ b/src/device/device_util.c</span><br><span>@@ -44,29 +44,6 @@</span><br><span> }</span><br><span> </span><br><span> /**</span><br><span style="color: hsl(0, 100%, 40%);">- * Given a PCI bus and a devfn number, find the device structure.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * @param bus The bus number.</span><br><span style="color: hsl(0, 100%, 40%);">- * @param devfn A device/function number.</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_slot(unsigned int bus, unsigned int devfn)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-  struct device *dev, *result;</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 = all_devices; 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%);">-               (dev->bus->secondary == bus) &&</span><br><span style="color: hsl(0, 100%, 40%);">-                   (dev->path.pci.devfn == devfn)) {</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>  * Given an SMBus bus and a device number, find the device structure.</span><br><span>  *</span><br><span>  * @param bus The bus number.</span><br><span>@@ -90,27 +67,6 @@</span><br><span> }</span><br><span> </span><br><span> /**</span><br><span style="color: hsl(0, 100%, 40%);">- * Given a PnP port and a device number, find the device structure.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * @param port The I/O port.</span><br><span style="color: hsl(0, 100%, 40%);">- * @param device Logical device number.</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_slot_pnp(u16 port, u16 device)</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%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     for (dev = all_devices; dev; dev = dev->next) {</span><br><span style="color: hsl(0, 100%, 40%);">-              if ((dev->path.type == DEVICE_PATH_PNP) &&</span><br><span style="color: hsl(0, 100%, 40%);">-               (dev->path.pnp.port == port) &&</span><br><span style="color: hsl(0, 100%, 40%);">-              (dev->path.pnp.device == device)) {</span><br><span style="color: hsl(0, 100%, 40%);">-                      return dev;</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 0;</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>  * Given a Local APIC ID, find the device structure.</span><br><span>  *</span><br><span>  * @param apic_id The Local APIC ID number.</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/26292">change 26292</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/26292"/><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: Iec0a11d67d7641996f26b3a01352be762006ebb6 </div>
<div style="display:none"> Gerrit-Change-Number: 26292 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>