diff mbox

[3/4] PCI: fix locking for pci_find_upstream_pcie_bridge and add declaration

Message ID 20101118135237.2269.96220.sendpatchset@localhost6.localdomain6 (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Assmann Nov. 18, 2010, 1:52 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 9d75dc8..c8159b0 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -29,6 +29,8 @@  pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
 
 	if (pci_is_pcie(pdev))
 		return NULL;
+
+	down_read(&pci_bus_sem);
 	while (1) {
 		if (pci_is_root_bus(pdev->bus))
 			break;
@@ -38,6 +40,7 @@  pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
 			tmp = pdev;
 			continue;
 		}
+		up_read(&pci_bus_sem);
 		/* PCI device should connect to a PCIe bridge */
 		if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) {
 			/* Busted hardware? */
@@ -46,6 +49,7 @@  pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
 		}
 		return pdev;
 	}
+	up_read(&pci_bus_sem);
 
 	return tmp;
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7454408..7acb6b2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -698,6 +698,7 @@  int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn,
 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
 struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
+struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev);
 
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
 				struct pci_dev *from);
@@ -1208,6 +1209,8 @@  static inline void pci_unblock_user_cfg_access(struct pci_dev *dev)
 
 static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
 { return NULL; }
+static inline struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
+{ return NULL; }
 
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)