From patchwork Tue Apr 30 11:31:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gu Zheng X-Patchwork-Id: 2504181 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 23A38DF2F2 for ; Tue, 30 Apr 2013 11:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760379Ab3D3LdV (ORCPT ); Tue, 30 Apr 2013 07:33:21 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:48052 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1760270Ab3D3LdT (ORCPT ); Tue, 30 Apr 2013 07:33:19 -0400 X-IronPort-AV: E=Sophos;i="4.87,581,1363104000"; d="scan'208,223";a="7159407" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 30 Apr 2013 19:30:33 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r3UBXEEc029864; Tue, 30 Apr 2013 19:33:18 +0800 Received: from [10.167.233.218] ([10.167.233.218]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013043019313243-921400 ; Tue, 30 Apr 2013 19:31:32 +0800 Message-ID: <517FAB8D.2060702@cn.fujitsu.com> Date: Tue, 30 Apr 2013 19:31:25 +0800 From: Gu Zheng User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1 MIME-Version: 1.0 To: Bjorn Helgaas , Yinghai Lu CC: "linux-pci@vger.kernel.org" , Yasuaki Ishimatsu , Taku Izumi , Jiang Liu , tangchen , Lin Feng , linux-kernel , guz.fnst@cn.fujitsu.com Subject: [PATCH v2 2/4] PCI: introduce pci_bus_get()/pci_bus_put() to hide pci_bus' reference management References: <516FB647.5030203@cn.fujitsu.com> In-Reply-To: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/04/30 19:31:32, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/04/30 19:31:35, Serialize complete at 2013/04/30 19:31:35 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From ff785e84afd2558dd52de8e73c4f75b7563a595b Mon Sep 17 00:00:00 2001 From: Gu Zheng Date: Tue, 30 Apr 2013 17:22:02 +0900 Subject: [PATCH v2 2/4] PCI: introduce pci_bus_get()/pci_bus_put() to hide pci_bus' reference management Signed-off-by: Gu Zheng --- drivers/pci/bus.c | 15 +++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 748f8f3..93f4dc0 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -18,6 +18,21 @@ #include "pci.h" +struct pci_bus *pci_bus_get(struct pci_bus *bus) +{ + if (bus) + get_device(&bus->dev); + return bus; +} +EXPORT_SYMBOL(pci_bus_get); + +void pci_bus_put(struct pci_bus *bus) +{ + if (bus) + put_device(&bus->dev); +} +EXPORT_SYMBOL(pci_bus_put); + void pci_add_resource_offset(struct list_head *resources, struct resource *res, resource_size_t offset) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 6c09949..2581e53 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1020,6 +1020,9 @@ int pci_request_selected_regions_exclusive(struct pci_dev *, int, const char *); void pci_release_selected_regions(struct pci_dev *, int); /* drivers/pci/bus.c */ +extern struct pci_bus *pci_bus_get(struct pci_bus *bus); +extern void pci_bus_put(struct pci_bus *bus); + void pci_add_resource(struct list_head *resources, struct resource *res); void pci_add_resource_offset(struct list_head *resources, struct resource *res, resource_size_t offset);