From patchwork Tue Aug 7 16:10:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 1286961 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8C3EF3FC23 for ; Tue, 7 Aug 2012 16:24:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754513Ab2HGQTY (ORCPT ); Tue, 7 Aug 2012 12:19:24 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:51364 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163Ab2HGQTW (ORCPT ); Tue, 7 Aug 2012 12:19:22 -0400 Received: by pbbrr13 with SMTP id rr13so4529963pbb.19 for ; Tue, 07 Aug 2012 09:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=VGHMSDDpAb59kKIdPDHAO4DFfWjOK31pCg/lzm6mfnY=; b=C2k6S7zhj1m8eIYTkTyclQmiWf6uNSlWg8fq5rvt0GEeptTNaitUS7aRR+0mkV3Fsx vKf2nGCI+K5jHzpgDimX5RFvmX/J5jKyLIDLMuvxGJ67RH4ss1/Z/O8nLm1HCnmmxux0 Wez7ALBVpOvhaHmxfIWeE4qtB+bIaphNbXXOIafJbiQRwhfpBNdsRrDnhTyfbLKji2Xm 7LzT89SVRS8bQvPhMw90AKCv5CqYFAT9OeJpev6cuvHJNwrvvFVD1IY1guqfIG2B9RjP WU6M//dt/085bA4Kup5pYWMvuo142KcMw2v8RGqvlmO/Yx1+H2MfWkGW+PK9hdGpbVU8 Ee9g== Received: by 10.68.231.40 with SMTP id td8mr29427066pbc.150.1344356362218; Tue, 07 Aug 2012 09:19:22 -0700 (PDT) Received: from localhost.localdomain ([58.250.81.2]) by mx.google.com with ESMTPS id pt2sm11429362pbb.58.2012.08.07.09.19.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Aug 2012 09:19:21 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile , Yinghai Lu , Greg KH , Kenji Kaneshige Cc: Jiang Liu , Taku Izumi , "Rafael J . Wysocki" , Yijing Wang , Xinwei Hu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu Subject: [RFC PATCH v1 05/22] PCI: introduce pci_bus_{get|put}() to manage PCI bus reference count Date: Wed, 8 Aug 2012 00:10:45 +0800 Message-Id: <1344355862-2726-6-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1344355862-2726-1-git-send-email-jiang.liu@huawei.com> References: <1344355862-2726-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 Sometimes PCI hotplug drivers need to hold a reference count on a PCI bus, so introduce pci_bus_{get|put}() to manage PCI bus reference count. Signed-off-by: Jiang Liu --- drivers/pci/bus.c | 15 +++++++++++++++ include/linux/pci.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index e2a0c52..0e18270 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -325,6 +325,21 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), } EXPORT_SYMBOL_GPL(pci_walk_bus); +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); + EXPORT_SYMBOL(pci_bus_alloc_resource); EXPORT_SYMBOL_GPL(pci_bus_add_device); EXPORT_SYMBOL(pci_bus_add_devices); diff --git a/include/linux/pci.h b/include/linux/pci.h index 95479cd..21fa79e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -955,6 +955,8 @@ 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 */ +struct pci_bus *pci_bus_get(struct pci_bus *bus); +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);