diff options
| author | Andi Kleen <andi@firstfloor.org> | 2010-01-05 06:48:00 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-07 20:04:47 -0500 |
| commit | 265d2e2e31c5f6dc1b20ae1653a17fdba706f79e (patch) | |
| tree | ef5de928828081f97e7d85650993bc6e0c281f2b | |
| parent | b15f562fc2f5429f27e5dfb0b0ee5ec44f661986 (diff) | |
sysdev: Convert cpu driver sysdev class attributes
Using the new attribute argument convert the cpu driver class attributes
to carry the node state. Then use a shared function to do what a lot of
individual functions did before.
This eliminates an ugly macro.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/base/cpu.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index fd1b2f9b7b8f..b04ecfc63b51 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c | |||
| @@ -141,27 +141,32 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); | |||
| 141 | /* | 141 | /* |
| 142 | * Print cpu online, possible, present, and system maps | 142 | * Print cpu online, possible, present, and system maps |
| 143 | */ | 143 | */ |
| 144 | static ssize_t print_cpus_map(char *buf, const struct cpumask *map) | 144 | |
| 145 | struct cpu_attr { | ||
| 146 | struct sysdev_class_attribute attr; | ||
| 147 | const struct cpumask *const * const map; | ||
| 148 | }; | ||
| 149 | |||
| 150 | static ssize_t show_cpus_attr(struct sysdev_class *class, | ||
| 151 | struct sysdev_class_attribute *attr, | ||
| 152 | char *buf) | ||
| 145 | { | 153 | { |
| 146 | int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map); | 154 | struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr); |
| 155 | int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *(ca->map)); | ||
| 147 | 156 | ||
| 148 | buf[n++] = '\n'; | 157 | buf[n++] = '\n'; |
| 149 | buf[n] = '\0'; | 158 | buf[n] = '\0'; |
| 150 | return n; | 159 | return n; |
| 151 | } | 160 | } |
| 152 | 161 | ||
| 153 | #define print_cpus_func(type) \ | 162 | #define _CPU_ATTR(name, map) \ |
| 154 | static ssize_t print_cpus_##type(struct sysdev_class *class, \ | 163 | { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map } |
| 155 | struct sysdev_class_attribute *attr, char *buf) \ | ||
| 156 | { \ | ||
| 157 | return print_cpus_map(buf, cpu_##type##_mask); \ | ||
| 158 | } \ | ||
| 159 | static struct sysdev_class_attribute attr_##type##_map = \ | ||
| 160 | _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL) | ||
| 161 | 164 | ||
| 162 | print_cpus_func(online); | 165 | static struct cpu_attr cpu_attrs[] = { |
| 163 | print_cpus_func(possible); | 166 | _CPU_ATTR(online, &cpu_online_mask), |
| 164 | print_cpus_func(present); | 167 | _CPU_ATTR(possible, &cpu_possible_mask), |
| 168 | _CPU_ATTR(present, &cpu_present_mask), | ||
| 169 | }; | ||
| 165 | 170 | ||
| 166 | /* | 171 | /* |
| 167 | * Print values for NR_CPUS and offlined cpus | 172 | * Print values for NR_CPUS and offlined cpus |
| @@ -208,9 +213,9 @@ static ssize_t print_cpus_offline(struct sysdev_class *class, | |||
| 208 | static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); | 213 | static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); |
| 209 | 214 | ||
| 210 | static struct sysdev_class_attribute *cpu_state_attr[] = { | 215 | static struct sysdev_class_attribute *cpu_state_attr[] = { |
| 211 | &attr_online_map, | 216 | &cpu_attrs[0].attr, |
| 212 | &attr_possible_map, | 217 | &cpu_attrs[1].attr, |
| 213 | &attr_present_map, | 218 | &cpu_attrs[2].attr, |
| 214 | &attr_kernel_max, | 219 | &attr_kernel_max, |
| 215 | &attr_offline, | 220 | &attr_offline, |
| 216 | }; | 221 | }; |
