Commit 330ebfe3 authored by Bjorn Helgaas's avatar Bjorn Helgaas

Merge branch 'pci/deletion' into next

* pci/deletion:
  PCI: Remove from bus_list and release resources in pci_release_dev()
  PCI: Move pci_proc_attach_device() to pci_bus_add_device()
  PCI: Use device_release_driver() in pci_stop_root_bus()
  PCI: Move device_del() from pci_stop_dev() to pci_destroy_dev()

Conflicts:
	drivers/pci/remove.c
parents d9cdfb87 ef83b078
......@@ -176,6 +176,7 @@ int pci_bus_add_device(struct pci_dev *dev)
*/
pci_fixup_device(pci_fixup_final, dev);
pci_create_sysfs_dev_files(dev);
pci_proc_attach_device(dev);
dev->match_driver = true;
retval = device_attach(&dev->dev);
......
......@@ -1154,6 +1154,18 @@ static void pci_release_capabilities(struct pci_dev *dev)
pci_free_cap_save_buffers(dev);
}
static void pci_free_resources(struct pci_dev *dev)
{
int i;
pci_cleanup_rom(dev);
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *res = dev->resource + i;
if (res->parent)
release_resource(res);
}
}
/**
* pci_release_dev - free a pci device structure when all users of it are finished.
* @dev: device that's been disconnected
......@@ -1163,9 +1175,14 @@ static void pci_release_capabilities(struct pci_dev *dev)
*/
static void pci_release_dev(struct device *dev)
{
struct pci_dev *pci_dev;
struct pci_dev *pci_dev = to_pci_dev(dev);
down_write(&pci_bus_sem);
list_del(&pci_dev->bus_list);
up_write(&pci_bus_sem);
pci_free_resources(pci_dev);
pci_dev = to_pci_dev(dev);
pci_release_capabilities(pci_dev);
pci_release_of_node(pci_dev);
pcibios_release_device(pci_dev);
......@@ -1381,8 +1398,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
dev->match_driver = false;
ret = device_add(&dev->dev);
WARN_ON(ret < 0);
pci_proc_attach_device(dev);
}
struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn)
......
......@@ -3,20 +3,6 @@
#include <linux/pci-aspm.h>
#include "pci.h"
static void pci_free_resources(struct pci_dev *dev)
{
int i;
msi_remove_pci_irq_vectors(dev);
pci_cleanup_rom(dev);
for (i = 0; i < PCI_NUM_RESOURCES; i++) {
struct resource *res = dev->resource + i;
if (res->parent)
release_resource(res);
}
}
static void pci_stop_dev(struct pci_dev *dev)
{
pci_pme_active(dev, false);
......@@ -36,11 +22,6 @@ static void pci_destroy_dev(struct pci_dev *dev)
{
device_del(&dev->dev);
down_write(&pci_bus_sem);
list_del(&dev->bus_list);
up_write(&pci_bus_sem);
pci_free_resources(dev);
put_device(&dev->dev);
}
......@@ -128,7 +109,7 @@ void pci_stop_root_bus(struct pci_bus *bus)
pci_stop_bus_device(child);
/* stop the host bridge */
device_del(&host_bridge->dev);
device_release_driver(&host_bridge->dev);
}
void pci_remove_root_bus(struct pci_bus *bus)
......@@ -147,5 +128,5 @@ void pci_remove_root_bus(struct pci_bus *bus)
host_bridge->bus = NULL;
/* remove the host bridge */
put_device(&host_bridge->dev);
device_unregister(&host_bridge->dev);
}
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