[coreboot-gerrit] New patch to review for coreboot: f787984 devicetree: Single scan_bridges()

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Fri Feb 27 17:33:06 CET 2015


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8540

-gerrit

commit f787984bc9e9bf1aced2109bda53a0cc856f2d45
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Fri Feb 20 21:28:31 2015 +0200

    devicetree: Single scan_bridges()
    
    Change-Id: Ifd277992a69a4182e2fac92aaf746abe4fec2a1b
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/device/device.c         | 21 +++++++++++++++++----
 src/device/pci_device.c     |  7 +------
 src/device/root_device.c    | 11 ++---------
 src/include/device/device.h |  2 +-
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/device/device.c b/src/device/device.c
index 00e323a..b96bbfd 100644
--- a/src/device/device.c
+++ b/src/device/device.c
@@ -911,15 +911,15 @@ int reset_bus(struct bus *bus)
  * @param max Current bus number.
  * @return The maximum bus number found, after scanning all subordinate buses.
  */
-unsigned int scan_bus(struct device *busdev, unsigned int max)
+static unsigned int scan_bus(struct device *busdev, unsigned int max)
 {
 	unsigned int new_max;
 	int do_scan_bus;
 
-	if (!busdev || !busdev->enabled || !busdev->ops ||
-	    !busdev->ops->scan_bus) {
+	if (!busdev->enabled)
 		return max;
-	}
+
+	printk(BIOS_SPEW, "%s scanning...\n", dev_path(busdev));
 
 	post_log_path(busdev);
 
@@ -940,6 +940,19 @@ unsigned int scan_bus(struct device *busdev, unsigned int max)
 	return new_max;
 }
 
+void scan_bridges(struct bus *bus)
+{
+	struct device *child;
+	unsigned int max = bus->secondary;
+
+	for (child = bus->children; child; child = child->sibling) {
+		if (!child->ops || !child->ops->scan_bus)
+			continue;
+		max = scan_bus(child, max);
+	}
+	bus->subordinate = max;
+}
+
 /**
  * Determine the existence of devices and extend the device tree.
  *
diff --git a/src/device/pci_device.c b/src/device/pci_device.c
index dc7365f..b1e2bbd 100644
--- a/src/device/pci_device.c
+++ b/src/device/pci_device.c
@@ -1083,7 +1083,6 @@ void pci_scan_bus(struct bus *bus, unsigned min_devfn,
 {
 	unsigned int devfn;
 	struct device *old_devices;
-	struct device *child;
 
 	printk(BIOS_DEBUG, "PCI: pci_scan_bus for bus %02x\n", bus->secondary);
 
@@ -1144,12 +1143,8 @@ void pci_scan_bus(struct bus *bus, unsigned min_devfn,
 	 * For all children that implement scan_bus() (i.e. bridges)
 	 * scan the bus behind that child.
 	 */
-	unsigned int max = bus->secondary;
 
-	for (child = bus->children; child; child = child->sibling)
-		max = scan_bus(child, max);
-
-	bus->subordinate = max;
+	scan_bridges(bus);
 
 	/*
 	 * We've scanned the bus and so we know all about what's on the other
diff --git a/src/device/root_device.c b/src/device/root_device.c
index e380d31..ae2f7f0 100644
--- a/src/device/root_device.c
+++ b/src/device/root_device.c
@@ -125,7 +125,6 @@ unsigned int scan_smbus(device_t bus, unsigned int passthru)
  */
 static unsigned int root_dev_scan_bus(device_t bus, unsigned int passthru)
 {
-	device_t child;
 	struct bus *link;
 	unsigned int max = 0;
 
@@ -133,14 +132,8 @@ static unsigned int root_dev_scan_bus(device_t bus, unsigned int passthru)
 
 	scan_static_bus(bus, 0);
 
-	for (link = bus->link_list; link; link = link->next) {
-		for (child = link->children; child; child = child->sibling) {
-			if (!child->ops || !child->ops->scan_bus)
-				continue;
-			printk(BIOS_SPEW, "%s scanning...\n", dev_path(child));
-			max = scan_bus(child, max);
-		}
-	}
+	for (link = bus->link_list; link; link = link->next)
+		scan_bridges(link);
 
 	printk(BIOS_SPEW, "%s for %s done\n", __func__, dev_path(bus));
 
diff --git a/src/include/device/device.h b/src/include/device/device.h
index d626165..e1349b2 100644
--- a/src/include/device/device.h
+++ b/src/include/device/device.h
@@ -175,7 +175,7 @@ void dev_finalize_chips(void);
 
 /* Generic device helper functions */
 int reset_bus(struct bus *bus);
-unsigned int scan_bus(struct device *bus, unsigned int _max);
+void scan_bridges(struct bus *bus);
 void assign_resources(struct bus *bus);
 const char *dev_name(device_t dev);
 const char *dev_path(device_t dev);



More information about the coreboot-gerrit mailing list