diff options
Diffstat (limited to 'drivers/base/node.c')
| -rw-r--r-- | drivers/base/node.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c index e59861f18ce5..12fde2d03d69 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
| @@ -19,21 +19,34 @@ static struct sysdev_class node_class = { | |||
| 19 | }; | 19 | }; |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | static ssize_t node_read_cpumap(struct sys_device * dev, char * buf) | 22 | static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf) |
| 23 | { | 23 | { |
| 24 | struct node *node_dev = to_node(dev); | 24 | struct node *node_dev = to_node(dev); |
| 25 | cpumask_t mask = node_to_cpumask(node_dev->sysdev.id); | 25 | node_to_cpumask_ptr(mask, node_dev->sysdev.id); |
| 26 | int len; | 26 | int len; |
| 27 | 27 | ||
| 28 | /* 2004/06/03: buf currently PAGE_SIZE, need > 1 char per 4 bits. */ | 28 | /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */ |
| 29 | BUILD_BUG_ON(MAX_NUMNODES/4 > PAGE_SIZE/2); | 29 | BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1)); |
| 30 | 30 | ||
| 31 | len = cpumask_scnprintf(buf, PAGE_SIZE-1, mask); | 31 | len = type? |
| 32 | len += sprintf(buf + len, "\n"); | 32 | cpulist_scnprintf(buf, PAGE_SIZE-2, *mask): |
| 33 | cpumask_scnprintf(buf, PAGE_SIZE-2, *mask); | ||
| 34 | buf[len++] = '\n'; | ||
| 35 | buf[len] = '\0'; | ||
| 33 | return len; | 36 | return len; |
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumap, NULL); | 39 | static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf) |
| 40 | { | ||
| 41 | return node_read_cpumap(dev, 0, buf); | ||
| 42 | } | ||
| 43 | static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf) | ||
| 44 | { | ||
| 45 | return node_read_cpumap(dev, 1, buf); | ||
| 46 | } | ||
| 47 | |||
| 48 | static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL); | ||
| 49 | static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL); | ||
| 37 | 50 | ||
| 38 | #define K(x) ((x) << (PAGE_SHIFT - 10)) | 51 | #define K(x) ((x) << (PAGE_SHIFT - 10)) |
| 39 | static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) | 52 | static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) |
| @@ -149,6 +162,7 @@ int register_node(struct node *node, int num, struct node *parent) | |||
| 149 | 162 | ||
| 150 | if (!error){ | 163 | if (!error){ |
| 151 | sysdev_create_file(&node->sysdev, &attr_cpumap); | 164 | sysdev_create_file(&node->sysdev, &attr_cpumap); |
| 165 | sysdev_create_file(&node->sysdev, &attr_cpulist); | ||
| 152 | sysdev_create_file(&node->sysdev, &attr_meminfo); | 166 | sysdev_create_file(&node->sysdev, &attr_meminfo); |
| 153 | sysdev_create_file(&node->sysdev, &attr_numastat); | 167 | sysdev_create_file(&node->sysdev, &attr_numastat); |
| 154 | sysdev_create_file(&node->sysdev, &attr_distance); | 168 | sysdev_create_file(&node->sysdev, &attr_distance); |
| @@ -166,6 +180,7 @@ int register_node(struct node *node, int num, struct node *parent) | |||
| 166 | void unregister_node(struct node *node) | 180 | void unregister_node(struct node *node) |
| 167 | { | 181 | { |
| 168 | sysdev_remove_file(&node->sysdev, &attr_cpumap); | 182 | sysdev_remove_file(&node->sysdev, &attr_cpumap); |
| 183 | sysdev_remove_file(&node->sysdev, &attr_cpulist); | ||
| 169 | sysdev_remove_file(&node->sysdev, &attr_meminfo); | 184 | sysdev_remove_file(&node->sysdev, &attr_meminfo); |
| 170 | sysdev_remove_file(&node->sysdev, &attr_numastat); | 185 | sysdev_remove_file(&node->sysdev, &attr_numastat); |
| 171 | sysdev_remove_file(&node->sysdev, &attr_distance); | 186 | sysdev_remove_file(&node->sysdev, &attr_distance); |
