diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-08-24 16:32:07 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-08-24 16:32:07 -0400 |
commit | c2b5acc3a3ba80bef61b9df712004e83cbab4a11 (patch) | |
tree | 536076cd98c31e95af3e05b9b9f6de9c51f8d927 /drivers/pci/hotplug | |
parent | 0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (diff) |
PCI: Remove the fakephp driver
The fakephp driver was scheduled for removal in 2011.
Fakephp presented /sys/bus/pci/slots/.../power files for every PCI
function. Writing "0" to one of these files logically removed the device
from the system. The PCI core now provides the same functionality with
/sys/bus/pci/devices/.../remove.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r-- | drivers/pci/hotplug/Kconfig | 24 | ||||
-rw-r--r-- | drivers/pci/hotplug/Makefile | 3 | ||||
-rw-r--r-- | drivers/pci/hotplug/fakephp.c | 164 |
3 files changed, 1 insertions, 190 deletions
diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig index 66f29bc00be4..b0e46dede1a9 100644 --- a/drivers/pci/hotplug/Kconfig +++ b/drivers/pci/hotplug/Kconfig | |||
@@ -17,28 +17,6 @@ menuconfig HOTPLUG_PCI | |||
17 | 17 | ||
18 | if HOTPLUG_PCI | 18 | if HOTPLUG_PCI |
19 | 19 | ||
20 | config HOTPLUG_PCI_FAKE | ||
21 | tristate "Fake PCI Hotplug driver" | ||
22 | help | ||
23 | Say Y here if you want to use the fake PCI hotplug driver. It can | ||
24 | be used to simulate PCI hotplug events if even if your system is | ||
25 | not PCI hotplug capable. | ||
26 | |||
27 | This driver will "emulate" removing PCI devices from the system. | ||
28 | If the "power" file is written to with "0" then the specified PCI | ||
29 | device will be completely removed from the kernel. | ||
30 | |||
31 | WARNING, this does NOT turn off the power to the PCI device. | ||
32 | This is a "logical" removal, not a physical or electrical | ||
33 | removal. | ||
34 | |||
35 | Use this module at your own risk. You have been warned! | ||
36 | |||
37 | To compile this driver as a module, choose M here: the | ||
38 | module will be called fakephp. | ||
39 | |||
40 | When in doubt, say N. | ||
41 | |||
42 | config HOTPLUG_PCI_COMPAQ | 20 | config HOTPLUG_PCI_COMPAQ |
43 | tristate "Compaq PCI Hotplug driver" | 21 | tristate "Compaq PCI Hotplug driver" |
44 | depends on X86 && PCI_BIOS | 22 | depends on X86 && PCI_BIOS |
@@ -143,7 +121,7 @@ config HOTPLUG_PCI_SHPC | |||
143 | 121 | ||
144 | config HOTPLUG_PCI_RPA | 122 | config HOTPLUG_PCI_RPA |
145 | tristate "RPA PCI Hotplug driver" | 123 | tristate "RPA PCI Hotplug driver" |
146 | depends on PPC_PSERIES && EEH && !HOTPLUG_PCI_FAKE | 124 | depends on PPC_PSERIES && EEH |
147 | help | 125 | help |
148 | Say Y here if you have a RPA system that supports PCI Hotplug. | 126 | Say Y here if you have a RPA system that supports PCI Hotplug. |
149 | 127 | ||
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 6cd9f3c9887d..c459cd4e39c2 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile | |||
@@ -23,9 +23,6 @@ obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o | |||
23 | 23 | ||
24 | obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o | 24 | obj-$(CONFIG_HOTPLUG_PCI_ACPI_IBM) += acpiphp_ibm.o |
25 | 25 | ||
26 | # Link this last so it doesn't claim devices that have a real hotplug driver | ||
27 | obj-$(CONFIG_HOTPLUG_PCI_FAKE) += fakephp.o | ||
28 | |||
29 | pci_hotplug-objs := pci_hotplug_core.o pcihp_slot.o | 26 | pci_hotplug-objs := pci_hotplug_core.o pcihp_slot.o |
30 | 27 | ||
31 | ifdef CONFIG_HOTPLUG_PCI_CPCI | 28 | ifdef CONFIG_HOTPLUG_PCI_CPCI |
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c deleted file mode 100644 index a019c9a712be..000000000000 --- a/drivers/pci/hotplug/fakephp.c +++ /dev/null | |||
@@ -1,164 +0,0 @@ | |||
1 | /* Works like the fakephp driver used to, except a little better. | ||
2 | * | ||
3 | * - It's possible to remove devices with subordinate busses. | ||
4 | * - New PCI devices that appear via any method, not just a fakephp triggered | ||
5 | * rescan, will be noticed. | ||
6 | * - Devices that are removed via any method, not just a fakephp triggered | ||
7 | * removal, will also be noticed. | ||
8 | * | ||
9 | * Uses nothing from the pci-hotplug subsystem. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/list.h> | ||
17 | #include <linux/kobject.h> | ||
18 | #include <linux/sysfs.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include "../pci.h" | ||
24 | |||
25 | struct legacy_slot { | ||
26 | struct kobject kobj; | ||
27 | struct pci_dev *dev; | ||
28 | struct list_head list; | ||
29 | }; | ||
30 | |||
31 | static LIST_HEAD(legacy_list); | ||
32 | |||
33 | static ssize_t legacy_show(struct kobject *kobj, struct attribute *attr, | ||
34 | char *buf) | ||
35 | { | ||
36 | struct legacy_slot *slot = container_of(kobj, typeof(*slot), kobj); | ||
37 | strcpy(buf, "1\n"); | ||
38 | return 2; | ||
39 | } | ||
40 | |||
41 | static void remove_callback(void *data) | ||
42 | { | ||
43 | pci_stop_and_remove_bus_device((struct pci_dev *)data); | ||
44 | } | ||
45 | |||
46 | static ssize_t legacy_store(struct kobject *kobj, struct attribute *attr, | ||
47 | const char *buf, size_t len) | ||
48 | { | ||
49 | struct legacy_slot *slot = container_of(kobj, typeof(*slot), kobj); | ||
50 | unsigned long val; | ||
51 | |||
52 | if (strict_strtoul(buf, 0, &val) < 0) | ||
53 | return -EINVAL; | ||
54 | |||
55 | if (val) | ||
56 | pci_rescan_bus(slot->dev->bus); | ||
57 | else | ||
58 | sysfs_schedule_callback(&slot->dev->dev.kobj, remove_callback, | ||
59 | slot->dev, THIS_MODULE); | ||
60 | return len; | ||
61 | } | ||
62 | |||
63 | static struct attribute *legacy_attrs[] = { | ||
64 | &(struct attribute){ .name = "power", .mode = 0644 }, | ||
65 | NULL, | ||
66 | }; | ||
67 | |||
68 | static void legacy_release(struct kobject *kobj) | ||
69 | { | ||
70 | struct legacy_slot *slot = container_of(kobj, typeof(*slot), kobj); | ||
71 | |||
72 | pci_dev_put(slot->dev); | ||
73 | kfree(slot); | ||
74 | } | ||
75 | |||
76 | static struct kobj_type legacy_ktype = { | ||
77 | .sysfs_ops = &(const struct sysfs_ops){ | ||
78 | .store = legacy_store, .show = legacy_show | ||
79 | }, | ||
80 | .release = &legacy_release, | ||
81 | .default_attrs = legacy_attrs, | ||
82 | }; | ||
83 | |||
84 | static int legacy_add_slot(struct pci_dev *pdev) | ||
85 | { | ||
86 | struct legacy_slot *slot = kzalloc(sizeof(*slot), GFP_KERNEL); | ||
87 | |||
88 | if (!slot) | ||
89 | return -ENOMEM; | ||
90 | |||
91 | if (kobject_init_and_add(&slot->kobj, &legacy_ktype, | ||
92 | &pci_slots_kset->kobj, "%s", | ||
93 | dev_name(&pdev->dev))) { | ||
94 | dev_warn(&pdev->dev, "Failed to created legacy fake slot\n"); | ||
95 | return -EINVAL; | ||
96 | } | ||
97 | slot->dev = pci_dev_get(pdev); | ||
98 | |||
99 | list_add(&slot->list, &legacy_list); | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static int legacy_notify(struct notifier_block *nb, | ||
105 | unsigned long action, void *data) | ||
106 | { | ||
107 | struct pci_dev *pdev = to_pci_dev(data); | ||
108 | |||
109 | if (action == BUS_NOTIFY_ADD_DEVICE) { | ||
110 | legacy_add_slot(pdev); | ||
111 | } else if (action == BUS_NOTIFY_DEL_DEVICE) { | ||
112 | struct legacy_slot *slot; | ||
113 | |||
114 | list_for_each_entry(slot, &legacy_list, list) | ||
115 | if (slot->dev == pdev) | ||
116 | goto found; | ||
117 | |||
118 | dev_warn(&pdev->dev, "Missing legacy fake slot?"); | ||
119 | return -ENODEV; | ||
120 | found: | ||
121 | kobject_del(&slot->kobj); | ||
122 | list_del(&slot->list); | ||
123 | kobject_put(&slot->kobj); | ||
124 | } | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static struct notifier_block legacy_notifier = { | ||
130 | .notifier_call = legacy_notify | ||
131 | }; | ||
132 | |||
133 | static int __init init_legacy(void) | ||
134 | { | ||
135 | struct pci_dev *pdev = NULL; | ||
136 | |||
137 | /* Add existing devices */ | ||
138 | for_each_pci_dev(pdev) | ||
139 | legacy_add_slot(pdev); | ||
140 | |||
141 | /* Be alerted of any new ones */ | ||
142 | bus_register_notifier(&pci_bus_type, &legacy_notifier); | ||
143 | return 0; | ||
144 | } | ||
145 | module_init(init_legacy); | ||
146 | |||
147 | static void __exit remove_legacy(void) | ||
148 | { | ||
149 | struct legacy_slot *slot, *tmp; | ||
150 | |||
151 | bus_unregister_notifier(&pci_bus_type, &legacy_notifier); | ||
152 | |||
153 | list_for_each_entry_safe(slot, tmp, &legacy_list, list) { | ||
154 | list_del(&slot->list); | ||
155 | kobject_del(&slot->kobj); | ||
156 | kobject_put(&slot->kobj); | ||
157 | } | ||
158 | } | ||
159 | module_exit(remove_legacy); | ||
160 | |||
161 | |||
162 | MODULE_AUTHOR("Trent Piepho <xyzzy@speakeasy.org>"); | ||
163 | MODULE_DESCRIPTION("Legacy version of the fakephp interface"); | ||
164 | MODULE_LICENSE("GPL"); | ||