Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754266Ab3EZP5i (ORCPT ); Sun, 26 May 2013 11:57:38 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:46125 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754086Ab3EZP52 (ORCPT ); Sun, 26 May 2013 11:57:28 -0400 From: Jiang Liu To: Bjorn Helgaas , Yinghai Lu Cc: Jiang Liu , "Rafael J . Wysocki" , Greg Kroah-Hartman , Gu Zheng , Toshi Kani , Myron Stowe , Yijing Wang , Jiang Liu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3, part2 04/20] PCI, IOV: hold a reference to PCI bus when creating virtual PCI devices Date: Sun, 26 May 2013 23:53:01 +0800 Message-Id: <1369583597-3801-5-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1369583597-3801-1-git-send-email-jiang.liu@huawei.com> References: <1369583597-3801-1-git-send-email-jiang.liu@huawei.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1568 Lines: 60 Also use new iterator to walk PCI devices of a PCI bus. Signed-off-by: Jiang Liu --- drivers/pci/iov.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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; } -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/