aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/kernel/sysfs.c66
-rw-r--r--include/linux/cpu.h8
2 files changed, 74 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index d45a168bdaca..cda21a27490a 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -299,6 +299,72 @@ static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
299 .notifier_call = sysfs_cpu_notify, 299 .notifier_call = sysfs_cpu_notify,
300}; 300};
301 301
302static DEFINE_MUTEX(cpu_mutex);
303
304int cpu_add_sysdev_attr(struct sysdev_attribute *attr)
305{
306 int cpu;
307
308 mutex_lock(&cpu_mutex);
309
310 for_each_possible_cpu(cpu) {
311 sysdev_create_file(get_cpu_sysdev(cpu), attr);
312 }
313
314 mutex_unlock(&cpu_mutex);
315 return 0;
316}
317EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr);
318
319int cpu_add_sysdev_attr_group(struct attribute_group *attrs)
320{
321 int cpu;
322 struct sys_device *sysdev;
323
324 mutex_lock(&cpu_mutex);
325
326 for_each_possible_cpu(cpu) {
327 sysdev = get_cpu_sysdev(cpu);
328 sysfs_create_group(&sysdev->kobj, attrs);
329 }
330
331 mutex_unlock(&cpu_mutex);
332 return 0;
333}
334EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
335
336
337void cpu_remove_sysdev_attr(struct sysdev_attribute *attr)
338{
339 int cpu;
340
341 mutex_lock(&cpu_mutex);
342
343 for_each_possible_cpu(cpu) {
344 sysdev_remove_file(get_cpu_sysdev(cpu), attr);
345 }
346
347 mutex_unlock(&cpu_mutex);
348}
349EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr);
350
351void cpu_remove_sysdev_attr_group(struct attribute_group *attrs)
352{
353 int cpu;
354 struct sys_device *sysdev;
355
356 mutex_lock(&cpu_mutex);
357
358 for_each_possible_cpu(cpu) {
359 sysdev = get_cpu_sysdev(cpu);
360 sysfs_remove_group(&sysdev->kobj, attrs);
361 }
362
363 mutex_unlock(&cpu_mutex);
364}
365EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr_group);
366
367
302/* NUMA stuff */ 368/* NUMA stuff */
303 369
304#ifdef CONFIG_NUMA 370#ifdef CONFIG_NUMA
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 3fef7d67aedc..f02d71bf6894 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -33,6 +33,14 @@ struct cpu {
33 33
34extern int register_cpu(struct cpu *cpu, int num); 34extern int register_cpu(struct cpu *cpu, int num);
35extern struct sys_device *get_cpu_sysdev(unsigned cpu); 35extern struct sys_device *get_cpu_sysdev(unsigned cpu);
36
37extern int cpu_add_sysdev_attr(struct sysdev_attribute *attr);
38extern void cpu_remove_sysdev_attr(struct sysdev_attribute *attr);
39
40extern int cpu_add_sysdev_attr_group(struct attribute_group *attrs);
41extern void cpu_remove_sysdev_attr_group(struct attribute_group *attrs);
42
43
36#ifdef CONFIG_HOTPLUG_CPU 44#ifdef CONFIG_HOTPLUG_CPU
37extern void unregister_cpu(struct cpu *cpu); 45extern void unregister_cpu(struct cpu *cpu);
38#endif 46#endif