diff options
author | Luca Coelho <luciano.coelho@intel.com> | 2018-02-18 15:24:51 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2018-02-23 12:33:24 +0100 |
commit | 1c96e546c821aef6e0fb5028d93cc6735a6f3b1c (patch) | |
tree | 6da98686a1b8288e87ed9421b219c34986c3533f /backport/backport-include/linux/pci.h | |
parent | 783d3c5354b91d6432185c99cfb48f34120b2da5 (diff) |
backport: add pcie_find_root_port()
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 <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'backport/backport-include/linux/pci.h')
-rw-r--r-- | backport/backport-include/linux/pci.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/backport/backport-include/linux/pci.h b/backport/backport-include/linux/pci.h index 81c2d57a..67ac40fc 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 */ |