[PATCH] PCI: centralize the capabilities code in probe.c

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

 



This patch centralizes the initialization and release functions of
various PCI capabilities in probe.c, which makes the introduction
of new capability support functions cleaner in the future.

Signed-off-by: Yu Zhao <yu.zhao@xxxxxxxxx>

---
drivers/pci/probe.c |   27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index d409e67..0647bd3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -844,6 +844,11 @@ static int pci_setup_device(struct pci_dev * dev)
	return 0;
}

+static void pci_release_capabilities(struct pci_dev *dev)
+{
+	pci_vpd_release(dev);
+}
+
/**
 * pci_release_dev - free a pci device structure when all users of it are finished.
 * @dev: device that's been disconnected
@@ -856,7 +861,7 @@ static void pci_release_dev(struct device *dev)
	struct pci_dev *pci_dev;

	pci_dev = to_pci_dev(dev);
-	pci_vpd_release(pci_dev);
+	pci_release_capabilities(pci_dev);
	kfree(pci_dev);
}

@@ -937,8 +942,6 @@ struct pci_dev *alloc_pci_dev(void)

	INIT_LIST_HEAD(&dev->bus_list);

-	pci_msi_init_pci_dev(dev);
-
	return dev;
}
EXPORT_SYMBOL(alloc_pci_dev);
@@ -1006,11 +1009,21 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
		return NULL;
	}

-	pci_vpd_pci22_init(dev);
-
	return dev;
}

+static void pci_init_capabilities(struct pci_dev *dev)
+{
+	/* MSI/MSI-X list */
+	pci_msi_init_pci_dev(dev);
+
+	/* Power Management */
+	pci_pm_init(dev);
+
+	/* Vital Product Data */
+	pci_vpd_pci22_init(dev);
+}
+
void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
{
	device_initialize(&dev->dev);
@@ -1027,8 +1040,8 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
	/* Fix up broken headers */
	pci_fixup_device(pci_fixup_header, dev);

-	/* Initialize power management of the device */
-	pci_pm_init(dev);
+	/* Initialize various capabilities */
+	pci_init_capabilities(dev);

	/*
	 * Add the device to our list of discovered devices
--
1.5.6.4

--
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