aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/node.c')
-rw-r--r--drivers/base/node.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 8e3f25bb8f80..12fde2d03d69 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -19,22 +19,34 @@ static struct sysdev_class node_class = {
19}; 19};
20 20
21 21
22static ssize_t node_read_cpumap(struct sys_device * dev, char * buf) 22static 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 node_to_cpumask_ptr(mask, 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-2, *mask); 31 len = type?
32 cpulist_scnprintf(buf, PAGE_SIZE-2, *mask):
33 cpumask_scnprintf(buf, PAGE_SIZE-2, *mask);
32 buf[len++] = '\n'; 34 buf[len++] = '\n';
33 buf[len] = '\0'; 35 buf[len] = '\0';
34 return len; 36 return len;
35} 37}
36 38
37static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumap, NULL); 39static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf)
40{
41 return node_read_cpumap(dev, 0, buf);
42}
43static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf)
44{
45 return node_read_cpumap(dev, 1, buf);
46}
47
48static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL);
49static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
38 50
39#define K(x) ((x) << (PAGE_SHIFT - 10)) 51#define K(x) ((x) << (PAGE_SHIFT - 10))
40static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) 52static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
@@ -150,6 +162,7 @@ int register_node(struct node *node, int num, struct node *parent)
150 162
151 if (!error){ 163 if (!error){
152 sysdev_create_file(&node->sysdev, &attr_cpumap); 164 sysdev_create_file(&node->sysdev, &attr_cpumap);
165 sysdev_create_file(&node->sysdev, &attr_cpulist);
153 sysdev_create_file(&node->sysdev, &attr_meminfo); 166 sysdev_create_file(&node->sysdev, &attr_meminfo);
154 sysdev_create_file(&node->sysdev, &attr_numastat); 167 sysdev_create_file(&node->sysdev, &attr_numastat);
155 sysdev_create_file(&node->sysdev, &attr_distance); 168 sysdev_create_file(&node->sysdev, &attr_distance);
@@ -167,6 +180,7 @@ int register_node(struct node *node, int num, struct node *parent)
167void unregister_node(struct node *node) 180void unregister_node(struct node *node)
168{ 181{
169 sysdev_remove_file(&node->sysdev, &attr_cpumap); 182 sysdev_remove_file(&node->sysdev, &attr_cpumap);
183 sysdev_remove_file(&node->sysdev, &attr_cpulist);
170 sysdev_remove_file(&node->sysdev, &attr_meminfo); 184 sysdev_remove_file(&node->sysdev, &attr_meminfo);
171 sysdev_remove_file(&node->sysdev, &attr_numastat); 185 sysdev_remove_file(&node->sysdev, &attr_numastat);
172 sysdev_remove_file(&node->sysdev, &attr_distance); 186 sysdev_remove_file(&node->sysdev, &attr_distance);