aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMike Travis <travis@sgi.com>2008-04-08 14:43:04 -0400
committerIngo Molnar <mingo@elte.hu>2008-04-19 13:44:59 -0400
commit9d1fe3236a1d64ab687e16b4cbbaa1383352a2c1 (patch)
tree059cd312cbc2253fd1e00809a5a937ba45120b99 /drivers/base
parent39106dcf85285e78f3b290022122c76f851379b8 (diff)
cpumask: add show cpu map functions
* Add cpu_sysdev_class functions to display the following maps with cpulist_scnprintf(). cpu_online_map cpu_present_map cpu_possible_map * Small change to include/linux/sysdev.h to allow the attribute name and label to be different (to avoid collision with the "attr_online" entry for bringing cpus on- and off-line.) Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Mike Travis <travis@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/cpu.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 499b003f9278..2c76afff3b15 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -103,6 +103,51 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
103#endif 103#endif
104 104
105/* 105/*
106 * Print cpu online, possible, present, and system maps
107 */
108static ssize_t print_cpus_map(char *buf, cpumask_t *map)
109{
110 int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *map);
111
112 buf[n++] = '\n';
113 buf[n] = '\0';
114 return n;
115}
116
117#define print_cpus_func(type) \
118static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \
119{ \
120 return print_cpus_map(buf, &cpu_##type##_map); \
121} \
122struct sysdev_class_attribute attr_##type##_map = \
123 _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)
124
125print_cpus_func(online);
126print_cpus_func(possible);
127print_cpus_func(present);
128
129struct sysdev_class_attribute *cpu_state_attr[] = {
130 &attr_online_map,
131 &attr_possible_map,
132 &attr_present_map,
133};
134
135static int cpu_states_init(void)
136{
137 int i;
138 int err = 0;
139
140 for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) {
141 int ret;
142 ret = sysdev_class_create_file(&cpu_sysdev_class,
143 cpu_state_attr[i]);
144 if (!err)
145 err = ret;
146 }
147 return err;
148}
149
150/*
106 * register_cpu - Setup a sysfs device for a CPU. 151 * register_cpu - Setup a sysfs device for a CPU.
107 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in 152 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
108 * sysfs for this CPU. 153 * sysfs for this CPU.
@@ -147,6 +192,9 @@ int __init cpu_dev_init(void)
147 int err; 192 int err;
148 193
149 err = sysdev_class_register(&cpu_sysdev_class); 194 err = sysdev_class_register(&cpu_sysdev_class);
195 if (!err)
196 err = cpu_states_init();
197
150#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 198#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
151 if (!err) 199 if (!err)
152 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); 200 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);