From patchwork Mon May 13 16:08:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2559361 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 BF553DF2E5 for ; Mon, 13 May 2013 16:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754974Ab3EMQI7 (ORCPT ); Mon, 13 May 2013 12:08:59 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:39745 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754565Ab3EMQI5 (ORCPT ); Mon, 13 May 2013 12:08:57 -0400 Received: by mail-pa0-f50.google.com with SMTP id fb10so4698455pad.23 for ; Mon, 13 May 2013 09:08:56 -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=qM0z3EgAVO70bQ7ycNplrNmn1TcCJcsOdnlxMs4DPTA=; b=tfApsMIgE72DKGj2Tl3LG2eXYYUDwIEjU5DG8SRiGutsPGeMHg82SbTwQaSgzIygPy exogabVxGSfYUbGqyPZ6ZUfv+xXs9hdBVVSxTCj8FtCJwB/RlYT6R4O1gKRVwn570gp0 s8CYXNfJrRttB66PTnblpxMW0eohvg0Zy72BsrsmQwn5uDDHpulHTy6HcBM0wy3Lgqqv YT/qqxACvoU6ow1EZFTm9h3pHig/uv0CPEwAWv4b+HB1q8YbrdddHUcxNafsRdZ/Z3oD dFG85phuDuL44aR70RUjHQ0YOG9AB3E770KVbUmjvLEmIgBInXjkYSNuIWME2c7maX1G Xw6A== X-Received: by 10.68.239.228 with SMTP id vv4mr28508071pbc.5.1368461336802; Mon, 13 May 2013 09:08:56 -0700 (PDT) Received: from localhost.localdomain ([120.196.98.100]) by mx.google.com with ESMTPSA id nt2sm14580193pbc.17.2013.05.13.09.08.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 May 2013 09:08:55 -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 v2, part 1 1/9] PCI: introduce pci_bus_{get|put}() to manage PCI bus reference count Date: Tue, 14 May 2013 00:08:25 +0800 Message-Id: <1368461313-4371-2-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 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 748f8f3..f7e1f76 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -282,6 +282,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 e19d864..f5e13f0 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1017,6 +1017,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);