Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 91081
b: refs/heads/master
c: 9d1fe32
h: refs/heads/master
i:
  91079: eecc984
v: v3
  • Loading branch information
Mike Travis authored and Ingo Molnar committed Apr 19, 2008
1 parent 74685f0 commit 967b624
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 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: 39106dcf85285e78f3b290022122c76f851379b8
refs/heads/master: 9d1fe3236a1d64ab687e16b4cbbaa1383352a2c1
48 changes: 48 additions & 0 deletions trunk/drivers/base/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,51 @@ static ssize_t show_crash_notes(struct sys_device *dev, char *buf)
static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
#endif

/*
* Print cpu online, possible, present, and system maps
*/
static ssize_t print_cpus_map(char *buf, cpumask_t *map)
{
int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *map);

buf[n++] = '\n';
buf[n] = '\0';
return n;
}

#define print_cpus_func(type) \
static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \
{ \
return print_cpus_map(buf, &cpu_##type##_map); \
} \
struct sysdev_class_attribute attr_##type##_map = \
_SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)

print_cpus_func(online);
print_cpus_func(possible);
print_cpus_func(present);

struct sysdev_class_attribute *cpu_state_attr[] = {
&attr_online_map,
&attr_possible_map,
&attr_present_map,
};

static int cpu_states_init(void)
{
int i;
int err = 0;

for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) {
int ret;
ret = sysdev_class_create_file(&cpu_sysdev_class,
cpu_state_attr[i]);
if (!err)
err = ret;
}
return err;
}

/*
* register_cpu - Setup a sysfs device for a CPU.
* @cpu - cpu->hotpluggable field set to 1 will generate a control file in
Expand Down Expand Up @@ -147,6 +192,9 @@ int __init cpu_dev_init(void)
int err;

err = sysdev_class_register(&cpu_sysdev_class);
if (!err)
err = cpu_states_init();

#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
if (!err)
err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
Expand Down
17 changes: 11 additions & 6 deletions trunk/include/linux/sysdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ struct sysdev_class_attribute {
ssize_t (*store)(struct sysdev_class *, const char *, size_t);
};

#define SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \
struct sysdev_class_attribute attr_##_name = { \
#define _SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \
{ \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
};
}

#define SYSDEV_CLASS_ATTR(_name,_mode,_show,_store) \
struct sysdev_class_attribute attr_##_name = \
_SYSDEV_CLASS_ATTR(_name,_mode,_show,_store)


extern int sysdev_class_register(struct sysdev_class *);
Expand Down Expand Up @@ -100,15 +104,16 @@ struct sysdev_attribute {
};


#define _SYSDEV_ATTR(_name,_mode,_show,_store) \
#define _SYSDEV_ATTR(_name, _mode, _show, _store) \
{ \
.attr = { .name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
}

#define SYSDEV_ATTR(_name,_mode,_show,_store) \
struct sysdev_attribute attr_##_name = _SYSDEV_ATTR(_name,_mode,_show,_store);
#define SYSDEV_ATTR(_name, _mode, _show, _store) \
struct sysdev_attribute attr_##_name = \
_SYSDEV_ATTR(_name, _mode, _show, _store);

extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
Expand Down

0 comments on commit 967b624

Please sign in to comment.