From patchwork Mon May 13 16:08:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 243436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2429E2C00A9 for ; Tue, 14 May 2013 02:11:31 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755158Ab3EMQJN (ORCPT ); Mon, 13 May 2013 12:09:13 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:34978 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755087Ab3EMQJH (ORCPT ); Mon, 13 May 2013 12:09:07 -0400 Received: by mail-pb0-f42.google.com with SMTP id up7so4584735pbc.15 for ; Mon, 13 May 2013 09:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=smUDsFNgPoN7HwSPKf92ZrkvbUftUr36Lzq90VtHY74=; b=zZDEaGOOQQu/LQpsFCuNryafEAoy3kHkj78HSvePBMhDZPLeU06lWPm/qEELGiDjL7 9wI7gTJ9rGKbNPVWM8l7e4FpJ2PhxrvQLzxRL6awv5wolCSlIjW4vz0iWvSWkLVVhnqE bLKPLZ9LQ3+1Ret2HLRXV0R5t42eEqZ7Ym4vCrxsoRsF0J3A5FE5lT6YMq5zypKzJpuY nsyEnvHeJjTowoCTUBjcLlwvaVqOz39H1SOVK4vQZUegTo5/YreW31/4jgCPHdf1qn52 5qqKdUb90x/oyklHlxowbdMZgHEHDFfA4tbfVgsJvJe3/sM2IshKSA3K91he5CNPTULh Hxag== X-Received: by 10.68.213.162 with SMTP id nt2mr29416115pbc.179.1368461346992; Mon, 13 May 2013 09:09:06 -0700 (PDT) Received: from localhost.localdomain ([120.196.98.100]) by mx.google.com with ESMTPSA id nt2sm14580193pbc.17.2013.05.13.09.09.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 May 2013 09:09:06 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Yinghai Lu Cc: Gu Zheng , "Rafael J . Wysocki" , Greg Kroah-Hartman , Toshi Kani , Myron Stowe , Yijing Wang , Jiang Liu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , "David S. Miller" , David Airlie , Neela Syam Kolli , "James E.J. Bottomley" , Andrew Morton , linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-scsi@vger.kernel.org, Jiang Liu Subject: [PATCH v2, part 1 3/9] PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus) instead Date: Tue, 14 May 2013 00:08:27 +0800 Message-Id: <1368461313-4371-4-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1368461313-4371-1-git-send-email-jiang.liu@huawei.com> References: <1368461313-4371-1-git-send-email-jiang.liu@huawei.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Gu Zheng From: Gu Zheng Use the new pci_alloc_dev(bus) to replace the existing using of alloc_pci_dev(void). v2: Follow Bjorn's correction to move pci_bus_put() to pci_release_dev() instead. Signed-off-by: Gu Zheng Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: "David S. Miller" Cc: David Airlie Cc: Neela Syam Kolli Cc: "James E.J. Bottomley" Cc: Yinghai Lu Cc: Greg Kroah-Hartman Cc: Andrew Morton Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Cc: sparclinux@vger.kernel.org Cc: linux-pci@vger.kernel.org Cc: linux-scsi@vger.kernel.org Signed-off-by: Jiang Liu --- arch/powerpc/kernel/pci_of_scan.c | 3 +-- arch/sparc/kernel/pci.c | 3 +-- drivers/char/agp/alpha-agp.c | 2 +- drivers/char/agp/parisc-agp.c | 2 +- drivers/pci/iov.c | 8 +++++--- drivers/pci/probe.c | 4 ++-- drivers/scsi/megaraid.c | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 2a67e9b..24d01c4 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c @@ -128,7 +128,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, const char *type; struct pci_slot *slot; - dev = alloc_pci_dev(); + dev = pci_alloc_dev(bus); if (!dev) return NULL; type = of_get_property(node, "device_type", NULL); @@ -137,7 +137,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node, pr_debug(" create device, devfn: %x, type: %s\n", devfn, type); - dev->bus = bus; dev->dev.of_node = of_node_get(node); dev->dev.parent = bus->bridge; dev->dev.bus = &pci_bus_type; diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index baf4366..e5871fb 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c @@ -254,7 +254,7 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, const char *type; u32 class; - dev = alloc_pci_dev(); + dev = pci_alloc_dev(bus); if (!dev) return NULL; @@ -281,7 +281,6 @@ static struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm, printk(" create device, devfn: %x, type: %s\n", devfn, type); - dev->bus = bus; dev->sysdata = node; dev->dev.parent = bus->bridge; dev->dev.bus = &pci_bus_type; diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c index dd84af4..199b8e9 100644 --- a/drivers/char/agp/alpha-agp.c +++ b/drivers/char/agp/alpha-agp.c @@ -174,7 +174,7 @@ alpha_core_agp_setup(void) /* * Build a fake pci_dev struct */ - pdev = alloc_pci_dev(); + pdev = pci_alloc_dev(NULL); if (!pdev) return -ENOMEM; pdev->vendor = 0xffff; diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c index 94821ab..bf5d247 100644 --- a/drivers/char/agp/parisc-agp.c +++ b/drivers/char/agp/parisc-agp.c @@ -333,7 +333,7 @@ parisc_agp_setup(void __iomem *ioc_hpa, void __iomem *lba_hpa) struct agp_bridge_data *bridge; int error = 0; - fake_bridge_dev = alloc_pci_dev(); + fake_bridge_dev = pci_alloc_dev(NULL); if (!fake_bridge_dev) { error = -ENOMEM; goto fail; diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index ee599f2..24134cd 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -75,18 +75,20 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) struct pci_dev *virtfn; struct resource *res; struct pci_sriov *iov = dev->sriov; + struct pci_bus *bus; - virtfn = alloc_pci_dev(); + virtfn = pci_alloc_dev(NULL); if (!virtfn) return -ENOMEM; mutex_lock(&iov->dev->sriov->lock); - virtfn->bus = virtfn_add_bus(dev->bus, virtfn_bus(dev, id)); - if (!virtfn->bus) { + bus = virtfn_add_bus(dev->bus, virtfn_bus(dev, id)); + if (!bus) { kfree(virtfn); mutex_unlock(&iov->dev->sriov->lock); return -ENOMEM; } + virtfn->bus = pci_bus_get(bus); virtfn->devfn = virtfn_devfn(dev, id); virtfn->vendor = dev->vendor; pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4f0bc0a..bc075a3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1131,6 +1131,7 @@ static void pci_release_dev(struct device *dev) struct pci_dev *pci_dev; pci_dev = to_pci_dev(dev); + pci_bus_put(pci_dev->bus); pci_release_capabilities(pci_dev); pci_release_of_node(pci_dev); kfree(pci_dev); @@ -1269,11 +1270,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) return NULL; - dev = alloc_pci_dev(); + dev = pci_alloc_dev(bus); if (!dev) return NULL; - dev->bus = bus; dev->devfn = devfn; dev->vendor = l & 0xffff; dev->device = (l >> 16) & 0xffff; diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 9504ec0..e1660ca 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -2025,7 +2025,7 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor) static inline int make_local_pdev(adapter_t *adapter, struct pci_dev **pdev) { - *pdev = alloc_pci_dev(); + *pdev = pci_alloc_dev(NULL); if( *pdev == NULL ) return -1;