Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 316456
b: refs/heads/master
c: ce29ca3
h: refs/heads/master
v: v3
  • Loading branch information
Amos Kong authored and Bjorn Helgaas committed Jun 13, 2012
1 parent 88f1dd7 commit 3024f8c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 638f293307b5787b69bf0a0bc915aed491efbec9
refs/heads/master: ce29ca3ea40744f24c2b5d88431e8ac566d257cc
42 changes: 32 additions & 10 deletions trunk/drivers/pci/hotplug/acpiphp_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,24 @@ static void disable_bridges(struct pci_bus *bus)
}
}

/* return first device in slot, acquiring a reference on it */
static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
{
struct pci_bus *bus = slot->bridge->pci_bus;
struct pci_dev *dev;
struct pci_dev *ret = NULL;

down_read(&pci_bus_sem);
list_for_each_entry(dev, &bus->devices, bus_list)
if (PCI_SLOT(dev->devfn) == slot->device) {
ret = pci_dev_get(dev);
break;
}
up_read(&pci_bus_sem);

return ret;
}

/**
* disable_device - disable a slot
* @slot: ACPI PHP slot
Expand All @@ -902,18 +920,22 @@ static int disable_device(struct acpiphp_slot *slot)
(u32)1, NULL, NULL);
func->bridge = NULL;
}
}

pdev = pci_get_slot(slot->bridge->pci_bus,
PCI_DEVFN(slot->device, func->function));
if (pdev) {
pci_stop_bus_device(pdev);
if (pdev->subordinate) {
disable_bridges(pdev->subordinate);
pci_disable_device(pdev);
}
__pci_remove_bus_device(pdev);
pci_dev_put(pdev);
/*
* enable_device() enumerates all functions in this device via
* pci_scan_slot(), whether they have associated ACPI hotplug
* methods (_EJ0, etc.) or not. Therefore, we remove all functions
* here.
*/
while ((pdev = dev_in_slot(slot))) {
pci_stop_bus_device(pdev);
if (pdev->subordinate) {
disable_bridges(pdev->subordinate);
pci_disable_device(pdev);
}
__pci_remove_bus_device(pdev);
pci_dev_put(pdev);
}

list_for_each_entry(func, &slot->funcs, sibling) {
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/pci/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "pci.h"

DECLARE_RWSEM(pci_bus_sem);
EXPORT_SYMBOL_GPL(pci_bus_sem);

/*
* find the upstream PCIe-to-PCI bridge of a PCI device
* if the device is PCIE, return NULL
Expand Down

0 comments on commit 3024f8c

Please sign in to comment.