aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c7
-rw-r--r--drivers/pci/bus.c11
-rw-r--r--drivers/pci/probe.c2
-rw-r--r--drivers/pci/remove.c6
-rw-r--r--include/linux/pci.h1
5 files changed, 10 insertions, 17 deletions
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index 5a5a19e40bb4..d26a7bcad6b6 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -88,11 +88,8 @@ pcibios_fixup_new_pci_devices(struct pci_bus *bus)
88 struct pci_dev *dev; 88 struct pci_dev *dev;
89 89
90 list_for_each_entry(dev, &bus->devices, bus_list) { 90 list_for_each_entry(dev, &bus->devices, bus_list) {
91 /* 91 /* Skip already-added devices */
92 * Skip already-present devices (which are on the 92 if (!dev->is_added) {
93 * global device list.)
94 */
95 if (list_empty(&dev->global_list)) {
96 int i; 93 int i;
97 94
98 /* Fill device archdata and setup iommu table */ 95 /* Fill device archdata and setup iommu table */
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index d708358326e5..e1c079aa0e82 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -84,6 +84,7 @@ int pci_bus_add_device(struct pci_dev *dev)
84 if (retval) 84 if (retval)
85 return retval; 85 return retval;
86 86
87 dev->is_added = 1;
87 down_write(&pci_bus_sem); 88 down_write(&pci_bus_sem);
88 list_add_tail(&dev->global_list, &pci_devices); 89 list_add_tail(&dev->global_list, &pci_devices);
89 up_write(&pci_bus_sem); 90 up_write(&pci_bus_sem);
@@ -112,11 +113,8 @@ void pci_bus_add_devices(struct pci_bus *bus)
112 int retval; 113 int retval;
113 114
114 list_for_each_entry(dev, &bus->devices, bus_list) { 115 list_for_each_entry(dev, &bus->devices, bus_list) {
115 /* 116 /* Skip already-added devices */
116 * Skip already-present devices (which are on the 117 if (dev->is_added)
117 * global device list.)
118 */
119 if (!list_empty(&dev->global_list))
120 continue; 118 continue;
121 retval = pci_bus_add_device(dev); 119 retval = pci_bus_add_device(dev);
122 if (retval) 120 if (retval)
@@ -124,8 +122,7 @@ void pci_bus_add_devices(struct pci_bus *bus)
124 } 122 }
125 123
126 list_for_each_entry(dev, &bus->devices, bus_list) { 124 list_for_each_entry(dev, &bus->devices, bus_list) {
127 125 BUG_ON(!dev->is_added);
128 BUG_ON(list_empty(&dev->global_list));
129 126
130 /* 127 /*
131 * If there is an unattached subordinate bus, attach 128 * If there is an unattached subordinate bus, attach
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 387fbbb97431..7217f4283ce8 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -984,7 +984,7 @@ EXPORT_SYMBOL(pci_scan_single_device);
984 * 984 *
985 * Scan a PCI slot on the specified PCI bus for devices, adding 985 * Scan a PCI slot on the specified PCI bus for devices, adding
986 * discovered devices to the @bus->devices list. New devices 986 * discovered devices to the @bus->devices list. New devices
987 * will have an empty dev->global_list head. 987 * will not have is_added set.
988 */ 988 */
989int pci_scan_slot(struct pci_bus *bus, int devfn) 989int pci_scan_slot(struct pci_bus *bus, int devfn)
990{ 990{
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 9684e1bde277..d3c77cbe3279 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -18,13 +18,11 @@ static void pci_free_resources(struct pci_dev *dev)
18 18
19static void pci_stop_dev(struct pci_dev *dev) 19static void pci_stop_dev(struct pci_dev *dev)
20{ 20{
21 if (!dev->global_list.next) 21 if (dev->is_added) {
22 return;
23
24 if (!list_empty(&dev->global_list)) {
25 pci_proc_detach_device(dev); 22 pci_proc_detach_device(dev);
26 pci_remove_sysfs_dev_files(dev); 23 pci_remove_sysfs_dev_files(dev);
27 device_unregister(&dev->dev); 24 device_unregister(&dev->dev);
25 dev->is_added = 0;
28 down_write(&pci_bus_sem); 26 down_write(&pci_bus_sem);
29 list_del(&dev->global_list); 27 list_del(&dev->global_list);
30 dev->global_list.next = dev->global_list.prev = NULL; 28 dev->global_list.next = dev->global_list.prev = NULL;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5f79c72bae63..5e6d0f413fb9 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -181,6 +181,7 @@ struct pci_dev {
181 unsigned int transparent:1; /* Transparent PCI bridge */ 181 unsigned int transparent:1; /* Transparent PCI bridge */
182 unsigned int multifunction:1;/* Part of multi-function device */ 182 unsigned int multifunction:1;/* Part of multi-function device */
183 /* keep track of device state */ 183 /* keep track of device state */
184 unsigned int is_added:1;
184 unsigned int is_busmaster:1; /* device is busmaster */ 185 unsigned int is_busmaster:1; /* device is busmaster */
185 unsigned int no_msi:1; /* device may not use msi */ 186 unsigned int no_msi:1; /* device may not use msi */
186 unsigned int no_d1d2:1; /* only allow d0 or d3 */ 187 unsigned int no_d1d2:1; /* only allow d0 or d3 */