From patchwork Tue Sep 15 17:10:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wdavis@nvidia.com X-Patchwork-Id: 518035 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 8CCD2140157 for ; Wed, 16 Sep 2015 03:11:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751465AbbIORLf (ORCPT ); Tue, 15 Sep 2015 13:11:35 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:13399 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751005AbbIORLf (ORCPT ); Tue, 15 Sep 2015 13:11:35 -0400 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Tue, 15 Sep 2015 10:11:25 -0700 Received: from HQMAIL104.nvidia.com ([172.18.146.11]) by hqnvupgp08.nvidia.com (PGP Universal service); Tue, 15 Sep 2015 10:11:20 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Tue, 15 Sep 2015 10:11:20 -0700 Received: from HQMAIL106.nvidia.com (172.18.146.12) by HQMAIL104.nvidia.com (172.18.146.11) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Tue, 15 Sep 2015 17:11:34 +0000 Received: from hqnvemgw01.nvidia.com (172.20.150.20) by HQMAIL106.nvidia.com (172.18.146.12) with Microsoft SMTP Server id 15.0.1044.25 via Frontend Transport; Tue, 15 Sep 2015 17:11:34 +0000 Received: from wdavis-lt.nvidia.com (Not Verified[10.20.168.59]) by hqnvemgw01.nvidia.com with MailMarshal (v7, 1, 2, 5326) id ; Tue, 15 Sep 2015 10:11:34 -0700 From: Will Davis To: Bjorn Helgaas CC: Alex Williamson , Joerg Roedel , , , Konrad Wilk , Mark Hounschell , "David S. Miller" , Jonathan Corbet , Terence Ripperda , John Hubbard , Jerome Glisse , Will Davis Subject: [PATCH 07/22] PCI: Export pci_find_host_bridge() Date: Tue, 15 Sep 2015 12:10:52 -0500 Message-ID: <1442337067-22964-8-git-send-email-wdavis@nvidia.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <1442337067-22964-1-git-send-email-wdavis@nvidia.com> References: <1442337067-22964-1-git-send-email-wdavis@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Return the struct pci_host_bridge corresponding to the given struct pci_bus. Signed-off-by: Will Davis --- drivers/pci/host-bridge.c | 19 ++----------------- include/linux/pci.h | 7 +++++++ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 5f4a2e0..6c2c82a 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -8,25 +8,10 @@ #include "pci.h" -static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) -{ - while (bus->parent) - bus = bus->parent; - - return bus; -} - -struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus) -{ - struct pci_bus *root_bus = find_pci_root_bus(bus); - - return to_pci_host_bridge(root_bus->bridge); -} - struct device *pci_get_host_bridge_device(struct pci_dev *dev) { - struct pci_bus *root_bus = find_pci_root_bus(dev->bus); - struct device *bridge = root_bus->bridge; + struct pci_host_bridge *host_bridge = pci_find_host_bridge(dev->bus); + struct device *bridge = &host_bridge->dev; kobject_get(&bridge->kobj); return bridge; diff --git a/include/linux/pci.h b/include/linux/pci.h index 8a0321a..d58063e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -512,6 +512,13 @@ static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev) return dev->bus->self; } +static inline struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus) +{ + while (bus->parent) + bus = bus->parent; + return to_pci_host_bridge(bus->bridge); +} + struct device *pci_get_host_bridge_device(struct pci_dev *dev); void pci_put_host_bridge_device(struct device *dev);