From patchwork Tue Sep 26 14:17:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 9972171 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C74846037E for ; Tue, 26 Sep 2017 14:19:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6F2F1FF0B for ; Tue, 26 Sep 2017 14:19:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABBBA2885A; Tue, 26 Sep 2017 14:19:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53F371FF0B for ; Tue, 26 Sep 2017 14:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969431AbdIZORZ (ORCPT ); Tue, 26 Sep 2017 10:17:25 -0400 Received: from mga11.intel.com ([192.55.52.93]:56468 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965228AbdIZORY (ORCPT ); Tue, 26 Sep 2017 10:17:24 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2017 07:17:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,441,1500966000"; d="scan'208";a="1199177786" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Sep 2017 07:17:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 53495EB; Tue, 26 Sep 2017 17:17:20 +0300 (EEST) From: Mika Westerberg To: Bjorn Helgaas Cc: Ashok Raj , Keith Busch , "Rafael J . Wysocki" , Lukas Wunner , Michael Jamet , Yehezkel Bernat , Mario.Limonciello@dell.com, Mika Westerberg , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] PCI: Introduce pcie_upstream_port() Date: Tue, 26 Sep 2017 17:17:15 +0300 Message-Id: <20170926141720.25067-3-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170926141720.25067-1-mika.westerberg@linux.intel.com> References: <20170926141720.25067-1-mika.westerberg@linux.intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This helper allows to determine whether the PCI device is PCIe upstream port. Signed-off-by: Mika Westerberg --- include/linux/pci.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index f68c58a93dd0..4397692be538 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2042,6 +2042,17 @@ static inline int pci_pcie_type(const struct pci_dev *dev) return (pcie_caps_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4; } +/** + * pcie_upstream_port - is the PCI device PCIe upstream port + * @dev: PCI device + */ +static inline bool pcie_upstream_port(struct pci_dev *dev) +{ + if (!pci_is_pcie(dev)) + return false; + return pci_pcie_type(dev) == PCI_EXP_TYPE_UPSTREAM; +} + static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev) { while (1) {