From 8a1bc9013a03d41a0e36ee413bb6f97281b30bd1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 14 Feb 2008 14:56:56 -0800 Subject: PCI: add is_added flag to struct pci_dev This lets us check if the device is really added to the driver core or not, which is what we need when walking some of the bus lists. The flag is there in anticipation of getting rid of the other PCI device list, which is what we used to check in this situation. Signed-off-by: Greg Kroah-Hartman --- drivers/pci/bus.c | 11 ++++------- drivers/pci/probe.c | 2 +- drivers/pci/remove.c | 6 ++---- 3 files changed, 7 insertions(+), 12 deletions(-) (limited to 'drivers/pci') diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index d708358326e..e1c079aa0e8 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -84,6 +84,7 @@ int pci_bus_add_device(struct pci_dev *dev) if (retval) return retval; + dev->is_added = 1; down_write(&pci_bus_sem); list_add_tail(&dev->global_list, &pci_devices); up_write(&pci_bus_sem); @@ -112,11 +113,8 @@ void pci_bus_add_devices(struct pci_bus *bus) int retval; list_for_each_entry(dev, &bus->devices, bus_list) { - /* - * Skip already-present devices (which are on the - * global device list.) - */ - if (!list_empty(&dev->global_list)) + /* Skip already-added devices */ + if (dev->is_added) continue; retval = pci_bus_add_device(dev); if (retval) @@ -124,8 +122,7 @@ void pci_bus_add_devices(struct pci_bus *bus) } list_for_each_entry(dev, &bus->devices, bus_list) { - - BUG_ON(list_empty(&dev->global_list)); + BUG_ON(!dev->is_added); /* * If there is an unattached subordinate bus, attach diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 387fbbb9743..7217f4283ce 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -984,7 +984,7 @@ EXPORT_SYMBOL(pci_scan_single_device); * * Scan a PCI slot on the specified PCI bus for devices, adding * discovered devices to the @bus->devices list. New devices - * will have an empty dev->global_list head. + * will not have is_added set. */ int pci_scan_slot(struct pci_bus *bus, int devfn) { diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 9684e1bde27..d3c77cbe327 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -18,13 +18,11 @@ static void pci_free_resources(struct pci_dev *dev) static void pci_stop_dev(struct pci_dev *dev) { - if (!dev->global_list.next) - return; - - if (!list_empty(&dev->global_list)) { + if (dev->is_added) { pci_proc_detach_device(dev); pci_remove_sysfs_dev_files(dev); device_unregister(&dev->dev); + dev->is_added = 0; down_write(&pci_bus_sem); list_del(&dev->global_list); dev->global_list.next = dev->global_list.prev = NULL; -- cgit v1.2.3