aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68knommu/kernel/ptrace.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2010-10-27 18:33:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 21:03:11 -0400
commitbf60ef96072ebbf768bae1f9ab421ceef5b80676 (patch)
tree7e79fea972e43fff60a84645d74eaedfb3e0c83c /arch/m68knommu/kernel/ptrace.c
parentadd3d6e8b1372646f3cb8cb56d5840c91afc85e0 (diff)
ptrace: cleanup arch_ptrace() on m68knommu
Use new 'regno', 'datap' variables in order to remove duplicated expressions and unnecessary castings. Alse remove checking @addr less than 0 because addr is now unsigned. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Acked-by: Greg Ungerer <gerg@uclinux.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m68knommu/kernel/ptrace.c')
-rw-r--r--arch/m68knommu/kernel/ptrace.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/arch/m68knommu/kernel/ptrace.c b/arch/m68knommu/kernel/ptrace.c
index 7dbb08f5534e..6709fb707335 100644
--- a/arch/m68knommu/kernel/ptrace.c
+++ b/arch/m68knommu/kernel/ptrace.c
@@ -116,6 +116,8 @@ long arch_ptrace(struct task_struct *child, long request,
116 unsigned long addr, unsigned long data) 116 unsigned long addr, unsigned long data)
117{ 117{
118 int ret; 118 int ret;
119 int regno = addr >> 2;
120 unsigned long __user *datap = (unsigned long __user *) data;
119 121
120 switch (request) { 122 switch (request) {
121 /* read the word at location addr in the USER area. */ 123 /* read the word at location addr in the USER area. */
@@ -123,53 +125,48 @@ long arch_ptrace(struct task_struct *child, long request,
123 unsigned long tmp; 125 unsigned long tmp;
124 126
125 ret = -EIO; 127 ret = -EIO;
126 if ((addr & 3) || addr < 0 || 128 if ((addr & 3) || addr > sizeof(struct user) - 3)
127 addr > sizeof(struct user) - 3)
128 break; 129 break;
129 130
130 tmp = 0; /* Default return condition */ 131 tmp = 0; /* Default return condition */
131 addr = addr >> 2; /* temporary hack. */
132 ret = -EIO; 132 ret = -EIO;
133 if (addr < 19) { 133 if (regno < 19) {
134 tmp = get_reg(child, addr); 134 tmp = get_reg(child, regno);
135 if (addr == PT_SR) 135 if (regno == PT_SR)
136 tmp >>= 16; 136 tmp >>= 16;
137 } else if (addr >= 21 && addr < 49) { 137 } else if (regno >= 21 && regno < 49) {
138 tmp = child->thread.fp[addr - 21]; 138 tmp = child->thread.fp[regno - 21];
139 } else if (addr == 49) { 139 } else if (regno == 49) {
140 tmp = child->mm->start_code; 140 tmp = child->mm->start_code;
141 } else if (addr == 50) { 141 } else if (regno == 50) {
142 tmp = child->mm->start_data; 142 tmp = child->mm->start_data;
143 } else if (addr == 51) { 143 } else if (regno == 51) {
144 tmp = child->mm->end_code; 144 tmp = child->mm->end_code;
145 } else 145 } else
146 break; 146 break;
147 ret = put_user(tmp,(unsigned long *) data); 147 ret = put_user(tmp, datap);
148 break; 148 break;
149 } 149 }
150 150
151 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 151 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
152 ret = -EIO; 152 ret = -EIO;
153 if ((addr & 3) || addr < 0 || 153 if ((addr & 3) || addr > sizeof(struct user) - 3)
154 addr > sizeof(struct user) - 3)
155 break; 154 break;
156 155
157 addr = addr >> 2; /* temporary hack. */ 156 if (regno == PT_SR) {
158
159 if (addr == PT_SR) {
160 data &= SR_MASK; 157 data &= SR_MASK;
161 data <<= 16; 158 data <<= 16;
162 data |= get_reg(child, PT_SR) & ~(SR_MASK << 16); 159 data |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
163 } 160 }
164 if (addr < 19) { 161 if (regno < 19) {
165 if (put_reg(child, addr, data)) 162 if (put_reg(child, regno, data))
166 break; 163 break;
167 ret = 0; 164 ret = 0;
168 break; 165 break;
169 } 166 }
170 if (addr >= 21 && addr < 48) 167 if (regno >= 21 && regno < 48)
171 { 168 {
172 child->thread.fp[addr - 21] = data; 169 child->thread.fp[regno - 21] = data;
173 ret = 0; 170 ret = 0;
174 } 171 }
175 break; 172 break;
@@ -181,11 +178,11 @@ long arch_ptrace(struct task_struct *child, long request,
181 tmp = get_reg(child, i); 178 tmp = get_reg(child, i);
182 if (i == PT_SR) 179 if (i == PT_SR)
183 tmp >>= 16; 180 tmp >>= 16;
184 if (put_user(tmp, (unsigned long *) data)) { 181 if (put_user(tmp, datap)) {
185 ret = -EFAULT; 182 ret = -EFAULT;
186 break; 183 break;
187 } 184 }
188 data += sizeof(unsigned long); 185 datap++;
189 } 186 }
190 ret = 0; 187 ret = 0;
191 break; 188 break;
@@ -195,7 +192,7 @@ long arch_ptrace(struct task_struct *child, long request,
195 int i; 192 int i;
196 unsigned long tmp; 193 unsigned long tmp;
197 for (i = 0; i < 19; i++) { 194 for (i = 0; i < 19; i++) {
198 if (get_user(tmp, (unsigned long *) data)) { 195 if (get_user(tmp, datap)) {
199 ret = -EFAULT; 196 ret = -EFAULT;
200 break; 197 break;
201 } 198 }
@@ -205,7 +202,7 @@ long arch_ptrace(struct task_struct *child, long request,
205 tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16); 202 tmp |= get_reg(child, PT_SR) & ~(SR_MASK << 16);
206 } 203 }
207 put_reg(child, i, tmp); 204 put_reg(child, i, tmp);
208 data += sizeof(unsigned long); 205 datap++;
209 } 206 }
210 ret = 0; 207 ret = 0;
211 break; 208 break;
@@ -214,7 +211,7 @@ long arch_ptrace(struct task_struct *child, long request,
214#ifdef PTRACE_GETFPREGS 211#ifdef PTRACE_GETFPREGS
215 case PTRACE_GETFPREGS: { /* Get the child FPU state. */ 212 case PTRACE_GETFPREGS: { /* Get the child FPU state. */
216 ret = 0; 213 ret = 0;
217 if (copy_to_user((void *)data, &child->thread.fp, 214 if (copy_to_user(datap, &child->thread.fp,
218 sizeof(struct user_m68kfp_struct))) 215 sizeof(struct user_m68kfp_struct)))
219 ret = -EFAULT; 216 ret = -EFAULT;
220 break; 217 break;
@@ -224,7 +221,7 @@ long arch_ptrace(struct task_struct *child, long request,
224#ifdef PTRACE_SETFPREGS 221#ifdef PTRACE_SETFPREGS
225 case PTRACE_SETFPREGS: { /* Set the child FPU state. */ 222 case PTRACE_SETFPREGS: { /* Set the child FPU state. */
226 ret = 0; 223 ret = 0;
227 if (copy_from_user(&child->thread.fp, (void *)data, 224 if (copy_from_user(&child->thread.fp, datap,
228 sizeof(struct user_m68kfp_struct))) 225 sizeof(struct user_m68kfp_struct)))
229 ret = -EFAULT; 226 ret = -EFAULT;
230 break; 227 break;
@@ -232,8 +229,7 @@ long arch_ptrace(struct task_struct *child, long request,
232#endif 229#endif
233 230
234 case PTRACE_GET_THREAD_AREA: 231 case PTRACE_GET_THREAD_AREA:
235 ret = put_user(task_thread_info(child)->tp_value, 232 ret = put_user(task_thread_info(child)->tp_value, datap);
236 (unsigned long __user *)data);
237 break; 233 break;
238 234
239 default: 235 default: