aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/cpu.c')
-rw-r--r--drivers/base/cpu.c59
1 files changed, 39 insertions, 20 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 3d48fc887ef4..c377673320ed 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -85,18 +85,21 @@ static ssize_t __ref store_online(struct device *dev,
85} 85}
86static DEVICE_ATTR(online, 0644, show_online, store_online); 86static DEVICE_ATTR(online, 0644, show_online, store_online);
87 87
88static void __cpuinit register_cpu_control(struct cpu *cpu) 88static struct attribute *hotplug_cpu_attrs[] = {
89{ 89 &dev_attr_online.attr,
90 device_create_file(&cpu->dev, &dev_attr_online); 90 NULL
91} 91};
92
93static struct attribute_group hotplug_cpu_attr_group = {
94 .attrs = hotplug_cpu_attrs,
95};
96
92void unregister_cpu(struct cpu *cpu) 97void unregister_cpu(struct cpu *cpu)
93{ 98{
94 int logical_cpu = cpu->dev.id; 99 int logical_cpu = cpu->dev.id;
95 100
96 unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); 101 unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu));
97 102
98 device_remove_file(&cpu->dev, &dev_attr_online);
99
100 device_unregister(&cpu->dev); 103 device_unregister(&cpu->dev);
101 per_cpu(cpu_sys_devices, logical_cpu) = NULL; 104 per_cpu(cpu_sys_devices, logical_cpu) = NULL;
102 return; 105 return;
@@ -122,11 +125,6 @@ static ssize_t cpu_release_store(struct device *dev,
122static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 125static DEVICE_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
123static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store); 126static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store);
124#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 127#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
125
126#else /* ... !CONFIG_HOTPLUG_CPU */
127static inline void register_cpu_control(struct cpu *cpu)
128{
129}
130#endif /* CONFIG_HOTPLUG_CPU */ 128#endif /* CONFIG_HOTPLUG_CPU */
131 129
132#ifdef CONFIG_KEXEC 130#ifdef CONFIG_KEXEC
@@ -164,8 +162,35 @@ static ssize_t show_crash_notes_size(struct device *dev,
164 return rc; 162 return rc;
165} 163}
166static DEVICE_ATTR(crash_notes_size, 0400, show_crash_notes_size, NULL); 164static DEVICE_ATTR(crash_notes_size, 0400, show_crash_notes_size, NULL);
165
166static struct attribute *crash_note_cpu_attrs[] = {
167 &dev_attr_crash_notes.attr,
168 &dev_attr_crash_notes_size.attr,
169 NULL
170};
171
172static struct attribute_group crash_note_cpu_attr_group = {
173 .attrs = crash_note_cpu_attrs,
174};
167#endif 175#endif
168 176
177static const struct attribute_group *common_cpu_attr_groups[] = {
178#ifdef CONFIG_KEXEC
179 &crash_note_cpu_attr_group,
180#endif
181 NULL
182};
183
184static const struct attribute_group *hotplugable_cpu_attr_groups[] = {
185#ifdef CONFIG_KEXEC
186 &crash_note_cpu_attr_group,
187#endif
188#ifdef CONFIG_HOTPLUG_CPU
189 &hotplug_cpu_attr_group,
190#endif
191 NULL
192};
193
169/* 194/*
170 * Print cpu online, possible, present, and system maps 195 * Print cpu online, possible, present, and system maps
171 */ 196 */
@@ -280,21 +305,15 @@ int __cpuinit register_cpu(struct cpu *cpu, int num)
280#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE 305#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE
281 cpu->dev.bus->uevent = arch_cpu_uevent; 306 cpu->dev.bus->uevent = arch_cpu_uevent;
282#endif 307#endif
308 cpu->dev.groups = common_cpu_attr_groups;
309 if (cpu->hotpluggable)
310 cpu->dev.groups = hotplugable_cpu_attr_groups;
283 error = device_register(&cpu->dev); 311 error = device_register(&cpu->dev);
284 if (!error && cpu->hotpluggable)
285 register_cpu_control(cpu);
286 if (!error) 312 if (!error)
287 per_cpu(cpu_sys_devices, num) = &cpu->dev; 313 per_cpu(cpu_sys_devices, num) = &cpu->dev;
288 if (!error) 314 if (!error)
289 register_cpu_under_node(num, cpu_to_node(num)); 315 register_cpu_under_node(num, cpu_to_node(num));
290 316
291#ifdef CONFIG_KEXEC
292 if (!error)
293 error = device_create_file(&cpu->dev, &dev_attr_crash_notes);
294 if (!error)
295 error = device_create_file(&cpu->dev,
296 &dev_attr_crash_notes_size);
297#endif
298 return error; 317 return error;
299} 318}
300 319