aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/topology.c
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2008-07-01 12:48:41 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-22 00:55:02 -0400
commit4a0b2b4dbe1335b8b9886ba3dc85a145d5d938ed (patch)
treec2d3a0f86ade5061a1bb9a14aa702323d729fd54 /drivers/base/topology.c
parent36ce6dad6e3cb3f050ed41e0beac0070d2062b25 (diff)
sysdev: Pass the attribute to the low level sysdev show/store function
This allow to dynamically generate attributes and share show/store functions between attributes. Right now most attributes are generated by special macros and lots of duplicated code. With the attribute passed it's instead possible to attach some data to the attribute and then use that in shared low level functions to do different things. I need this for the dynamically generated bank attributes in the x86 machine check code, but it'll allow some further cleanups. I converted all users in tree to the new show/store prototype. It's a single huge patch to avoid unbisectable sections. Runtime tested: x86-32, x86-64 Compiled only: ia64, powerpc Not compile tested/only grep converted: sh, arm, avr32 Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/topology.c')
-rw-r--r--drivers/base/topology.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 3f6d9b0a6abe..199cd97e32e6 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -34,7 +34,8 @@
34static SYSDEV_ATTR(_name, 0444, show_##_name, NULL) 34static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
35 35
36#define define_id_show_func(name) \ 36#define define_id_show_func(name) \
37static ssize_t show_##name(struct sys_device *dev, char *buf) \ 37static ssize_t show_##name(struct sys_device *dev, \
38 struct sysdev_attribute *attr, char *buf) \
38{ \ 39{ \
39 unsigned int cpu = dev->id; \ 40 unsigned int cpu = dev->id; \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 41 return sprintf(buf, "%d\n", topology_##name(cpu)); \
@@ -59,14 +60,17 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
59 60
60#ifdef arch_provides_topology_pointers 61#ifdef arch_provides_topology_pointers
61#define define_siblings_show_map(name) \ 62#define define_siblings_show_map(name) \
62static ssize_t show_##name(struct sys_device *dev, char *buf) \ 63static ssize_t show_##name(struct sys_device *dev, \
64 struct sysdev_attribute *attr, char *buf) \
63{ \ 65{ \
64 unsigned int cpu = dev->id; \ 66 unsigned int cpu = dev->id; \
65 return show_cpumap(0, &(topology_##name(cpu)), buf); \ 67 return show_cpumap(0, &(topology_##name(cpu)), buf); \
66} 68}
67 69
68#define define_siblings_show_list(name) \ 70#define define_siblings_show_list(name) \
69static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ 71static ssize_t show_##name##_list(struct sys_device *dev, \
72 struct sysdev_attribute *attr, \
73 char *buf) \
70{ \ 74{ \
71 unsigned int cpu = dev->id; \ 75 unsigned int cpu = dev->id; \
72 return show_cpumap(1, &(topology_##name(cpu)), buf); \ 76 return show_cpumap(1, &(topology_##name(cpu)), buf); \
@@ -74,7 +78,8 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
74 78
75#else 79#else
76#define define_siblings_show_map(name) \ 80#define define_siblings_show_map(name) \
77static ssize_t show_##name(struct sys_device *dev, char *buf) \ 81static ssize_t show_##name(struct sys_device *dev, \
82 struct sysdev_attribute *attr, char *buf) \
78{ \ 83{ \
79 unsigned int cpu = dev->id; \ 84 unsigned int cpu = dev->id; \
80 cpumask_t mask = topology_##name(cpu); \ 85 cpumask_t mask = topology_##name(cpu); \
@@ -82,7 +87,9 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
82} 87}
83 88
84#define define_siblings_show_list(name) \ 89#define define_siblings_show_list(name) \
85static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \ 90static ssize_t show_##name##_list(struct sys_device *dev, \
91 struct sysdev_attribute *attr, \
92 char *buf) \
86{ \ 93{ \
87 unsigned int cpu = dev->id; \ 94 unsigned int cpu = dev->id; \
88 cpumask_t mask = topology_##name(cpu); \ 95 cpumask_t mask = topology_##name(cpu); \