From patchwork Sat May 25 13:48:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2613541 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 2CD5DDF2A2 for ; Sat, 25 May 2013 13:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756477Ab3EYNvQ (ORCPT ); Sat, 25 May 2013 09:51:16 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:42594 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756447Ab3EYNvO (ORCPT ); Sat, 25 May 2013 09:51:14 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa10so5313343pad.33 for ; Sat, 25 May 2013 06:51:13 -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=okfJIrvFeA8hjHAdfLN43Vs5kL1DyxMTPXQgs+eG1LU=; b=Behr2MViUwukBNzba37suHCCnOHmagIHW6VJbtF+IavOrwa9JxvkqAXLUnM1ixLBtq chNm8t3DKgu2ek8qgwCkwCB6tXlEFuwNWc35R/HnSbPcspByWxhw9+wG2ccKLvfgTgLr SlIZ1trU2j93BNdM4O6PZ7YDPWkbP6aNdEW2vGx6AAW9J/0eot8BtvbYgAdDnmbvEHCu IUdYA+KHENegYqH/2RZHs8La//NjoXjZh7jB5ElYgZ8HtkdcttniK5EL6/x0Wq0Z48rW dzobzp7wQRX8mL4/bLmVXErl/HqoDSWSt3L7UQmSCJ3xzc5OlNU6HU4aHcUeFYVIVJjK y1Yg== X-Received: by 10.66.232.196 with SMTP id tq4mr22959754pac.167.1369489873523; Sat, 25 May 2013 06:51:13 -0700 (PDT) Received: from localhost.localdomain ([114.250.94.230]) by mx.google.com with ESMTPSA id b7sm20545858pba.39.2013.05.25.06.51.08 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 25 May 2013 06:51:11 -0700 (PDT) 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, part1 01/10] PCI: introduce pci_bus_{get|put}() to manage PCI bus reference count Date: Sat, 25 May 2013 21:48:29 +0800 Message-Id: <1369489718-25869-2-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1369489718-25869-1-git-send-email-jiang.liu@huawei.com> References: <1369489718-25869-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 Introduce helper functions pci_bus_{get|put}() to manage PCI bus reference count. Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang Signed-off-by: Gu Zheng Cc: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- 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 32e66a6..b1ff02a 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -283,6 +283,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 3a24e4f..7556c59 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1018,6 +1018,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);