diff options
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/cpu.c | 48 |
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 | */ | ||
108 | static 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) \ | ||
118 | static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \ | ||
119 | { \ | ||
120 | return print_cpus_map(buf, &cpu_##type##_map); \ | ||
121 | } \ | ||
122 | struct sysdev_class_attribute attr_##type##_map = \ | ||
123 | _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL) | ||
124 | |||
125 | print_cpus_func(online); | ||
126 | print_cpus_func(possible); | ||
127 | print_cpus_func(present); | ||
128 | |||
129 | struct sysdev_class_attribute *cpu_state_attr[] = { | ||
130 | &attr_online_map, | ||
131 | &attr_possible_map, | ||
132 | &attr_present_map, | ||
133 | }; | ||
134 | |||
135 | static 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); |