]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
PCI: add is_added flag to struct pci_dev
authorGreg Kroah-Hartman <gregkh@suse.de>
Thu, 14 Feb 2008 22:56:56 +0000 (14:56 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 21 Apr 2008 04:47:00 +0000 (21:47 -0700)
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 <gregkh@suse.de>
arch/powerpc/platforms/pseries/pci_dlpar.c
drivers/pci/bus.c
drivers/pci/probe.c
drivers/pci/remove.c
include/linux/pci.h

index 5a5a19e40bb4587e80943991e8ebfc9621bbfd7b..d26a7bcad6b6ffd0a5fd902dace698eaa1ff0a6a 100644 (file)
@@ -88,11 +88,8 @@ pcibios_fixup_new_pci_devices(struct pci_bus *bus)
        struct pci_dev *dev;
 
        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) {
                        int i;
 
                        /* Fill device archdata and setup iommu table */
index d708358326e556ae03e00b213e89dd1baf0dceff..e1c079aa0e8211f152c001d05c73ffbecef14c59 100644 (file)
@@ -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
index 387fbbb97431eef05d3920db995690ce2f201240..7217f4283ce8af356b0a375abca3fd2eba4eed08 100644 (file)
@@ -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)
 {
index 9684e1bde277a1e012fae641363178f394071323..d3c77cbe327958f182b89b2b69e677df7d43cf45 100644 (file)
@@ -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;
index 5f79c72bae6360bd40b3fc62e7985cbeddb47510..5e6d0f413fb97796e203f22008c7b2b84b1d5af8 100644 (file)
@@ -181,6 +181,7 @@ struct pci_dev {
        unsigned int    transparent:1;  /* Transparent PCI bridge */
        unsigned int    multifunction:1;/* Part of multi-function device */
        /* keep track of device state */
+       unsigned int    is_added:1;
        unsigned int    is_busmaster:1; /* device is busmaster */
        unsigned int    no_msi:1;       /* device may not use msi */
        unsigned int    no_d1d2:1;   /* only allow d0 or d3 */