aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2012-08-23 20:36:10 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-08-23 20:36:10 -0400
commit7bf79d8a9904ee1ed354e7e655f8045afda67fd6 (patch)
treefde1ddd5e0743b9585bef508ff0baf7a8d90288f
parenta28afda8cc6a45b2c5a4f98cf8fcddd877597701 (diff)
parentc29aabe22eafb4914aecebab6e99623894d81564 (diff)
Merge branch 'pci/bjorn-cleanup-remove' into next
* pci/bjorn-cleanup-remove: PCI: Remove unused pci_dev_b() sgi-agp: Use list_for_each_entry() for bus->devices traversal parisc/PCI: Use list_for_each_entry() for bus->devices traversal parisc/PCI: Enable PERR/SERR on all devices frv/PCI: Use list_for_each_entry() for bus->devices traversal PCI: Leave normal LIST_POISON in deleted list entries PCI: Rename local variables to conventional names PCI: Remove unused, commented-out, code PCI: Stop and remove devices in one pass PCI: Fold stop and remove helpers into their callers PCI: Use list_for_each_entry() for bus->devices traversal PCI: Remove pci_stop_and_remove_behind_bridge() PCI: Don't export stop_bus_device and remove_bus_device interfaces pcmcia: Use common pci_stop_and_remove_bus_device() PCI: acpiphp: Use common pci_stop_and_remove_bus_device() PCI: acpiphp: Stop disabling bridges on remove
-rw-r--r--arch/frv/mb93090-mb00/pci-vdk.c4
-rw-r--r--drivers/char/agp/sgi-agp.c5
-rw-r--r--drivers/parisc/dino.c10
-rw-r--r--drivers/parisc/lba_pci.c7
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c46
-rw-r--r--drivers/pci/proc.c19
-rw-r--r--drivers/pci/remove.c131
-rw-r--r--drivers/pci/rom.c59
-rw-r--r--drivers/pci/search.c6
-rw-r--r--drivers/pcmcia/cardbus.c15
-rw-r--r--include/linux/pci.h4
11 files changed, 45 insertions, 261 deletions
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c
index d04ed14bbf0c..71e9bcf58105 100644
--- a/arch/frv/mb93090-mb00/pci-vdk.c
+++ b/arch/frv/mb93090-mb00/pci-vdk.c
@@ -330,10 +330,8 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
330 pci_read_bridge_bases(bus); 330 pci_read_bridge_bases(bus);
331 331
332 if (bus->number == 0) { 332 if (bus->number == 0) {
333 struct list_head *ln;
334 struct pci_dev *dev; 333 struct pci_dev *dev;
335 for (ln=bus->devices.next; ln != &bus->devices; ln=ln->next) { 334 list_for_each_entry(dev, &bus->devices, bus_list) {
336 dev = pci_dev_b(ln);
337 if (dev->devfn == 0) { 335 if (dev->devfn == 0) {
338 dev->resource[0].start = 0; 336 dev->resource[0].start = 0;
339 dev->resource[0].end = 0; 337 dev->resource[0].end = 0;
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 192000377737..3a5af2f9b015 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -289,12 +289,11 @@ static int __devinit agp_sgi_init(void)
289 289
290 j = 0; 290 j = 0;
291 list_for_each_entry(info, &tioca_list, ca_list) { 291 list_for_each_entry(info, &tioca_list, ca_list) {
292 struct list_head *tmp;
293 if (list_empty(info->ca_devices)) 292 if (list_empty(info->ca_devices))
294 continue; 293 continue;
295 list_for_each(tmp, info->ca_devices) { 294 list_for_each_entry(pdev, info->ca_devices, bus_list) {
296 u8 cap_ptr; 295 u8 cap_ptr;
297 pdev = pci_dev_b(tmp); 296
298 if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8)) 297 if (pdev->class != (PCI_CLASS_DISPLAY_VGA << 8))
299 continue; 298 continue;
300 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); 299 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index ffddc4f64268..fb6a1fe21b93 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -477,14 +477,12 @@ dino_card_setup(struct pci_bus *bus, void __iomem *base_addr)
477 if (ccio_allocate_resource(dino_dev->hba.dev, res, _8MB, 477 if (ccio_allocate_resource(dino_dev->hba.dev, res, _8MB,
478 F_EXTEND(0xf0000000UL) | _8MB, 478 F_EXTEND(0xf0000000UL) | _8MB,
479 F_EXTEND(0xffffffffUL) &~ _8MB, _8MB) < 0) { 479 F_EXTEND(0xffffffffUL) &~ _8MB, _8MB) < 0) {
480 struct list_head *ln, *tmp_ln; 480 struct pci_dev *dev, *tmp;
481 481
482 printk(KERN_ERR "Dino: cannot attach bus %s\n", 482 printk(KERN_ERR "Dino: cannot attach bus %s\n",
483 dev_name(bus->bridge)); 483 dev_name(bus->bridge));
484 /* kill the bus, we can't do anything with it */ 484 /* kill the bus, we can't do anything with it */
485 list_for_each_safe(ln, tmp_ln, &bus->devices) { 485 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
486 struct pci_dev *dev = pci_dev_b(ln);
487
488 list_del(&dev->bus_list); 486 list_del(&dev->bus_list);
489 } 487 }
490 488
@@ -549,7 +547,6 @@ dino_card_fixup(struct pci_dev *dev)
549static void __init 547static void __init
550dino_fixup_bus(struct pci_bus *bus) 548dino_fixup_bus(struct pci_bus *bus)
551{ 549{
552 struct list_head *ln;
553 struct pci_dev *dev; 550 struct pci_dev *dev;
554 struct dino_device *dino_dev = DINO_DEV(parisc_walk_tree(bus->bridge)); 551 struct dino_device *dino_dev = DINO_DEV(parisc_walk_tree(bus->bridge));
555 552
@@ -596,8 +593,7 @@ dino_fixup_bus(struct pci_bus *bus)
596 } 593 }
597 594
598 595
599 list_for_each(ln, &bus->devices) { 596 list_for_each_entry(dev, &bus->devices, bus_list) {
600 dev = pci_dev_b(ln);
601 if (is_card_dino(&dino_dev->hba.dev->id)) 597 if (is_card_dino(&dino_dev->hba.dev->id))
602 dino_card_fixup(dev); 598 dino_card_fixup(dev);
603 599
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index 4f9cf2456f4e..fdd63a6a62d6 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -629,7 +629,7 @@ truncate_pat_collision(struct resource *root, struct resource *new)
629static void 629static void
630lba_fixup_bus(struct pci_bus *bus) 630lba_fixup_bus(struct pci_bus *bus)
631{ 631{
632 struct list_head *ln; 632 struct pci_dev *dev;
633#ifdef FBB_SUPPORT 633#ifdef FBB_SUPPORT
634 u16 status; 634 u16 status;
635#endif 635#endif
@@ -710,9 +710,8 @@ lba_fixup_bus(struct pci_bus *bus)
710 710
711 } 711 }
712 712
713 list_for_each(ln, &bus->devices) { 713 list_for_each_entry(dev, &bus->devices, bus_list) {
714 int i; 714 int i;
715 struct pci_dev *dev = pci_dev_b(ln);
716 715
717 DBG("lba_fixup_bus() %s\n", pci_name(dev)); 716 DBG("lba_fixup_bus() %s\n", pci_name(dev));
718 717
@@ -770,7 +769,7 @@ lba_fixup_bus(struct pci_bus *bus)
770 } 769 }
771 770
772 /* Lastly enable FBB/PERR/SERR on all devices too */ 771 /* Lastly enable FBB/PERR/SERR on all devices too */
773 list_for_each(ln, &bus->devices) { 772 list_for_each_entry(dev, &bus->devices, bus_list) {
774 (void) pci_read_config_word(dev, PCI_COMMAND, &status); 773 (void) pci_read_config_word(dev, PCI_COMMAND, &status);
775 status |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR | fbb_enable; 774 status |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR | fbb_enable;
776 (void) pci_write_config_word(dev, PCI_COMMAND, status); 775 (void) pci_write_config_word(dev, PCI_COMMAND, status);
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index ad6fd6695495..7be4ca5e1f4c 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -869,17 +869,6 @@ static int __ref enable_device(struct acpiphp_slot *slot)
869 return retval; 869 return retval;
870} 870}
871 871
872static void disable_bridges(struct pci_bus *bus)
873{
874 struct pci_dev *dev;
875 list_for_each_entry(dev, &bus->devices, bus_list) {
876 if (dev->subordinate) {
877 disable_bridges(dev->subordinate);
878 pci_disable_device(dev);
879 }
880 }
881}
882
883/* return first device in slot, acquiring a reference on it */ 872/* return first device in slot, acquiring a reference on it */
884static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot) 873static struct pci_dev *dev_in_slot(struct acpiphp_slot *slot)
885{ 874{
@@ -931,12 +920,7 @@ static int disable_device(struct acpiphp_slot *slot)
931 * here. 920 * here.
932 */ 921 */
933 while ((pdev = dev_in_slot(slot))) { 922 while ((pdev = dev_in_slot(slot))) {
934 pci_stop_bus_device(pdev); 923 pci_stop_and_remove_bus_device(pdev);
935 if (pdev->subordinate) {
936 disable_bridges(pdev->subordinate);
937 pci_disable_device(pdev);
938 }
939 __pci_remove_bus_device(pdev);
940 pci_dev_put(pdev); 924 pci_dev_put(pdev);
941 } 925 }
942 926
@@ -1477,34 +1461,6 @@ int __init acpiphp_get_num_slots(void)
1477} 1461}
1478 1462
1479 1463
1480#if 0
1481/**
1482 * acpiphp_for_each_slot - call function for each slot
1483 * @fn: callback function
1484 * @data: context to be passed to callback function
1485 */
1486static int acpiphp_for_each_slot(acpiphp_callback fn, void *data)
1487{
1488 struct list_head *node;
1489 struct acpiphp_bridge *bridge;
1490 struct acpiphp_slot *slot;
1491 int retval = 0;
1492
1493 list_for_each (node, &bridge_list) {
1494 bridge = (struct acpiphp_bridge *)node;
1495 for (slot = bridge->slots; slot; slot = slot->next) {
1496 retval = fn(slot, data);
1497 if (!retval)
1498 goto err_exit;
1499 }
1500 }
1501
1502 err_exit:
1503 return retval;
1504}
1505#endif
1506
1507
1508/** 1464/**
1509 * acpiphp_enable_slot - power on slot 1465 * acpiphp_enable_slot - power on slot
1510 * @slot: ACPI PHP slot 1466 * @slot: ACPI PHP slot
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 27911b55c2a5..eb907a8faf2a 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -434,25 +434,6 @@ int pci_proc_detach_device(struct pci_dev *dev)
434 return 0; 434 return 0;
435} 435}
436 436
437#if 0
438int pci_proc_attach_bus(struct pci_bus* bus)
439{
440 struct proc_dir_entry *de = bus->procdir;
441
442 if (!proc_initialized)
443 return -EACCES;
444
445 if (!de) {
446 char name[16];
447 sprintf(name, "%02x", bus->number);
448 de = bus->procdir = proc_mkdir(name, proc_bus_pci_dir);
449 if (!de)
450 return -ENOMEM;
451 }
452 return 0;
453}
454#endif /* 0 */
455
456int pci_proc_detach_bus(struct pci_bus* bus) 437int pci_proc_detach_bus(struct pci_bus* bus)
457{ 438{
458 struct proc_dir_entry *de = bus->procdir; 439 struct proc_dir_entry *de = bus->procdir;
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 04a4861b4749..4f9ca9162895 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -32,53 +32,30 @@ static void pci_stop_dev(struct pci_dev *dev)
32 32
33static void pci_destroy_dev(struct pci_dev *dev) 33static void pci_destroy_dev(struct pci_dev *dev)
34{ 34{
35 /* Remove the device from the device lists, and prevent any further
36 * list accesses from this device */
37 down_write(&pci_bus_sem); 35 down_write(&pci_bus_sem);
38 list_del(&dev->bus_list); 36 list_del(&dev->bus_list);
39 dev->bus_list.next = dev->bus_list.prev = NULL;
40 up_write(&pci_bus_sem); 37 up_write(&pci_bus_sem);
41 38
42 pci_free_resources(dev); 39 pci_free_resources(dev);
43 pci_dev_put(dev); 40 pci_dev_put(dev);
44} 41}
45 42
46/** 43void pci_remove_bus(struct pci_bus *bus)
47 * pci_remove_device_safe - remove an unused hotplug device
48 * @dev: the device to remove
49 *
50 * Delete the device structure from the device lists and
51 * notify userspace (/sbin/hotplug), but only if the device
52 * in question is not being used by a driver.
53 * Returns 0 on success.
54 */
55#if 0
56int pci_remove_device_safe(struct pci_dev *dev)
57{ 44{
58 if (pci_dev_driver(dev)) 45 pci_proc_detach_bus(bus);
59 return -EBUSY;
60 pci_destroy_dev(dev);
61 return 0;
62}
63#endif /* 0 */
64
65void pci_remove_bus(struct pci_bus *pci_bus)
66{
67 pci_proc_detach_bus(pci_bus);
68 46
69 down_write(&pci_bus_sem); 47 down_write(&pci_bus_sem);
70 list_del(&pci_bus->node); 48 list_del(&bus->node);
71 pci_bus_release_busn_res(pci_bus); 49 pci_bus_release_busn_res(bus);
72 up_write(&pci_bus_sem); 50 up_write(&pci_bus_sem);
73 if (!pci_bus->is_added) 51 if (!bus->is_added)
74 return; 52 return;
75 53
76 pci_remove_legacy_files(pci_bus); 54 pci_remove_legacy_files(bus);
77 device_unregister(&pci_bus->dev); 55 device_unregister(&bus->dev);
78} 56}
79EXPORT_SYMBOL(pci_remove_bus); 57EXPORT_SYMBOL(pci_remove_bus);
80 58
81static void __pci_remove_behind_bridge(struct pci_dev *dev);
82/** 59/**
83 * pci_stop_and_remove_bus_device - remove a PCI device and any children 60 * pci_stop_and_remove_bus_device - remove a PCI device and any children
84 * @dev: the device to remove 61 * @dev: the device to remove
@@ -91,93 +68,27 @@ static void __pci_remove_behind_bridge(struct pci_dev *dev);
91 * device lists, remove the /proc entry, and notify userspace 68 * device lists, remove the /proc entry, and notify userspace
92 * (/sbin/hotplug). 69 * (/sbin/hotplug).
93 */ 70 */
94void __pci_remove_bus_device(struct pci_dev *dev)
95{
96 if (dev->subordinate) {
97 struct pci_bus *b = dev->subordinate;
98
99 __pci_remove_behind_bridge(dev);
100 pci_remove_bus(b);
101 dev->subordinate = NULL;
102 }
103
104 pci_destroy_dev(dev);
105}
106EXPORT_SYMBOL(__pci_remove_bus_device);
107
108void pci_stop_and_remove_bus_device(struct pci_dev *dev) 71void pci_stop_and_remove_bus_device(struct pci_dev *dev)
109{ 72{
110 pci_stop_bus_device(dev); 73 struct pci_bus *bus = dev->subordinate;
111 __pci_remove_bus_device(dev); 74 struct pci_dev *child, *tmp;
112}
113
114static void __pci_remove_behind_bridge(struct pci_dev *dev)
115{
116 struct list_head *l, *n;
117
118 if (dev->subordinate)
119 list_for_each_safe(l, n, &dev->subordinate->devices)
120 __pci_remove_bus_device(pci_dev_b(l));
121}
122
123static void pci_stop_behind_bridge(struct pci_dev *dev)
124{
125 struct list_head *l, *n;
126
127 if (dev->subordinate)
128 list_for_each_safe(l, n, &dev->subordinate->devices)
129 pci_stop_bus_device(pci_dev_b(l));
130}
131
132/**
133 * pci_stop_and_remove_behind_bridge - stop and remove all devices behind
134 * a PCI bridge
135 * @dev: PCI bridge device
136 *
137 * Remove all devices on the bus, except for the parent bridge.
138 * This also removes any child buses, and any devices they may
139 * contain in a depth-first manner.
140 */
141void pci_stop_and_remove_behind_bridge(struct pci_dev *dev)
142{
143 pci_stop_behind_bridge(dev);
144 __pci_remove_behind_bridge(dev);
145}
146
147static void pci_stop_bus_devices(struct pci_bus *bus)
148{
149 struct list_head *l, *n;
150 75
151 /* 76 /*
152 * VFs could be removed by pci_stop_and_remove_bus_device() in the 77 * Removing an SR-IOV PF device removes all the associated VFs,
153 * pci_stop_bus_devices() code path for PF. 78 * which will update the bus->devices list and confuse the
154 * aka, bus->devices get updated in the process. 79 * iterator. Therefore, iterate in reverse so we remove the VFs
155 * but VFs are inserted after PFs when SRIOV is enabled for PF, 80 * first, then the PF.
156 * We can iterate the list backwards to get prev valid PF instead
157 * of removed VF.
158 */ 81 */
159 list_for_each_prev_safe(l, n, &bus->devices) { 82 if (bus) {
160 struct pci_dev *dev = pci_dev_b(l); 83 list_for_each_entry_safe_reverse(child, tmp,
161 pci_stop_bus_device(dev); 84 &bus->devices, bus_list)
162 } 85 pci_stop_and_remove_bus_device(child);
163}
164 86
165/** 87 pci_remove_bus(bus);
166 * pci_stop_bus_device - stop a PCI device and any children 88 dev->subordinate = NULL;
167 * @dev: the device to stop 89 }
168 *
169 * Stop a PCI device (detach the driver, remove from the global list
170 * and so on). This also stop any subordinate buses and children in a
171 * depth-first manner.
172 */
173void pci_stop_bus_device(struct pci_dev *dev)
174{
175 if (dev->subordinate)
176 pci_stop_bus_devices(dev->subordinate);
177 90
178 pci_stop_dev(dev); 91 pci_stop_dev(dev);
92 pci_destroy_dev(dev);
179} 93}
180
181EXPORT_SYMBOL(pci_stop_and_remove_bus_device); 94EXPORT_SYMBOL(pci_stop_and_remove_bus_device);
182EXPORT_SYMBOL(pci_stop_and_remove_behind_bridge);
183EXPORT_SYMBOL_GPL(pci_stop_bus_device);
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 48ebdb237f3f..0b3037ab8b93 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -167,44 +167,6 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
167 return rom; 167 return rom;
168} 168}
169 169
170#if 0
171/**
172 * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy
173 * @pdev: pointer to pci device struct
174 * @size: pointer to receive size of pci window over ROM
175 *
176 * Return: kernel virtual pointer to image of ROM
177 *
178 * Map a PCI ROM into kernel space. If ROM is boot video ROM,
179 * the shadow BIOS copy will be returned instead of the
180 * actual ROM.
181 */
182void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size)
183{
184 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
185 void __iomem *rom;
186
187 rom = pci_map_rom(pdev, size);
188 if (!rom)
189 return NULL;
190
191 if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_SHADOW |
192 IORESOURCE_ROM_BIOS_COPY))
193 return rom;
194
195 res->start = (unsigned long)kmalloc(*size, GFP_KERNEL);
196 if (!res->start)
197 return rom;
198
199 res->end = res->start + *size;
200 memcpy_fromio((void*)(unsigned long)res->start, rom, *size);
201 pci_unmap_rom(pdev, rom);
202 res->flags |= IORESOURCE_ROM_COPY;
203
204 return (void __iomem *)(unsigned long)res->start;
205}
206#endif /* 0 */
207
208/** 170/**
209 * pci_unmap_rom - unmap the ROM from kernel space 171 * pci_unmap_rom - unmap the ROM from kernel space
210 * @pdev: pointer to pci device struct 172 * @pdev: pointer to pci device struct
@@ -226,27 +188,6 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
226 pci_disable_rom(pdev); 188 pci_disable_rom(pdev);
227} 189}
228 190
229#if 0
230/**
231 * pci_remove_rom - disable the ROM and remove its sysfs attribute
232 * @pdev: pointer to pci device struct
233 *
234 * Remove the rom file in sysfs and disable ROM decoding.
235 */
236void pci_remove_rom(struct pci_dev *pdev)
237{
238 struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
239
240 if (pci_resource_len(pdev, PCI_ROM_RESOURCE))
241 sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
242 if (!(res->flags & (IORESOURCE_ROM_ENABLE |
243 IORESOURCE_ROM_SHADOW |
244 IORESOURCE_ROM_BIOS_COPY |
245 IORESOURCE_ROM_COPY)))
246 pci_disable_rom(pdev);
247}
248#endif /* 0 */
249
250/** 191/**
251 * pci_cleanup_rom - free the ROM copy created by pci_map_rom_copy 192 * pci_cleanup_rom - free the ROM copy created by pci_map_rom_copy
252 * @pdev: pointer to pci device struct 193 * @pdev: pointer to pci device struct
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 621b162ceb69..d84cdcfaacf3 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -130,16 +130,14 @@ pci_find_next_bus(const struct pci_bus *from)
130 * decrement the reference count by calling pci_dev_put(). 130 * decrement the reference count by calling pci_dev_put().
131 * If no device is found, %NULL is returned. 131 * If no device is found, %NULL is returned.
132 */ 132 */
133struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) 133struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn)
134{ 134{
135 struct list_head *tmp;
136 struct pci_dev *dev; 135 struct pci_dev *dev;
137 136
138 WARN_ON(in_interrupt()); 137 WARN_ON(in_interrupt());
139 down_read(&pci_bus_sem); 138 down_read(&pci_bus_sem);
140 139
141 list_for_each(tmp, &bus->devices) { 140 list_for_each_entry(dev, &bus->devices, bus_list) {
142 dev = pci_dev_b(tmp);
143 if (dev->devfn == devfn) 141 if (dev->devfn == devfn)
144 goto out; 142 goto out;
145 } 143 }
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 24caeaf50529..9d3ac998fc1f 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -105,8 +105,17 @@ int __ref cb_alloc(struct pcmcia_socket *s)
105 */ 105 */
106void cb_free(struct pcmcia_socket *s) 106void cb_free(struct pcmcia_socket *s)
107{ 107{
108 struct pci_dev *bridge = s->cb_dev; 108 struct pci_dev *bridge, *dev, *tmp;
109 struct pci_bus *bus;
109 110
110 if (bridge) 111 bridge = s->cb_dev;
111 pci_stop_and_remove_behind_bridge(bridge); 112 if (!bridge)
113 return;
114
115 bus = bridge->subordinate;
116 if (!bus)
117 return;
118
119 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list)
120 pci_stop_and_remove_bus_device(dev);
112} 121}
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 57a08da824e0..0d8718904e88 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -369,7 +369,6 @@ static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
369 369
370extern struct pci_dev *alloc_pci_dev(void); 370extern struct pci_dev *alloc_pci_dev(void);
371 371
372#define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
373#define to_pci_dev(n) container_of(n, struct pci_dev, dev) 372#define to_pci_dev(n) container_of(n, struct pci_dev, dev)
374#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL) 373#define for_each_pci_dev(d) while ((d = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, d)) != NULL)
375 374
@@ -734,9 +733,7 @@ u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp);
734extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 733extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
735extern void pci_dev_put(struct pci_dev *dev); 734extern void pci_dev_put(struct pci_dev *dev);
736extern void pci_remove_bus(struct pci_bus *b); 735extern void pci_remove_bus(struct pci_bus *b);
737extern void __pci_remove_bus_device(struct pci_dev *dev);
738extern void pci_stop_and_remove_bus_device(struct pci_dev *dev); 736extern void pci_stop_and_remove_bus_device(struct pci_dev *dev);
739extern void pci_stop_bus_device(struct pci_dev *dev);
740void pci_setup_cardbus(struct pci_bus *bus); 737void pci_setup_cardbus(struct pci_bus *bus);
741extern void pci_sort_breadthfirst(void); 738extern void pci_sort_breadthfirst(void);
742#define dev_is_pci(d) ((d)->bus == &pci_bus_type) 739#define dev_is_pci(d) ((d)->bus == &pci_bus_type)
@@ -1047,7 +1044,6 @@ void pci_unregister_driver(struct pci_driver *dev);
1047 module_driver(__pci_driver, pci_register_driver, \ 1044 module_driver(__pci_driver, pci_register_driver, \
1048 pci_unregister_driver) 1045 pci_unregister_driver)
1049 1046
1050void pci_stop_and_remove_behind_bridge(struct pci_dev *dev);
1051struct pci_driver *pci_dev_driver(const struct pci_dev *dev); 1047struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
1052int pci_add_dynid(struct pci_driver *drv, 1048int pci_add_dynid(struct pci_driver *drv,
1053 unsigned int vendor, unsigned int device, 1049 unsigned int vendor, unsigned int device,