diff options
author | Namhyung Kim <namhyung@gmail.com> | 2010-10-27 18:33:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 21:03:10 -0400 |
commit | 81d3285c96dd90044ffe2c2c5d56405a5423d753 (patch) | |
tree | 4b592e4d2f4d51b3a89a95d77bebb0fbc77133ab /arch/frv | |
parent | 475a4b813816fe9af4cdf7833799036b679f46d0 (diff) |
ptrace: cleanup arch_ptrace() on frv
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>
Cc: David Howells <dhowells@redhat.com>
Cc: "Daniel K." <dk@uw.no>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/frv')
-rw-r--r-- | arch/frv/kernel/ptrace.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/arch/frv/kernel/ptrace.c b/arch/frv/kernel/ptrace.c index e9dbfad93589..9d68f7fac730 100644 --- a/arch/frv/kernel/ptrace.c +++ b/arch/frv/kernel/ptrace.c | |||
@@ -259,19 +259,21 @@ long arch_ptrace(struct task_struct *child, long request, | |||
259 | { | 259 | { |
260 | unsigned long tmp; | 260 | unsigned long tmp; |
261 | int ret; | 261 | int ret; |
262 | int regno = addr >> 2; | ||
263 | unsigned long __user *datap = (unsigned long __user *) data; | ||
262 | 264 | ||
263 | switch (request) { | 265 | switch (request) { |
264 | /* read the word at location addr in the USER area. */ | 266 | /* read the word at location addr in the USER area. */ |
265 | case PTRACE_PEEKUSR: { | 267 | case PTRACE_PEEKUSR: { |
266 | tmp = 0; | 268 | tmp = 0; |
267 | ret = -EIO; | 269 | ret = -EIO; |
268 | if ((addr & 3) || addr < 0) | 270 | if (addr & 3) |
269 | break; | 271 | break; |
270 | 272 | ||
271 | ret = 0; | 273 | ret = 0; |
272 | switch (addr >> 2) { | 274 | switch (regno) { |
273 | case 0 ... PT__END - 1: | 275 | case 0 ... PT__END - 1: |
274 | tmp = get_reg(child, addr >> 2); | 276 | tmp = get_reg(child, regno); |
275 | break; | 277 | break; |
276 | 278 | ||
277 | case PT__END + 0: | 279 | case PT__END + 0: |
@@ -300,23 +302,18 @@ long arch_ptrace(struct task_struct *child, long request, | |||
300 | } | 302 | } |
301 | 303 | ||
302 | if (ret == 0) | 304 | if (ret == 0) |
303 | ret = put_user(tmp, (unsigned long *) data); | 305 | ret = put_user(tmp, datap); |
304 | break; | 306 | break; |
305 | } | 307 | } |
306 | 308 | ||
307 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ | 309 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ |
308 | ret = -EIO; | 310 | ret = -EIO; |
309 | if ((addr & 3) || addr < 0) | 311 | if (addr & 3) |
310 | break; | 312 | break; |
311 | 313 | ||
312 | ret = 0; | 314 | switch (regno) { |
313 | switch (addr >> 2) { | ||
314 | case 0 ... PT__END - 1: | 315 | case 0 ... PT__END - 1: |
315 | ret = put_reg(child, addr >> 2, data); | 316 | ret = put_reg(child, regno, data); |
316 | break; | ||
317 | |||
318 | default: | ||
319 | ret = -EIO; | ||
320 | break; | 317 | break; |
321 | } | 318 | } |
322 | break; | 319 | break; |
@@ -325,25 +322,25 @@ long arch_ptrace(struct task_struct *child, long request, | |||
325 | return copy_regset_to_user(child, &user_frv_native_view, | 322 | return copy_regset_to_user(child, &user_frv_native_view, |
326 | REGSET_GENERAL, | 323 | REGSET_GENERAL, |
327 | 0, sizeof(child->thread.user->i), | 324 | 0, sizeof(child->thread.user->i), |
328 | (void __user *)data); | 325 | datap); |
329 | 326 | ||
330 | case PTRACE_SETREGS: /* Set all integer regs in the child. */ | 327 | case PTRACE_SETREGS: /* Set all integer regs in the child. */ |
331 | return copy_regset_from_user(child, &user_frv_native_view, | 328 | return copy_regset_from_user(child, &user_frv_native_view, |
332 | REGSET_GENERAL, | 329 | REGSET_GENERAL, |
333 | 0, sizeof(child->thread.user->i), | 330 | 0, sizeof(child->thread.user->i), |
334 | (const void __user *)data); | 331 | datap); |
335 | 332 | ||
336 | case PTRACE_GETFPREGS: /* Get the child FP/Media state. */ | 333 | case PTRACE_GETFPREGS: /* Get the child FP/Media state. */ |
337 | return copy_regset_to_user(child, &user_frv_native_view, | 334 | return copy_regset_to_user(child, &user_frv_native_view, |
338 | REGSET_FPMEDIA, | 335 | REGSET_FPMEDIA, |
339 | 0, sizeof(child->thread.user->f), | 336 | 0, sizeof(child->thread.user->f), |
340 | (void __user *)data); | 337 | datap); |
341 | 338 | ||
342 | case PTRACE_SETFPREGS: /* Set the child FP/Media state. */ | 339 | case PTRACE_SETFPREGS: /* Set the child FP/Media state. */ |
343 | return copy_regset_from_user(child, &user_frv_native_view, | 340 | return copy_regset_from_user(child, &user_frv_native_view, |
344 | REGSET_FPMEDIA, | 341 | REGSET_FPMEDIA, |
345 | 0, sizeof(child->thread.user->f), | 342 | 0, sizeof(child->thread.user->f), |
346 | (const void __user *)data); | 343 | datap); |
347 | 344 | ||
348 | default: | 345 | default: |
349 | ret = ptrace_request(child, request, addr, data); | 346 | ret = ptrace_request(child, request, addr, data); |