From patchwork Sun Feb 18 13:24:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 10226765 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 1B9B2602DC for ; Sun, 18 Feb 2018 13:55:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B90C28A03 for ; Sun, 18 Feb 2018 13:55:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 007BB28AEF; Sun, 18 Feb 2018 13:55:47 +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=ham 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 A1EC628A03 for ; Sun, 18 Feb 2018 13:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbeBRNzr (ORCPT ); Sun, 18 Feb 2018 08:55:47 -0500 Received: from paleale.coelho.fi ([176.9.41.70]:59522 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751335AbeBRNzr (ORCPT ); Sun, 18 Feb 2018 08:55:47 -0500 Received: from 91-156-4-241.elisa-laajakaista.fi ([91.156.4.241] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1enOxo-0001N7-5b; Sun, 18 Feb 2018 15:25:08 +0200 From: Luca Coelho To: backports@vger.kernel.org Cc: Luca Coelho Date: Sun, 18 Feb 2018 15:24:51 +0200 Message-Id: <20180218132459.11011-3-luca@coelho.fi> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180218132459.11011-1-luca@coelho.fi> References: <20180218132459.11011-1-luca@coelho.fi> X-SA-Exim-Connect-IP: 91.156.4.241 X-SA-Exim-Mail-From: luca@coelho.fi Subject: [PATCH 02/10] backport: add pcie_find_root_port() X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on farmhouse.coelho.fi) Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luca Coelho This function was introduced in v4.9 and added to 3.12.69, 4.4.37 and 4.8.13. Signed-off-by: Luca Coelho --- backport/backport-include/linux/pci.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/backport/backport-include/linux/pci.h b/backport/backport-include/linux/pci.h index 81c2d57a3454..67ac40fcbf58 100644 --- a/backport/backport-include/linux/pci.h +++ b/backport/backport-include/linux/pci.h @@ -184,4 +184,25 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev, #endif #endif /* CONFIG_PCI */ +#if LINUX_VERSION_IS_LESS(4,9,0) && \ + !LINUX_VERSION_IN_RANGE(3,12,69, 3,13,0) && \ + !LINUX_VERSION_IN_RANGE(4,4,37, 4,5,0) && \ + !LINUX_VERSION_IN_RANGE(4,8,13, 4,9,0) + +static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev) +{ + while (1) { + if (!pci_is_pcie(dev)) + break; + if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) + return dev; + if (!dev->bus->self) + break; + dev = dev->bus->self; + } + return NULL; +} + +#endif/* <4.9.0 but not >= 3.12.69, 4.4.37, 4.8.13 */ + #endif /* _BACKPORT_LINUX_PCI_H */