[PATCH 02/10] backport: add pcie_find_root_port()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luca Coelho <luciano.coelho@xxxxxxxxx>

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@xxxxxxxxx>
---
 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 */
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux