[coreboot-gerrit] Change in coreboot[master]: device: Always build device_simple.c for less code duplication

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


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


Change subject: device: Always build device_simple.c for less code duplication
......................................................................

device: Always build device_simple.c for less code duplication

Change-Id: Iec0a11d67d7641996f26b3a01352be762006ebb6
Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
M src/device/Makefile.inc
M src/device/device.c
M src/device/device_simple.c
M src/device/device_util.c
4 files changed, 9 insertions(+), 51 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/92/26292/1

diff --git a/src/device/Makefile.inc b/src/device/Makefile.inc
index 82d4b36..e86aa2c 100644
--- a/src/device/Makefile.inc
+++ b/src/device/Makefile.inc
@@ -26,6 +26,7 @@
 smm-y += device_simple.c
 verstage-y += device_simple.c
 romstage-y += device_simple.c
+ramstage-y += device_simple.c
 romstage-$(CONFIG_PCI) += pci_early.c
 
 subdirs-y += oprom dram
diff --git a/src/device/device.c b/src/device/device.c
index 02209d9..1cee963 100644
--- a/src/device/device.c
+++ b/src/device/device.c
@@ -51,8 +51,6 @@
 #endif
 #include <timer.h>
 
-/** Linked list of ALL devices */
-struct device *all_devices = &dev_root;
 /** Pointer to the last device */
 extern struct device *last_dev;
 /** Linked list of free resources */
diff --git a/src/device/device_simple.c b/src/device/device_simple.c
index e6a6e8f..b5eade2 100644
--- a/src/device/device_simple.c
+++ b/src/device/device_simple.c
@@ -23,6 +23,7 @@
 #include <device/path.h>
 #include <device/pci.h>
 #include <device/resource.h>
+#include <stddef.h>
 
 /** Linked list of ALL devices */
 DEVTREE_CONST struct device * DEVTREE_CONST all_devices = &dev_root;
@@ -39,11 +40,13 @@
 {
 	DEVTREE_CONST struct device *dev, *result;
 
-	printk(BIOS_WARNING,
-		"WARNING: Using the simple device version of %s() "
-		"is considered\ndangerous. Secondary bus numbers are not "
-		"available, yet. Please update the\n code of your platform.\n",
-		__func__);
+	if (DEVTREE_EARLY) {
+		printk(BIOS_WARNING,
+			"WARNING: Using the simple device version of %s() "
+			"is considered\ndangerous. Secondary bus numbers are "
+			"not available, yet. Please update the\n code of your "
+			"platform.\n", __func__);
+	}
 
 	result = 0;
 	for (dev = all_devices; dev; dev = dev->next) {
diff --git a/src/device/device_util.c b/src/device/device_util.c
index aad3b4b..85b794a 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -44,29 +44,6 @@
 }
 
 /**
- * Given a PCI bus and a devfn number, find the device structure.
- *
- * @param bus The bus number.
- * @param devfn A device/function number.
- * @return Pointer to the device structure (if found), 0 otherwise.
- */
-struct device *dev_find_slot(unsigned int bus, unsigned int devfn)
-{
-	struct device *dev, *result;
-
-	result = 0;
-	for (dev = all_devices; dev; dev = dev->next) {
-		if ((dev->path.type == DEVICE_PATH_PCI) &&
-		    (dev->bus->secondary == bus) &&
-		    (dev->path.pci.devfn == devfn)) {
-			result = dev;
-			break;
-		}
-	}
-	return result;
-}
-
-/**
  * Given an SMBus bus and a device number, find the device structure.
  *
  * @param bus The bus number.
@@ -90,27 +67,6 @@
 }
 
 /**
- * Given a PnP port and a device number, find the device structure.
- *
- * @param port The I/O port.
- * @param device Logical device number.
- * @return Pointer to the device structure (if found), 0 otherwise.
- */
-struct device *dev_find_slot_pnp(u16 port, u16 device)
-{
-	struct device *dev;
-
-	for (dev = all_devices; dev; dev = dev->next) {
-		if ((dev->path.type == DEVICE_PATH_PNP) &&
-		    (dev->path.pnp.port == port) &&
-		    (dev->path.pnp.device == device)) {
-			return dev;
-		}
-	}
-	return 0;
-}
-
-/**
  * Given a Local APIC ID, find the device structure.
  *
  * @param apic_id The Local APIC ID number.

-- 
To view, visit https://review.coreboot.org/26292
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: Iec0a11d67d7641996f26b3a01352be762006ebb6
Gerrit-Change-Number: 26292
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/b0b7a094/attachment-0001.html>


More information about the coreboot-gerrit mailing list