Commit 265d2e2e authored by Andi Kleen's avatar Andi Kleen Committed by Greg Kroah-Hartman

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: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b15f562f
...@@ -141,27 +141,32 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL); ...@@ -141,27 +141,32 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
/* /*
* Print cpu online, possible, present, and system maps * Print cpu online, possible, present, and system maps
*/ */
static ssize_t print_cpus_map(char *buf, const struct cpumask *map)
struct cpu_attr {
struct sysdev_class_attribute attr;
const struct cpumask *const * const map;
};
static ssize_t show_cpus_attr(struct sysdev_class *class,
struct sysdev_class_attribute *attr,
char *buf)
{ {
int n = cpulist_scnprintf(buf, PAGE_SIZE-2, map); struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr);
int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *(ca->map));
buf[n++] = '\n'; buf[n++] = '\n';
buf[n] = '\0'; buf[n] = '\0';
return n; return n;
} }
#define print_cpus_func(type) \ #define _CPU_ATTR(name, map) \
static ssize_t print_cpus_##type(struct sysdev_class *class, \ { _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map }
struct sysdev_class_attribute *attr, char *buf) \
{ \
return print_cpus_map(buf, cpu_##type##_mask); \
} \
static struct sysdev_class_attribute attr_##type##_map = \
_SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)
print_cpus_func(online); static struct cpu_attr cpu_attrs[] = {
print_cpus_func(possible); _CPU_ATTR(online, &cpu_online_mask),
print_cpus_func(present); _CPU_ATTR(possible, &cpu_possible_mask),
_CPU_ATTR(present, &cpu_present_mask),
};
/* /*
* Print values for NR_CPUS and offlined cpus * Print values for NR_CPUS and offlined cpus
...@@ -208,9 +213,9 @@ static ssize_t print_cpus_offline(struct sysdev_class *class, ...@@ -208,9 +213,9 @@ static ssize_t print_cpus_offline(struct sysdev_class *class,
static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL); static SYSDEV_CLASS_ATTR(offline, 0444, print_cpus_offline, NULL);
static struct sysdev_class_attribute *cpu_state_attr[] = { static struct sysdev_class_attribute *cpu_state_attr[] = {
&attr_online_map, &cpu_attrs[0].attr,
&attr_possible_map, &cpu_attrs[1].attr,
&attr_present_map, &cpu_attrs[2].attr,
&attr_kernel_max, &attr_kernel_max,
&attr_offline, &attr_offline,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment