aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32
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/avr32
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/avr32')
-rw-r--r--arch/avr32/kernel/cpu.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/arch/avr32/kernel/cpu.c b/arch/avr32/kernel/cpu.c
index b8409caeb23d..e84faffbbeca 100644
--- a/arch/avr32/kernel/cpu.c
+++ b/arch/avr32/kernel/cpu.c
@@ -26,14 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
26 * XXX: If/when a SMP-capable implementation of AVR32 will ever be 26 * XXX: If/when a SMP-capable implementation of AVR32 will ever be
27 * made, we must make sure that the code executes on the correct CPU. 27 * made, we must make sure that the code executes on the correct CPU.
28 */ 28 */
29static ssize_t show_pc0event(struct sys_device *dev, char *buf) 29static ssize_t show_pc0event(struct sys_device *dev,
30 struct sysdev_attribute *attr, char *buf)
30{ 31{
31 unsigned long pccr; 32 unsigned long pccr;
32 33
33 pccr = sysreg_read(PCCR); 34 pccr = sysreg_read(PCCR);
34 return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f); 35 return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f);
35} 36}
36static ssize_t store_pc0event(struct sys_device *dev, const char *buf, 37static ssize_t store_pc0event(struct sys_device *dev,
38 struct sysdev_attribute *attr, const char *buf,
37 size_t count) 39 size_t count)
38{ 40{
39 unsigned long val; 41 unsigned long val;
@@ -46,15 +48,17 @@ static ssize_t store_pc0event(struct sys_device *dev, const char *buf,
46 sysreg_write(PCCR, val); 48 sysreg_write(PCCR, val);
47 return count; 49 return count;
48} 50}
49static ssize_t show_pc0count(struct sys_device *dev, char *buf) 51static ssize_t show_pc0count(struct sys_device *dev,
52 struct sysdev_attribute *attr, char *buf)
50{ 53{
51 unsigned long pcnt0; 54 unsigned long pcnt0;
52 55
53 pcnt0 = sysreg_read(PCNT0); 56 pcnt0 = sysreg_read(PCNT0);
54 return sprintf(buf, "%lu\n", pcnt0); 57 return sprintf(buf, "%lu\n", pcnt0);
55} 58}
56static ssize_t store_pc0count(struct sys_device *dev, const char *buf, 59static ssize_t store_pc0count(struct sys_device *dev,
57 size_t count) 60 struct sysdev_attribute *attr,
61 const char *buf, size_t count)
58{ 62{
59 unsigned long val; 63 unsigned long val;
60 char *endp; 64 char *endp;
@@ -67,14 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev, const char *buf,
67 return count; 71 return count;
68} 72}
69 73
70static ssize_t show_pc1event(struct sys_device *dev, char *buf) 74static ssize_t show_pc1event(struct sys_device *dev,
75 struct sysdev_attribute *attr, char *buf)
71{ 76{
72 unsigned long pccr; 77 unsigned long pccr;
73 78
74 pccr = sysreg_read(PCCR); 79 pccr = sysreg_read(PCCR);
75 return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f); 80 return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f);
76} 81}
77static ssize_t store_pc1event(struct sys_device *dev, const char *buf, 82static ssize_t store_pc1event(struct sys_device *dev,
83 struct sysdev_attribute *attr, const char *buf,
78 size_t count) 84 size_t count)
79{ 85{
80 unsigned long val; 86 unsigned long val;
@@ -87,14 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev, const char *buf,
87 sysreg_write(PCCR, val); 93 sysreg_write(PCCR, val);
88 return count; 94 return count;
89} 95}
90static ssize_t show_pc1count(struct sys_device *dev, char *buf) 96static ssize_t show_pc1count(struct sys_device *dev,
97 struct sysdev_attribute *attr, char *buf)
91{ 98{
92 unsigned long pcnt1; 99 unsigned long pcnt1;
93 100
94 pcnt1 = sysreg_read(PCNT1); 101 pcnt1 = sysreg_read(PCNT1);
95 return sprintf(buf, "%lu\n", pcnt1); 102 return sprintf(buf, "%lu\n", pcnt1);
96} 103}
97static ssize_t store_pc1count(struct sys_device *dev, const char *buf, 104static ssize_t store_pc1count(struct sys_device *dev,
105 struct sysdev_attribute *attr, const char *buf,
98 size_t count) 106 size_t count)
99{ 107{
100 unsigned long val; 108 unsigned long val;
@@ -108,14 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev, const char *buf,
108 return count; 116 return count;
109} 117}
110 118
111static ssize_t show_pccycles(struct sys_device *dev, char *buf) 119static ssize_t show_pccycles(struct sys_device *dev,
120 struct sysdev_attribute *attr, char *buf)
112{ 121{
113 unsigned long pccnt; 122 unsigned long pccnt;
114 123
115 pccnt = sysreg_read(PCCNT); 124 pccnt = sysreg_read(PCCNT);
116 return sprintf(buf, "%lu\n", pccnt); 125 return sprintf(buf, "%lu\n", pccnt);
117} 126}
118static ssize_t store_pccycles(struct sys_device *dev, const char *buf, 127static ssize_t store_pccycles(struct sys_device *dev,
128 struct sysdev_attribute *attr, const char *buf,
119 size_t count) 129 size_t count)
120{ 130{
121 unsigned long val; 131 unsigned long val;
@@ -129,14 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev, const char *buf,
129 return count; 139 return count;
130} 140}
131 141
132static ssize_t show_pcenable(struct sys_device *dev, char *buf) 142static ssize_t show_pcenable(struct sys_device *dev,
143 struct sysdev_attribute *attr, char *buf)
133{ 144{
134 unsigned long pccr; 145 unsigned long pccr;
135 146
136 pccr = sysreg_read(PCCR); 147 pccr = sysreg_read(PCCR);
137 return sprintf(buf, "%c\n", (pccr & 1)?'1':'0'); 148 return sprintf(buf, "%c\n", (pccr & 1)?'1':'0');
138} 149}
139static ssize_t store_pcenable(struct sys_device *dev, const char *buf, 150static ssize_t store_pcenable(struct sys_device *dev,
151 struct sysdev_attribute *attr, const char *buf,
140 size_t count) 152 size_t count)
141{ 153{
142 unsigned long pccr, val; 154 unsigned long pccr, val;