Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 187049
b: refs/heads/master
c: 265d2e2
h: refs/heads/master
i:
  187047: 492a6a1
v: v3
  • Loading branch information
Andi Kleen authored and Greg Kroah-Hartman committed Mar 8, 2010
1 parent 9e57308 commit 4d92c56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b15f562fc2f5429f27e5dfb0b0ee5ec44f661986
refs/heads/master: 265d2e2e31c5f6dc1b20ae1653a17fdba706f79e
37 changes: 21 additions & 16 deletions trunk/drivers/base/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,32 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
/*
* 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] = '\0';
return n;
}

#define print_cpus_func(type) \
static ssize_t print_cpus_##type(struct sysdev_class *class, \
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)
#define _CPU_ATTR(name, map) \
{ _SYSDEV_CLASS_ATTR(name, 0444, show_cpus_attr, NULL), map }

print_cpus_func(online);
print_cpus_func(possible);
print_cpus_func(present);
static struct cpu_attr cpu_attrs[] = {
_CPU_ATTR(online, &cpu_online_mask),
_CPU_ATTR(possible, &cpu_possible_mask),
_CPU_ATTR(present, &cpu_present_mask),
};

/*
* Print values for NR_CPUS and offlined cpus
Expand Down Expand Up @@ -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 struct sysdev_class_attribute *cpu_state_attr[] = {
&attr_online_map,
&attr_possible_map,
&attr_present_map,
&cpu_attrs[0].attr,
&cpu_attrs[1].attr,
&cpu_attrs[2].attr,
&attr_kernel_max,
&attr_offline,
};
Expand Down

0 comments on commit 4d92c56

Please sign in to comment.