aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2010-01-05 06:48:03 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-07 20:04:47 -0500
commite1a7e29a266ba3313a873d302b352521403bd155 (patch)
tree37d3e07b7975eb5850743fc95fa3c02ac0fcef75 /drivers/base
parent38457ab3a0d36320370c715145ba6da514127194 (diff)
sysdev: Convert node driver
Use sysdev_class attribute arrays in node driver Convert the node driver to sysdev_class attribute arrays. This greatly cleans up the code and remove a lot of code. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/cpu.c57
1 files changed, 17 insertions, 40 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index b04ecfc63b51..fb456b729803 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -13,8 +13,11 @@
13 13
14#include "base.h" 14#include "base.h"
15 15
16static struct sysdev_class_attribute *cpu_sysdev_class_attrs[];
17
16struct sysdev_class cpu_sysdev_class = { 18struct sysdev_class cpu_sysdev_class = {
17 .name = "cpu", 19 .name = "cpu",
20 .attrs = cpu_sysdev_class_attrs,
18}; 21};
19EXPORT_SYMBOL(cpu_sysdev_class); 22EXPORT_SYMBOL(cpu_sysdev_class);
20 23
@@ -90,20 +93,6 @@ static ssize_t cpu_release_store(struct class *class, const char *buf,
90 93
91static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 94static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
92static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); 95static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store);
93
94int __init cpu_probe_release_init(void)
95{
96 int rc;
97
98 rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
99 &class_attr_probe.attr);
100 if (!rc)
101 rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
102 &class_attr_release.attr);
103
104 return rc;
105}
106device_initcall(cpu_probe_release_init);
107#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 96#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
108 97
109#else /* ... !CONFIG_HOTPLUG_CPU */ 98#else /* ... !CONFIG_HOTPLUG_CPU */
@@ -162,6 +151,7 @@ static ssize_t show_cpus_attr(struct sysdev_class *class,
162#define _CPU_ATTR(name, map) \ 151#define _CPU_ATTR(name, map) \
163 { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map } 152 { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map }
164 153
154/* Keep in sync with cpu_sysdev_class_attrs */
165static struct cpu_attr cpu_attrs[] = { 155static struct cpu_attr cpu_attrs[] = {
166 _CPU_ATTR(online, &cpu_online_mask), 156 _CPU_ATTR(online, &cpu_online_mask),
167 _CPU_ATTR(possible, &cpu_possible_mask), 157 _CPU_ATTR(possible, &cpu_possible_mask),
@@ -212,29 +202,6 @@ static ssize_t print_cpus_offline(struct sysdev_class *class,
212} 202}
213static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); 203static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL);
214 204
215static struct sysdev_class_attribute *cpu_state_attr[] = {
216 &cpu_attrs[0].attr,
217 &cpu_attrs[1].attr,
218 &cpu_attrs[2].attr,
219 &attr_kernel_max,
220 &attr_offline,
221};
222
223static int cpu_states_init(void)
224{
225 int i;
226 int err = 0;
227
228 for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) {
229 int ret;
230 ret = sysdev_class_create_file(&cpu_sysdev_class,
231 cpu_state_attr[i]);
232 if (!err)
233 err = ret;
234 }
235 return err;
236}
237
238/* 205/*
239 * register_cpu - Setup a sysfs device for a CPU. 206 * register_cpu - Setup a sysfs device for a CPU.
240 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in 207 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
@@ -280,9 +247,6 @@ int __init cpu_dev_init(void)
280 int err; 247 int err;
281 248
282 err = sysdev_class_register(&cpu_sysdev_class); 249 err = sysdev_class_register(&cpu_sysdev_class);
283 if (!err)
284 err = cpu_states_init();
285
286#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 250#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
287 if (!err) 251 if (!err)
288 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); 252 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
@@ -290,3 +254,16 @@ int __init cpu_dev_init(void)
290 254
291 return err; 255 return err;
292} 256}
257
258static struct sysdev_class_attribute *cpu_sysdev_class_attrs[] = {
259#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
260 &class_attr_probe.attr,
261 &class_attr_release.attr,
262#endif
263 &cpu_attrs[0].attr,
264 &cpu_attrs[1].attr,
265 &cpu_attrs[2].attr,
266 &attr_kernel_max,
267 &attr_offline,
268 NULL
269};