Commit 057bd2e0 authored by Thierry Reding's avatar Thierry Reding Committed by Bjorn Helgaas

PCI: Add pci_ops.{add,remove}_bus() callbacks

Add pci_ops.{add,remove}_bus() callbacks, which will be called on every
newly created bus and when a bus is being removed, respectively.  This can
be used by drivers to implement driver-specific initialization and teardown
of the bus, in addition to the architecture-specifics implemented by the
pcibios_add_bus() and the pcibios_remove_bus() functions.
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 92e963f5
...@@ -758,6 +758,12 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, ...@@ -758,6 +758,12 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
pcibios_add_bus(child); pcibios_add_bus(child);
if (child->ops->add_bus) {
ret = child->ops->add_bus(child);
if (WARN_ON(ret < 0))
dev_err(&child->dev, "failed to add bus: %d\n", ret);
}
/* Create legacy_io and legacy_mem files for this bus */ /* Create legacy_io and legacy_mem files for this bus */
pci_create_legacy_files(child); pci_create_legacy_files(child);
......
...@@ -54,6 +54,10 @@ void pci_remove_bus(struct pci_bus *bus) ...@@ -54,6 +54,10 @@ void pci_remove_bus(struct pci_bus *bus)
pci_bus_release_busn_res(bus); pci_bus_release_busn_res(bus);
up_write(&pci_bus_sem); up_write(&pci_bus_sem);
pci_remove_legacy_files(bus); pci_remove_legacy_files(bus);
if (bus->ops->remove_bus)
bus->ops->remove_bus(bus);
pcibios_remove_bus(bus); pcibios_remove_bus(bus);
device_unregister(&bus->dev); device_unregister(&bus->dev);
} }
......
...@@ -578,6 +578,8 @@ static inline int pcibios_err_to_errno(int err) ...@@ -578,6 +578,8 @@ static inline int pcibios_err_to_errno(int err)
/* Low-level architecture-dependent routines */ /* Low-level architecture-dependent routines */
struct pci_ops { struct pci_ops {
int (*add_bus)(struct pci_bus *bus);
void (*remove_bus)(struct pci_bus *bus);
void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int where); void __iomem *(*map_bus)(struct pci_bus *bus, unsigned int devfn, int where);
int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val); int (*read)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val); int (*write)(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment