From 3bd6df441f66efb88241ba66cbf854218eee825c Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Wed, 25 Jul 2012 08:48:41 -0400 Subject: [PATCH 5/7] PCI: Add pcibios_add_device Platforms may want to provide architecture-specific functionality during PCI enumeration. Add a pcibios_add_device() call that architectures can override to do so. Signed-off-by: Matthew Garrett --- drivers/pci/bus.c | 5 +++++ drivers/pci/pci.c | 13 +++++++++++++ include/linux/pci.h | 1 + 3 files changed, 19 insertions(+) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 4ce5ef2..4efd1a8 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -164,6 +164,11 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, int pci_bus_add_device(struct pci_dev *dev) { int retval; + + retval = pcibios_add_device(dev); + if (retval) + return retval; + retval = device_add(&dev->dev); if (retval) return retval; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 77cb54a..7796e69 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1341,6 +1341,19 @@ void pcim_pin_device(struct pci_dev *pdev) dr->pinned = 1; } +/* + * pcibios_add_device - provide arch specific hooks when adding device dev + * @dev: the PCI device being added + * + * Permits the platform to provide architecture specific functionality when + * devices are added. This is the default implementation. Architecture + * implementations can override this. + */ +int __attribute__ ((weak)) pcibios_add_device (struct pci_dev *dev) +{ + return 0; +} + /** * pcibios_disable_device - disable arch specific PCI resources for device dev * @dev: the PCI device to disable diff --git a/include/linux/pci.h b/include/linux/pci.h index fefb4e1..9a252fe3 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1524,6 +1524,7 @@ void pcibios_disable_device(struct pci_dev *dev); void pcibios_set_master(struct pci_dev *dev); int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); +int pcibios_add_device(struct pci_dev *dev); #ifdef CONFIG_PCI_MMCONFIG extern void __init pci_mmcfg_early_init(void); -- 1.7.10.4