aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2010-10-27 18:33:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 21:03:11 -0400
commit05fabdace41837a21f957507378b2954fe87ab61 (patch)
tree1bb0e246e7786b008a44779052fa072de0955acf
parent81d3285c96dd90044ffe2c2c5d56405a5423d753 (diff)
ptrace: cleanup arch_ptrace() on h8300
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: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/h8300/kernel/ptrace.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/arch/h8300/kernel/ptrace.c b/arch/h8300/kernel/ptrace.c
index ef1aa0b8b20f..497fa89b5df4 100644
--- a/arch/h8300/kernel/ptrace.c
+++ b/arch/h8300/kernel/ptrace.c
@@ -54,24 +54,25 @@ long arch_ptrace(struct task_struct *child, long request,
54 unsigned long addr, unsigned long data) 54 unsigned long addr, unsigned long data)
55{ 55{
56 int ret; 56 int ret;
57 int regno = addr >> 2;
58 unsigned long __user *datap = (unsigned long __user *) data;
57 59
58 switch (request) { 60 switch (request) {
59 /* read the word at location addr in the USER area. */ 61 /* read the word at location addr in the USER area. */
60 case PTRACE_PEEKUSR: { 62 case PTRACE_PEEKUSR: {
61 unsigned long tmp = 0; 63 unsigned long tmp = 0;
62 64
63 if ((addr & 3) || addr < 0 || addr >= sizeof(struct user)) { 65 if ((addr & 3) || addr >= sizeof(struct user)) {
64 ret = -EIO; 66 ret = -EIO;
65 break ; 67 break ;
66 } 68 }
67 69
68 ret = 0; /* Default return condition */ 70 ret = 0; /* Default return condition */
69 addr = addr >> 2; /* temporary hack. */
70 71
71 if (addr < H8300_REGS_NO) 72 if (regno < H8300_REGS_NO)
72 tmp = h8300_get_reg(child, addr); 73 tmp = h8300_get_reg(child, regno);
73 else { 74 else {
74 switch(addr) { 75 switch (regno) {
75 case 49: 76 case 49:
76 tmp = child->mm->start_code; 77 tmp = child->mm->start_code;
77 break ; 78 break ;
@@ -89,24 +90,23 @@ long arch_ptrace(struct task_struct *child, long request,
89 } 90 }
90 } 91 }
91 if (!ret) 92 if (!ret)
92 ret = put_user(tmp,(unsigned long *) data); 93 ret = put_user(tmp, datap);
93 break ; 94 break ;
94 } 95 }
95 96
96 /* when I and D space are separate, this will have to be fixed. */ 97 /* when I and D space are separate, this will have to be fixed. */
97 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ 98 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
98 if ((addr & 3) || addr < 0 || addr >= sizeof(struct user)) { 99 if ((addr & 3) || addr >= sizeof(struct user)) {
99 ret = -EIO; 100 ret = -EIO;
100 break ; 101 break ;
101 } 102 }
102 addr = addr >> 2; /* temporary hack. */
103 103
104 if (addr == PT_ORIG_ER0) { 104 if (regno == PT_ORIG_ER0) {
105 ret = -EIO; 105 ret = -EIO;
106 break ; 106 break ;
107 } 107 }
108 if (addr < H8300_REGS_NO) { 108 if (regno < H8300_REGS_NO) {
109 ret = h8300_put_reg(child, addr, data); 109 ret = h8300_put_reg(child, regno, data);
110 break ; 110 break ;
111 } 111 }
112 ret = -EIO; 112 ret = -EIO;
@@ -117,11 +117,11 @@ long arch_ptrace(struct task_struct *child, long request,
117 unsigned long tmp; 117 unsigned long tmp;
118 for (i = 0; i < H8300_REGS_NO; i++) { 118 for (i = 0; i < H8300_REGS_NO; i++) {
119 tmp = h8300_get_reg(child, i); 119 tmp = h8300_get_reg(child, i);
120 if (put_user(tmp, (unsigned long *) data)) { 120 if (put_user(tmp, datap)) {
121 ret = -EFAULT; 121 ret = -EFAULT;
122 break; 122 break;
123 } 123 }
124 data += sizeof(unsigned long); 124 datap++;
125 } 125 }
126 ret = 0; 126 ret = 0;
127 break; 127 break;
@@ -131,12 +131,12 @@ long arch_ptrace(struct task_struct *child, long request,
131 int i; 131 int i;
132 unsigned long tmp; 132 unsigned long tmp;
133 for (i = 0; i < H8300_REGS_NO; i++) { 133 for (i = 0; i < H8300_REGS_NO; i++) {
134 if (get_user(tmp, (unsigned long *) data)) { 134 if (get_user(tmp, datap)) {
135 ret = -EFAULT; 135 ret = -EFAULT;
136 break; 136 break;
137 } 137 }
138 h8300_put_reg(child, i, tmp); 138 h8300_put_reg(child, i, tmp);
139 data += sizeof(unsigned long); 139 datap++;
140 } 140 }
141 ret = 0; 141 ret = 0;
142 break; 142 break;