@@ -800,11 +800,14 @@ static int __ref enable_device(struct acpiphp_slot *slot)
if (slot->flags & SLOT_ENABLED)
goto err_exit;
+ if (pci_bus_lock_states(bus, PCI_BUS_STATE_WORKING) < 0)
+ return -EINVAL;
+
num = pci_scan_slot(bus, PCI_DEVFN(slot->device, 0));
if (num == 0) {
/* Maybe only part of funcs are added. */
dbg("No new device found\n");
- goto err_exit;
+ goto out_unlock;
}
max = acpiphp_max_busnr(bus);
@@ -862,8 +865,10 @@ static int __ref enable_device(struct acpiphp_slot *slot)
pci_dev_put(dev);
}
+out_unlock:
+ pci_bus_unlock(bus);
- err_exit:
+err_exit:
return retval;
}
@@ -906,6 +911,9 @@ static int disable_device(struct acpiphp_slot *slot)
struct pci_dev *pdev;
struct pci_bus *bus = slot->bridge->pci_bus;
+ if (pci_bus_lock_states(bus, PCI_BUS_STATE_WORKING) < 0)
+ goto err_exit;
+
/* The slot will be enabled when func 0 is added, so check
func 0 before disable the slot. */
pdev = pci_get_slot(bus, PCI_DEVFN(slot->device, 0));
@@ -943,6 +951,7 @@ static int disable_device(struct acpiphp_slot *slot)
}
slot->flags &= (~SLOT_ENABLED);
+ pci_bus_unlock(bus);
err_exit:
return 0;