ia64/linux-2.6.18-xen.hg

view drivers/xen/core/pci.c @ 634:87413eba04ab

Don't WARN_ON -ENOSYS from PHYSDEVOP_manage_pci_remove

We let -ENOSYS slip through on the add side to support old
hypervisors, let's do the same on the remove end so we don't get stack
dumps during bootup.

Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Aug 08 10:54:59 2008 +0100 (2008-08-08)
parents 268d6984c8e2
children d31b6ccf10e4
line source
1 /*
2 * vim:shiftwidth=8:noexpandtab
3 */
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <linux/pci.h>
8 #include <xen/interface/physdev.h>
10 static int (*pci_bus_probe)(struct device *dev);
11 static int (*pci_bus_remove)(struct device *dev);
13 static int pci_bus_probe_wrapper(struct device *dev)
14 {
15 int r;
16 struct pci_dev *pci_dev = to_pci_dev(dev);
17 struct physdev_manage_pci manage_pci;
18 manage_pci.bus = pci_dev->bus->number;
19 manage_pci.devfn = pci_dev->devfn;
21 r = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add, &manage_pci);
22 if (r && r != -ENOSYS)
23 return r;
25 r = pci_bus_probe(dev);
26 if (r) {
27 int ret;
29 ret = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove,
30 &manage_pci);
31 WARN_ON(ret && ret != -ENOSYS);
32 }
34 return r;
35 }
37 static int pci_bus_remove_wrapper(struct device *dev)
38 {
39 int r;
40 struct pci_dev *pci_dev = to_pci_dev(dev);
41 struct physdev_manage_pci manage_pci;
42 manage_pci.bus = pci_dev->bus->number;
43 manage_pci.devfn = pci_dev->devfn;
45 r = pci_bus_remove(dev);
46 /* dev and pci_dev are no longer valid!! */
48 WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_remove,
49 &manage_pci));
50 return r;
51 }
53 static int __init hook_pci_bus(void)
54 {
55 if (!is_running_on_xen() || !is_initial_xendomain())
56 return 0;
58 pci_bus_probe = pci_bus_type.probe;
59 pci_bus_type.probe = pci_bus_probe_wrapper;
61 pci_bus_remove = pci_bus_type.remove;
62 pci_bus_type.remove = pci_bus_remove_wrapper;
64 return 0;
65 }
67 core_initcall(hook_pci_bus);