lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211110221456.11977-5-jim2101024@gmail.com>
Date:   Wed, 10 Nov 2021 17:14:44 -0500
From:   Jim Quinlan <jim2101024@...il.com>
To:     linux-pci@...r.kernel.org, Bjorn Helgaas <bhelgaas@...gle.com>,
        Nicolas Saenz Julienne <nsaenz@...nel.org>,
        Rob Herring <robh@...nel.org>, Mark Brown <broonie@...nel.org>,
        bcm-kernel-feedback-list@...adcom.com, jim2101024@...il.com,
        james.quinlan@...adcom.com
Cc:     Sean V Kelley <sean.v.kelley@...el.com>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Qiuxu Zhuo <qiuxu.zhuo@...el.com>,
        Keith Busch <kbusch@...nel.org>,
        linux-kernel@...r.kernel.org (open list)
Subject: [PATCH v8 4/8] PCI/portdrv: Create pcie_is_port_dev() func from existing code

The function will be needed elsewhere in a few commits.

Signed-off-by: Jim Quinlan <jim2101024@...il.com>
---
 drivers/pci/pci.h              |  2 ++
 drivers/pci/pcie/portdrv_pci.c | 23 ++++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 1cce56c2aea0..c2bd1995d3a9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -744,4 +744,6 @@ extern const struct attribute_group aspm_ctrl_attr_group;
 
 extern const struct attribute_group pci_dev_reset_method_attr_group;
 
+bool pcie_is_port_dev(struct pci_dev *dev);
+
 #endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index c7ff1eea225a..63f2a87e9db8 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -90,6 +90,23 @@ static const struct dev_pm_ops pcie_portdrv_pm_ops = {
 #define PCIE_PORTDRV_PM_OPS	NULL
 #endif /* !PM */
 
+bool pcie_is_port_dev(struct pci_dev *dev)
+{
+	int type;
+
+	if (!dev)
+		return false;
+
+	type = pci_pcie_type(dev);
+
+	return pci_is_pcie(dev) &&
+		((type == PCI_EXP_TYPE_ROOT_PORT) ||
+		 (type == PCI_EXP_TYPE_UPSTREAM) ||
+		 (type == PCI_EXP_TYPE_DOWNSTREAM) ||
+		 (type == PCI_EXP_TYPE_RC_EC));
+}
+EXPORT_SYMBOL_GPL(pcie_is_port_dev);
+
 /*
  * pcie_portdrv_probe - Probe PCI-Express port devices
  * @dev: PCI-Express port device being probed
@@ -104,11 +121,7 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
 	int type = pci_pcie_type(dev);
 	int status;
 
-	if (!pci_is_pcie(dev) ||
-	    ((type != PCI_EXP_TYPE_ROOT_PORT) &&
-	     (type != PCI_EXP_TYPE_UPSTREAM) &&
-	     (type != PCI_EXP_TYPE_DOWNSTREAM) &&
-	     (type != PCI_EXP_TYPE_RC_EC)))
+	if (!pcie_is_port_dev(dev))
 		return -ENODEV;
 
 	if (type == PCI_EXP_TYPE_RC_EC)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ