diff mbox

[v3,part2,04/20] PCI, IOV: hold a reference to PCI bus when creating virtual PCI devices

Message ID 1369583597-3801-5-git-send-email-jiang.liu@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Jiang Liu May 26, 2013, 3:53 p.m. UTC
Also use new iterator to walk PCI devices of a PCI bus.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
---
 drivers/pci/iov.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 5eb8165..4b796d6 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -36,19 +36,17 @@  static struct pci_bus *virtfn_add_bus(struct pci_bus *bus, int busnr)
 	struct pci_bus *child;
 
 	if (bus->number == busnr)
-		return bus;
+		return pci_bus_get(bus);
 
-	child = pci_find_bus(pci_domain_nr(bus), busnr);
+	child = pci_get_bus(pci_domain_nr(bus), busnr);
 	if (child)
 		return child;
 
 	child = pci_add_new_bus(bus, NULL, busnr);
-	if (!child)
-		return NULL;
-
-	pci_bus_insert_busn_res(child, busnr, busnr);
+	if (child)
+		pci_bus_insert_busn_res(child, busnr, busnr);
 
-	return child;
+	return pci_bus_get(child);
 }
 
 static void virtfn_remove_bus(struct pci_bus *physbus, struct pci_bus *virtbus)
@@ -113,6 +111,7 @@  static int virtfn_add(struct pci_dev *dev, int id, int reset)
 		goto failed2;
 
 	kobject_uevent(&virtfn->dev.kobj, KOBJ_CHANGE);
+	pci_bus_put(bus);
 
 	return 0;
 
@@ -125,6 +124,7 @@  failed1:
 	virtfn_remove_bus(dev->bus, bus);
 failed0:
 	mutex_unlock(&iov->dev->sriov->lock);
+	pci_bus_put(bus);
 
 	return rc;
 }