PCI: pcie_portdriver: fix pcie_port_device_remove
pcie_port_device_remove currently calls the remove method of port drivers twice. Ouch! We are calling device_for_each_child multiple times for no apparent reason. So make it simple. Place put_device and device_unregister into remove_iter, and throw out the rest. Only call device_for_each_child once. The code is simpler and actually works! Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
This commit is contained in:
parent
10a0ef39fb
commit
ae40582e99
1 changed files with 3 additions and 20 deletions
|
@ -456,16 +456,9 @@ int pcie_port_device_resume(struct pci_dev *dev)
|
||||||
|
|
||||||
static int remove_iter(struct device *dev, void *data)
|
static int remove_iter(struct device *dev, void *data)
|
||||||
{
|
{
|
||||||
struct pcie_port_service_driver *service_driver;
|
|
||||||
|
|
||||||
if (dev->bus == &pcie_port_bus_type) {
|
if (dev->bus == &pcie_port_bus_type) {
|
||||||
if (dev->driver) {
|
put_device(dev);
|
||||||
service_driver = to_service_driver(dev->driver);
|
device_unregister(dev);
|
||||||
if (service_driver->remove)
|
|
||||||
service_driver->remove(to_pcie_device(dev));
|
|
||||||
}
|
|
||||||
*(unsigned long*)data = (unsigned long)dev;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -480,18 +473,8 @@ static int remove_iter(struct device *dev, void *data)
|
||||||
void pcie_port_device_remove(struct pci_dev *dev)
|
void pcie_port_device_remove(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
struct pcie_port_data *port_data = pci_get_drvdata(dev);
|
struct pcie_port_data *port_data = pci_get_drvdata(dev);
|
||||||
int status;
|
|
||||||
|
|
||||||
do {
|
device_for_each_child(&dev->dev, NULL, remove_iter);
|
||||||
unsigned long device_addr;
|
|
||||||
|
|
||||||
status = device_for_each_child(&dev->dev, &device_addr, remove_iter);
|
|
||||||
if (status) {
|
|
||||||
struct device *device = (struct device*)device_addr;
|
|
||||||
put_device(device);
|
|
||||||
device_unregister(device);
|
|
||||||
}
|
|
||||||
} while (status);
|
|
||||||
|
|
||||||
switch (port_data->port_irq_mode) {
|
switch (port_data->port_irq_mode) {
|
||||||
case PCIE_PORT_MSIX_MODE:
|
case PCIE_PORT_MSIX_MODE:
|
||||||
|
|
Loading…
Reference in a new issue