aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
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 /arch/powerpc
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 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/sysfs.c15
-rw-r--r--arch/powerpc/platforms/cell/cbe_thermal.c45
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c3
3 files changed, 43 insertions, 20 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index c8127f832df0..aba0ba95f062 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -28,7 +28,9 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
28/* Time in microseconds we delay before sleeping in the idle loop */ 28/* Time in microseconds we delay before sleeping in the idle loop */
29DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 }; 29DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
30 30
31static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf, 31static ssize_t store_smt_snooze_delay(struct sys_device *dev,
32 struct sysdev_attribute *attr,
33 const char *buf,
32 size_t count) 34 size_t count)
33{ 35{
34 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 36 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
@@ -44,7 +46,9 @@ static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf,
44 return count; 46 return count;
45} 47}
46 48
47static ssize_t show_smt_snooze_delay(struct sys_device *dev, char *buf) 49static ssize_t show_smt_snooze_delay(struct sys_device *dev,
50 struct sysdev_attribute *attr,
51 char *buf)
48{ 52{
49 struct cpu *cpu = container_of(dev, struct cpu, sysdev); 53 struct cpu *cpu = container_of(dev, struct cpu, sysdev);
50 54
@@ -152,14 +156,17 @@ static unsigned long write_##NAME(unsigned long val) \
152 mtspr(ADDRESS, val); \ 156 mtspr(ADDRESS, val); \
153 return 0; \ 157 return 0; \
154} \ 158} \
155static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ 159static ssize_t show_##NAME(struct sys_device *dev, \
160 struct sysdev_attribute *attr, \
161 char *buf) \
156{ \ 162{ \
157 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 163 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
158 unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \ 164 unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
159 return sprintf(buf, "%lx\n", val); \ 165 return sprintf(buf, "%lx\n", val); \
160} \ 166} \
161static ssize_t __used \ 167static ssize_t __used \
162 store_##NAME(struct sys_device *dev, const char *buf, size_t count) \ 168 store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \
169 const char *buf, size_t count) \
163{ \ 170{ \
164 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ 171 struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
165 unsigned long val; \ 172 unsigned long val; \
diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c b/arch/powerpc/platforms/cell/cbe_thermal.c
index 4852bf312d83..4d4c8c169124 100644
--- a/arch/powerpc/platforms/cell/cbe_thermal.c
+++ b/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -97,7 +97,8 @@ static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iom
97 return value.spe[spu->spe_id]; 97 return value.spe[spu->spe_id];
98} 98}
99 99
100static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf) 100static ssize_t spu_show_temp(struct sys_device *sysdev, struct sysdev_attribute *attr,
101 char *buf)
101{ 102{
102 u8 value; 103 u8 value;
103 struct cbe_pmd_regs __iomem *pmd_regs; 104 struct cbe_pmd_regs __iomem *pmd_regs;
@@ -146,32 +147,38 @@ static ssize_t store_throttle(struct cbe_pmd_regs __iomem *pmd_regs, const char
146 return size; 147 return size;
147} 148}
148 149
149static ssize_t spu_show_throttle_end(struct sys_device *sysdev, char *buf) 150static ssize_t spu_show_throttle_end(struct sys_device *sysdev,
151 struct sysdev_attribute *attr, char *buf)
150{ 152{
151 return show_throttle(get_pmd_regs(sysdev), buf, 0); 153 return show_throttle(get_pmd_regs(sysdev), buf, 0);
152} 154}
153 155
154static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, char *buf) 156static ssize_t spu_show_throttle_begin(struct sys_device *sysdev,
157 struct sysdev_attribute *attr, char *buf)
155{ 158{
156 return show_throttle(get_pmd_regs(sysdev), buf, 8); 159 return show_throttle(get_pmd_regs(sysdev), buf, 8);
157} 160}
158 161
159static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, char *buf) 162static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev,
163 struct sysdev_attribute *attr, char *buf)
160{ 164{
161 return show_throttle(get_pmd_regs(sysdev), buf, 16); 165 return show_throttle(get_pmd_regs(sysdev), buf, 16);
162} 166}
163 167
164static ssize_t spu_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size) 168static ssize_t spu_store_throttle_end(struct sys_device *sysdev,
169 struct sysdev_attribute *attr, const char *buf, size_t size)
165{ 170{
166 return store_throttle(get_pmd_regs(sysdev), buf, size, 0); 171 return store_throttle(get_pmd_regs(sysdev), buf, size, 0);
167} 172}
168 173
169static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size) 174static ssize_t spu_store_throttle_begin(struct sys_device *sysdev,
175 struct sysdev_attribute *attr, const char *buf, size_t size)
170{ 176{
171 return store_throttle(get_pmd_regs(sysdev), buf, size, 8); 177 return store_throttle(get_pmd_regs(sysdev), buf, size, 8);
172} 178}
173 179
174static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size) 180static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev,
181 struct sysdev_attribute *attr, const char *buf, size_t size)
175{ 182{
176 return store_throttle(get_pmd_regs(sysdev), buf, size, 16); 183 return store_throttle(get_pmd_regs(sysdev), buf, size, 16);
177} 184}
@@ -192,43 +199,51 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
192 199
193/* shows the temperature of the DTS on the PPE, 200/* shows the temperature of the DTS on the PPE,
194 * located near the linear thermal sensor */ 201 * located near the linear thermal sensor */
195static ssize_t ppe_show_temp0(struct sys_device *sysdev, char *buf) 202static ssize_t ppe_show_temp0(struct sys_device *sysdev,
203 struct sysdev_attribute *attr, char *buf)
196{ 204{
197 return ppe_show_temp(sysdev, buf, 32); 205 return ppe_show_temp(sysdev, buf, 32);
198} 206}
199 207
200/* shows the temperature of the second DTS on the PPE */ 208/* shows the temperature of the second DTS on the PPE */
201static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf) 209static ssize_t ppe_show_temp1(struct sys_device *sysdev,
210 struct sysdev_attribute *attr, char *buf)
202{ 211{
203 return ppe_show_temp(sysdev, buf, 0); 212 return ppe_show_temp(sysdev, buf, 0);
204} 213}
205 214
206static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, char *buf) 215static ssize_t ppe_show_throttle_end(struct sys_device *sysdev,
216 struct sysdev_attribute *attr, char *buf)
207{ 217{
208 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32); 218 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32);
209} 219}
210 220
211static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, char *buf) 221static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev,
222 struct sysdev_attribute *attr, char *buf)
212{ 223{
213 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40); 224 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40);
214} 225}
215 226
216static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, char *buf) 227static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev,
228 struct sysdev_attribute *attr, char *buf)
217{ 229{
218 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48); 230 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48);
219} 231}
220 232
221static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size) 233static ssize_t ppe_store_throttle_end(struct sys_device *sysdev,
234 struct sysdev_attribute *attr, const char *buf, size_t size)
222{ 235{
223 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32); 236 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32);
224} 237}
225 238
226static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size) 239static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev,
240 struct sysdev_attribute *attr, const char *buf, size_t size)
227{ 241{
228 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40); 242 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40);
229} 243}
230 244
231static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size) 245static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev,
246 struct sysdev_attribute *attr, const char *buf, size_t size)
232{ 247{
233 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48); 248 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48);
234} 249}
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 78f905bc6a42..a5bdb89a17c3 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -703,7 +703,8 @@ static unsigned long long spu_acct_time(struct spu *spu,
703} 703}
704 704
705 705
706static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf) 706static ssize_t spu_stat_show(struct sys_device *sysdev,
707 struct sysdev_attribute *attr, char *buf)
707{ 708{
708 struct spu *spu = container_of(sysdev, struct spu, sysdev); 709 struct spu *spu = container_of(sysdev, struct spu, sysdev);
709 710