From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030432AbdIZOR0 (ORCPT ); Tue, 26 Sep 2017 10:17:26 -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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,441,1500966000"; d="scan'208";a="1199177786" 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 2.14.1