[PATCH v3 4/8] pci: register device after BAR setup

Sebastian Hesselbarth sebastian.hesselbarth at gmail.com
Wed Jul 30 01:39:36 PDT 2014


As soon as pci_register_device is called, a potential driver
will access its registers. This requires BARs to be set up
properly, so move pci_register_device after BAR setup.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
Changelog:
v2->v3:
- new patch

Cc: barebox at lists.infradead.org
Cc: Antony Pavlov <antonynpavlov at gmail.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
Cc: Lucas Stach <l.stach at pengutronix.de>
Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Cc: Ezequiel Garcia <ezequiel.garcia at free-electrons.com>
---
 drivers/pci/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 83d44fc103f7..f58e2c98f185 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -186,9 +186,6 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
 
 		DBG("PCI: %02x:%02x [%04x/%04x]\n", bus->number, dev->devfn, dev->vendor, dev->device);
 
-		list_add_tail(&dev->bus_list, &bus->devices);
-		pci_register_device(dev);
-
 		if (class == PCI_CLASS_BRIDGE_HOST) {
 			DBG("PCI: skip pci host bridge\n");
 			continue;
@@ -235,6 +232,9 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
 			if (dev->resource[bar].flags & IORESOURCE_MEM_64)
 				bar++;
 		}
+
+		list_add_tail(&dev->bus_list, &bus->devices);
+		pci_register_device(dev);
 	}
 
 	/*
-- 
2.0.0




More information about the barebox mailing list