[PATCH 1/11] portdrv: remove redundant pcie_port_device_probe

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

 



We don't need pcie_port_device_probe() because we can get pci
device/port type using pci_is_pcie() and 'pcie_type' fields in struct
pci_dev. Remove pcie_port_device_probe().

Signed-off-by: Kenji Kaneshige <kaneshige.kenji@xxxxxxxxxxxxxx>

---
 drivers/pci/pcie/portdrv.h      |    1 -
 drivers/pci/pcie/portdrv_core.c |   22 ----------------------
 drivers/pci/pcie/portdrv_pci.c  |   14 ++++++++------
 3 files changed, 8 insertions(+), 29 deletions(-)

Index: 20091125/drivers/pci/pcie/portdrv.h
===================================================================
--- 20091125.orig/drivers/pci/pcie/portdrv.h
+++ 20091125/drivers/pci/pcie/portdrv.h
@@ -35,7 +35,6 @@
 #define get_descriptor_id(type, service) (((type - 4) << 4) | service)
 
 extern struct bus_type pcie_port_bus_type;
-extern int pcie_port_device_probe(struct pci_dev *dev);
 extern int pcie_port_device_register(struct pci_dev *dev);
 #ifdef CONFIG_PM
 extern int pcie_port_device_suspend(struct device *dev);
Index: 20091125/drivers/pci/pcie/portdrv_pci.c
===================================================================
--- 20091125.orig/drivers/pci/pcie/portdrv_pci.c
+++ 20091125/drivers/pci/pcie/portdrv_pci.c
@@ -67,14 +67,16 @@ static struct dev_pm_ops pcie_portdrv_pm
  * this port device.
  *
  */
-static int __devinit pcie_portdrv_probe (struct pci_dev *dev, 
-				const struct pci_device_id *id )
+static int __devinit pcie_portdrv_probe(struct pci_dev *dev,
+					const struct pci_device_id *id)
 {
-	int			status;
+	int status;
 
-	status = pcie_port_device_probe(dev);
-	if (status)
-		return status;
+	if (!pci_is_pcie(dev) ||
+	    ((dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT) &&
+	     (dev->pcie_type != PCI_EXP_TYPE_UPSTREAM) &&
+	     (dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM)))
+		return -ENODEV;
 
         if (!dev->irq && dev->pin) {
 		dev_warn(&dev->dev, "device [%04x:%04x] has invalid IRQ; "
Index: 20091125/drivers/pci/pcie/portdrv_core.c
===================================================================
--- 20091125.orig/drivers/pci/pcie/portdrv_core.c
+++ 20091125/drivers/pci/pcie/portdrv_core.c
@@ -297,28 +297,6 @@ static struct pcie_device* alloc_pcie_de
 }
 
 /**
- * pcie_port_device_probe - check if device is a PCI Express port
- * @dev: Device to check
- */
-int pcie_port_device_probe(struct pci_dev *dev)
-{
-	int pos, type;
-	u16 reg;
-
-	pos = pci_pcie_cap(dev);
-	if (!pos)
-		return -ENODEV;
-
-	pci_read_config_word(dev, pos + PCIE_CAPABILITIES_REG, &reg);
-	type = (reg >> 4) & PORT_TYPE_MASK;
-	if (	type == PCIE_RC_PORT || type == PCIE_SW_UPSTREAM_PORT ||
-		type == PCIE_SW_DOWNSTREAM_PORT )
-		return 0;
-
-	return -ENODEV;
-}
-
-/**
  * pcie_port_device_register - register PCI Express port
  * @dev: PCI Express port to register
  *

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux