diff options
author | Andi Kleen <andi@firstfloor.org> | 2008-07-01 12:48:41 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-07-22 00:55:02 -0400 |
commit | 4a0b2b4dbe1335b8b9886ba3dc85a145d5d938ed (patch) | |
tree | c2d3a0f86ade5061a1bb9a14aa702323d729fd54 /arch/ia64 | |
parent | 36ce6dad6e3cb3f050ed41e0beac0070d2062b25 (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 'arch/ia64')
-rw-r--r-- | arch/ia64/kernel/err_inject.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c index b642648cc2ac..c539c689493b 100644 --- a/arch/ia64/kernel/err_inject.c +++ b/arch/ia64/kernel/err_inject.c | |||
@@ -55,7 +55,8 @@ static u64 resources[NR_CPUS]; | |||
55 | 55 | ||
56 | #define show(name) \ | 56 | #define show(name) \ |
57 | static ssize_t \ | 57 | static ssize_t \ |
58 | show_##name(struct sys_device *dev, char *buf) \ | 58 | show_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ |
59 | char *buf) \ | ||
59 | { \ | 60 | { \ |
60 | u32 cpu=dev->id; \ | 61 | u32 cpu=dev->id; \ |
61 | return sprintf(buf, "%lx\n", name[cpu]); \ | 62 | return sprintf(buf, "%lx\n", name[cpu]); \ |
@@ -63,7 +64,8 @@ show_##name(struct sys_device *dev, char *buf) \ | |||
63 | 64 | ||
64 | #define store(name) \ | 65 | #define store(name) \ |
65 | static ssize_t \ | 66 | static ssize_t \ |
66 | store_##name(struct sys_device *dev, const char *buf, size_t size) \ | 67 | store_##name(struct sys_device *dev, struct sysdev_attribute *attr, \ |
68 | const char *buf, size_t size) \ | ||
67 | { \ | 69 | { \ |
68 | unsigned int cpu=dev->id; \ | 70 | unsigned int cpu=dev->id; \ |
69 | name[cpu] = simple_strtoull(buf, NULL, 16); \ | 71 | name[cpu] = simple_strtoull(buf, NULL, 16); \ |
@@ -76,7 +78,8 @@ show(call_start) | |||
76 | * processor. The cpu number in driver is only used for storing data. | 78 | * processor. The cpu number in driver is only used for storing data. |
77 | */ | 79 | */ |
78 | static ssize_t | 80 | static ssize_t |
79 | store_call_start(struct sys_device *dev, const char *buf, size_t size) | 81 | store_call_start(struct sys_device *dev, struct sysdev_attribute *attr, |
82 | const char *buf, size_t size) | ||
80 | { | 83 | { |
81 | unsigned int cpu=dev->id; | 84 | unsigned int cpu=dev->id; |
82 | unsigned long call_start = simple_strtoull(buf, NULL, 16); | 85 | unsigned long call_start = simple_strtoull(buf, NULL, 16); |
@@ -124,14 +127,16 @@ show(err_type_info) | |||
124 | store(err_type_info) | 127 | store(err_type_info) |
125 | 128 | ||
126 | static ssize_t | 129 | static ssize_t |
127 | show_virtual_to_phys(struct sys_device *dev, char *buf) | 130 | show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, |
131 | char *buf) | ||
128 | { | 132 | { |
129 | unsigned int cpu=dev->id; | 133 | unsigned int cpu=dev->id; |
130 | return sprintf(buf, "%lx\n", phys_addr[cpu]); | 134 | return sprintf(buf, "%lx\n", phys_addr[cpu]); |
131 | } | 135 | } |
132 | 136 | ||
133 | static ssize_t | 137 | static ssize_t |
134 | store_virtual_to_phys(struct sys_device *dev, const char *buf, size_t size) | 138 | store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr, |
139 | const char *buf, size_t size) | ||
135 | { | 140 | { |
136 | unsigned int cpu=dev->id; | 141 | unsigned int cpu=dev->id; |
137 | u64 virt_addr=simple_strtoull(buf, NULL, 16); | 142 | u64 virt_addr=simple_strtoull(buf, NULL, 16); |
@@ -154,7 +159,8 @@ show(err_struct_info) | |||
154 | store(err_struct_info) | 159 | store(err_struct_info) |
155 | 160 | ||
156 | static ssize_t | 161 | static ssize_t |
157 | show_err_data_buffer(struct sys_device *dev, char *buf) | 162 | show_err_data_buffer(struct sys_device *dev, |
163 | struct sysdev_attribute *attr, char *buf) | ||
158 | { | 164 | { |
159 | unsigned int cpu=dev->id; | 165 | unsigned int cpu=dev->id; |
160 | 166 | ||
@@ -165,7 +171,9 @@ show_err_data_buffer(struct sys_device *dev, char *buf) | |||
165 | } | 171 | } |
166 | 172 | ||
167 | static ssize_t | 173 | static ssize_t |
168 | store_err_data_buffer(struct sys_device *dev, const char *buf, size_t size) | 174 | store_err_data_buffer(struct sys_device *dev, |
175 | struct sysdev_attribute *attr, | ||
176 | const char *buf, size_t size) | ||
169 | { | 177 | { |
170 | unsigned int cpu=dev->id; | 178 | unsigned int cpu=dev->id; |
171 | int ret; | 179 | int ret; |