aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/kernel/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/avr32/kernel/cpu.c')
-rw-r--r--arch/avr32/kernel/cpu.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/arch/avr32/kernel/cpu.c b/arch/avr32/kernel/cpu.c
index 2233be71e2e8..0341ae27c9ec 100644
--- a/arch/avr32/kernel/cpu.c
+++ b/arch/avr32/kernel/cpu.c
@@ -39,10 +39,12 @@ static ssize_t store_pc0event(struct device *dev,
39 size_t count) 39 size_t count)
40{ 40{
41 unsigned long val; 41 unsigned long val;
42 char *endp; 42 int ret;
43 43
44 val = simple_strtoul(buf, &endp, 0); 44 ret = kstrtoul(buf, 0, &val);
45 if (endp == buf || val > 0x3f) 45 if (ret)
46 return ret;
47 if (val > 0x3f)
46 return -EINVAL; 48 return -EINVAL;
47 val = (val << 12) | (sysreg_read(PCCR) & 0xfffc0fff); 49 val = (val << 12) | (sysreg_read(PCCR) & 0xfffc0fff);
48 sysreg_write(PCCR, val); 50 sysreg_write(PCCR, val);
@@ -61,11 +63,11 @@ static ssize_t store_pc0count(struct device *dev,
61 const char *buf, size_t count) 63 const char *buf, size_t count)
62{ 64{
63 unsigned long val; 65 unsigned long val;
64 char *endp; 66 int ret;
65 67
66 val = simple_strtoul(buf, &endp, 0); 68 ret = kstrtoul(buf, 0, &val);
67 if (endp == buf) 69 if (ret)
68 return -EINVAL; 70 return ret;
69 sysreg_write(PCNT0, val); 71 sysreg_write(PCNT0, val);
70 72
71 return count; 73 return count;
@@ -84,10 +86,12 @@ static ssize_t store_pc1event(struct device *dev,
84 size_t count) 86 size_t count)
85{ 87{
86 unsigned long val; 88 unsigned long val;
87 char *endp; 89 int ret;
88 90
89 val = simple_strtoul(buf, &endp, 0); 91 ret = kstrtoul(buf, 0, &val);
90 if (endp == buf || val > 0x3f) 92 if (ret)
93 return ret;
94 if (val > 0x3f)
91 return -EINVAL; 95 return -EINVAL;
92 val = (val << 18) | (sysreg_read(PCCR) & 0xff03ffff); 96 val = (val << 18) | (sysreg_read(PCCR) & 0xff03ffff);
93 sysreg_write(PCCR, val); 97 sysreg_write(PCCR, val);
@@ -106,11 +110,11 @@ static ssize_t store_pc1count(struct device *dev,
106 size_t count) 110 size_t count)
107{ 111{
108 unsigned long val; 112 unsigned long val;
109 char *endp; 113 int ret;
110 114
111 val = simple_strtoul(buf, &endp, 0); 115 ret = kstrtoul(buf, 0, &val);
112 if (endp == buf) 116 if (ret)
113 return -EINVAL; 117 return ret;
114 sysreg_write(PCNT1, val); 118 sysreg_write(PCNT1, val);
115 119
116 return count; 120 return count;
@@ -129,11 +133,11 @@ static ssize_t store_pccycles(struct device *dev,
129 size_t count) 133 size_t count)
130{ 134{
131 unsigned long val; 135 unsigned long val;
132 char *endp; 136 int ret;
133 137
134 val = simple_strtoul(buf, &endp, 0); 138 ret = kstrtoul(buf, 0, &val);
135 if (endp == buf) 139 if (ret)
136 return -EINVAL; 140 return ret;
137 sysreg_write(PCCNT, val); 141 sysreg_write(PCCNT, val);
138 142
139 return count; 143 return count;
@@ -152,11 +156,11 @@ static ssize_t store_pcenable(struct device *dev,
152 size_t count) 156 size_t count)
153{ 157{
154 unsigned long pccr, val; 158 unsigned long pccr, val;
155 char *endp; 159 int ret;
156 160
157 val = simple_strtoul(buf, &endp, 0); 161 ret = kstrtoul(buf, 0, &val);
158 if (endp == buf) 162 if (ret)
159 return -EINVAL; 163 return ret;
160 if (val) 164 if (val)
161 val = 1; 165 val = 1;
162 166