diff options
author | Namhyung Kim <namhyung@gmail.com> | 2010-10-27 18:33:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 21:03:11 -0400 |
commit | add3d6e8b1372646f3cb8cb56d5840c91afc85e0 (patch) | |
tree | d771f5eda7afa5c7f5485c2e8f7e721c13f6a8cc /arch/m68k | |
parent | a68caa035a0ffb895baa829edec0545f17d88c07 (diff) |
ptrace: cleanup arch_ptrace() on m68k
Use new 'regno', 'datap' variables in order to remove duplicated
expressions and unnecessary castings.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r-- | arch/m68k/kernel/ptrace.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/arch/m68k/kernel/ptrace.c b/arch/m68k/kernel/ptrace.c index 583f59fcc363..0b252683cefb 100644 --- a/arch/m68k/kernel/ptrace.c +++ b/arch/m68k/kernel/ptrace.c | |||
@@ -161,51 +161,52 @@ long arch_ptrace(struct task_struct *child, long request, | |||
161 | { | 161 | { |
162 | unsigned long tmp; | 162 | unsigned long tmp; |
163 | int i, ret = 0; | 163 | int i, ret = 0; |
164 | int regno = addr >> 2; /* temporary hack. */ | ||
165 | unsigned long __user *datap = (unsigned long __user *) data; | ||
164 | 166 | ||
165 | switch (request) { | 167 | switch (request) { |
166 | /* read the word at location addr in the USER area. */ | 168 | /* read the word at location addr in the USER area. */ |
167 | case PTRACE_PEEKUSR: | 169 | case PTRACE_PEEKUSR: |
168 | if (addr & 3) | 170 | if (addr & 3) |
169 | goto out_eio; | 171 | goto out_eio; |
170 | addr >>= 2; /* temporary hack. */ | ||
171 | 172 | ||
172 | if (addr >= 0 && addr < 19) { | 173 | if (regno >= 0 && regno < 19) { |
173 | tmp = get_reg(child, addr); | 174 | tmp = get_reg(child, regno); |
174 | } else if (addr >= 21 && addr < 49) { | 175 | } else if (regno >= 21 && regno < 49) { |
175 | tmp = child->thread.fp[addr - 21]; | 176 | tmp = child->thread.fp[regno - 21]; |
176 | /* Convert internal fpu reg representation | 177 | /* Convert internal fpu reg representation |
177 | * into long double format | 178 | * into long double format |
178 | */ | 179 | */ |
179 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) | 180 | if (FPU_IS_EMU && (regno < 45) && !(regno % 3)) |
180 | tmp = ((tmp & 0xffff0000) << 15) | | 181 | tmp = ((tmp & 0xffff0000) << 15) | |
181 | ((tmp & 0x0000ffff) << 16); | 182 | ((tmp & 0x0000ffff) << 16); |
182 | } else | 183 | } else |
183 | goto out_eio; | 184 | goto out_eio; |
184 | ret = put_user(tmp, (unsigned long *)data); | 185 | ret = put_user(tmp, datap); |
185 | break; | 186 | break; |
186 | 187 | ||
187 | case PTRACE_POKEUSR: /* write the word at location addr in the USER area */ | 188 | case PTRACE_POKEUSR: |
189 | /* write the word at location addr in the USER area */ | ||
188 | if (addr & 3) | 190 | if (addr & 3) |
189 | goto out_eio; | 191 | goto out_eio; |
190 | addr >>= 2; /* temporary hack. */ | ||
191 | 192 | ||
192 | if (addr == PT_SR) { | 193 | if (regno == PT_SR) { |
193 | data &= SR_MASK; | 194 | data &= SR_MASK; |
194 | data |= get_reg(child, PT_SR) & ~SR_MASK; | 195 | data |= get_reg(child, PT_SR) & ~SR_MASK; |
195 | } | 196 | } |
196 | if (addr >= 0 && addr < 19) { | 197 | if (regno >= 0 && regno < 19) { |
197 | if (put_reg(child, addr, data)) | 198 | if (put_reg(child, regno, data)) |
198 | goto out_eio; | 199 | goto out_eio; |
199 | } else if (addr >= 21 && addr < 48) { | 200 | } else if (regno >= 21 && regno < 48) { |
200 | /* Convert long double format | 201 | /* Convert long double format |
201 | * into internal fpu reg representation | 202 | * into internal fpu reg representation |
202 | */ | 203 | */ |
203 | if (FPU_IS_EMU && (addr < 45) && !(addr % 3)) { | 204 | if (FPU_IS_EMU && (regno < 45) && !(regno % 3)) { |
204 | data <<= 15; | 205 | data <<= 15; |
205 | data = (data & 0xffff0000) | | 206 | data = (data & 0xffff0000) | |
206 | ((data & 0x0000ffff) >> 1); | 207 | ((data & 0x0000ffff) >> 1); |
207 | } | 208 | } |
208 | child->thread.fp[addr - 21] = data; | 209 | child->thread.fp[regno - 21] = data; |
209 | } else | 210 | } else |
210 | goto out_eio; | 211 | goto out_eio; |
211 | break; | 212 | break; |
@@ -213,16 +214,16 @@ long arch_ptrace(struct task_struct *child, long request, | |||
213 | case PTRACE_GETREGS: /* Get all gp regs from the child. */ | 214 | case PTRACE_GETREGS: /* Get all gp regs from the child. */ |
214 | for (i = 0; i < 19; i++) { | 215 | for (i = 0; i < 19; i++) { |
215 | tmp = get_reg(child, i); | 216 | tmp = get_reg(child, i); |
216 | ret = put_user(tmp, (unsigned long *)data); | 217 | ret = put_user(tmp, datap); |
217 | if (ret) | 218 | if (ret) |
218 | break; | 219 | break; |
219 | data += sizeof(unsigned long); | 220 | datap++; |
220 | } | 221 | } |
221 | break; | 222 | break; |
222 | 223 | ||
223 | case PTRACE_SETREGS: /* Set all gp regs in the child. */ | 224 | case PTRACE_SETREGS: /* Set all gp regs in the child. */ |
224 | for (i = 0; i < 19; i++) { | 225 | for (i = 0; i < 19; i++) { |
225 | ret = get_user(tmp, (unsigned long *)data); | 226 | ret = get_user(tmp, datap); |
226 | if (ret) | 227 | if (ret) |
227 | break; | 228 | break; |
228 | if (i == PT_SR) { | 229 | if (i == PT_SR) { |
@@ -230,25 +231,24 @@ long arch_ptrace(struct task_struct *child, long request, | |||
230 | tmp |= get_reg(child, PT_SR) & ~SR_MASK; | 231 | tmp |= get_reg(child, PT_SR) & ~SR_MASK; |
231 | } | 232 | } |
232 | put_reg(child, i, tmp); | 233 | put_reg(child, i, tmp); |
233 | data += sizeof(unsigned long); | 234 | datap++; |
234 | } | 235 | } |
235 | break; | 236 | break; |
236 | 237 | ||
237 | case PTRACE_GETFPREGS: /* Get the child FPU state. */ | 238 | case PTRACE_GETFPREGS: /* Get the child FPU state. */ |
238 | if (copy_to_user((void *)data, &child->thread.fp, | 239 | if (copy_to_user(datap, &child->thread.fp, |
239 | sizeof(struct user_m68kfp_struct))) | 240 | sizeof(struct user_m68kfp_struct))) |
240 | ret = -EFAULT; | 241 | ret = -EFAULT; |
241 | break; | 242 | break; |
242 | 243 | ||
243 | case PTRACE_SETFPREGS: /* Set the child FPU state. */ | 244 | case PTRACE_SETFPREGS: /* Set the child FPU state. */ |
244 | if (copy_from_user(&child->thread.fp, (void *)data, | 245 | if (copy_from_user(&child->thread.fp, datap, |
245 | sizeof(struct user_m68kfp_struct))) | 246 | sizeof(struct user_m68kfp_struct))) |
246 | ret = -EFAULT; | 247 | ret = -EFAULT; |
247 | break; | 248 | break; |
248 | 249 | ||
249 | case PTRACE_GET_THREAD_AREA: | 250 | case PTRACE_GET_THREAD_AREA: |
250 | ret = put_user(task_thread_info(child)->tp_value, | 251 | ret = put_user(task_thread_info(child)->tp_value, datap); |
251 | (unsigned long __user *)data); | ||
252 | break; | 252 | break; |
253 | 253 | ||
254 | default: | 254 | default: |