Commit 18788716 authored by John Rose's avatar John Rose Committed by Greg Kroah-Hartman

[PATCH] PCI Hotplug: create pci_remove_bus()

The following patch implements a pci_remove_bus() that can be used by
hotplug drivers for the removal of root buses.  It also defines a
release function that frees the device struct for pci_bus->bridge when a
root bus class device is unregistered.
Signed-off-by: default avatarJohn Rose <johnrose@austin.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 866a9b85
...@@ -571,6 +571,11 @@ static int pci_cfg_space_size(struct pci_dev *dev) ...@@ -571,6 +571,11 @@ static int pci_cfg_space_size(struct pci_dev *dev)
return PCI_CFG_SPACE_SIZE; return PCI_CFG_SPACE_SIZE;
} }
static void pci_release_bus_bridge_dev(struct device *dev)
{
kfree(dev);
}
/* /*
* Read the config data for a PCI device, sanity-check it * Read the config data for a PCI device, sanity-check it
* and fill in the dev structure... * and fill in the dev structure...
...@@ -772,6 +777,7 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus, ...@@ -772,6 +777,7 @@ struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent, int bus,
memset(dev, 0, sizeof(*dev)); memset(dev, 0, sizeof(*dev));
dev->parent = parent; dev->parent = parent;
dev->release = pci_release_bus_bridge_dev;
sprintf(dev->bus_id, "pci%04x:%02x", pci_domain_nr(b), bus); sprintf(dev->bus_id, "pci%04x:%02x", pci_domain_nr(b), bus);
device_register(dev); device_register(dev);
b->bridge = get_device(dev); b->bridge = get_device(dev);
......
...@@ -59,6 +59,18 @@ int pci_remove_device_safe(struct pci_dev *dev) ...@@ -59,6 +59,18 @@ int pci_remove_device_safe(struct pci_dev *dev)
} }
EXPORT_SYMBOL(pci_remove_device_safe); EXPORT_SYMBOL(pci_remove_device_safe);
void pci_remove_bus(struct pci_bus *b)
{
pci_proc_detach_bus(b);
spin_lock(&pci_bus_lock);
list_del(&b->node);
spin_unlock(&pci_bus_lock);
class_device_unregister(&b->class_dev);
}
EXPORT_SYMBOL(pci_remove_bus);
/** /**
* pci_remove_bus_device - remove a PCI device and any children * pci_remove_bus_device - remove a PCI device and any children
* @dev: the device to remove * @dev: the device to remove
...@@ -77,13 +89,7 @@ void pci_remove_bus_device(struct pci_dev *dev) ...@@ -77,13 +89,7 @@ void pci_remove_bus_device(struct pci_dev *dev)
struct pci_bus *b = dev->subordinate; struct pci_bus *b = dev->subordinate;
pci_remove_behind_bridge(dev); pci_remove_behind_bridge(dev);
pci_proc_detach_bus(b); pci_remove_bus(b);
spin_lock(&pci_bus_lock);
list_del(&b->node);
spin_unlock(&pci_bus_lock);
class_device_unregister(&b->class_dev);
dev->subordinate = NULL; dev->subordinate = NULL;
} }
......
...@@ -712,7 +712,7 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct reso ...@@ -712,7 +712,7 @@ struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct reso
int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
extern struct pci_dev *pci_dev_get(struct pci_dev *dev); extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
extern void pci_dev_put(struct pci_dev *dev); extern void pci_dev_put(struct pci_dev *dev);
extern void pci_remove_bus(struct pci_bus *b);
extern void pci_remove_bus_device(struct pci_dev *dev); extern void pci_remove_bus_device(struct pci_dev *dev);
/* Generic PCI functions exported to card drivers */ /* Generic PCI functions exported to card drivers */
......
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