[PATCH] sh: task_pt_regs()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Al Viro and committed by Linus Torvalds 3cf0f4ec 26ecbdea

+18 -48
+6 -36
arch/sh/kernel/process.c
··· 191 191 { 192 192 #if defined(CONFIG_SH_FPU) 193 193 struct task_struct *tsk = current; 194 - struct pt_regs *regs = (struct pt_regs *) 195 - ((unsigned long)tsk->thread_info 196 - + THREAD_SIZE - sizeof(struct pt_regs) 197 - - sizeof(unsigned long)); 198 - 199 194 /* Forget lazy FPU state */ 200 - clear_fpu(tsk, regs); 195 + clear_fpu(tsk, task_pt_regs(tsk)); 201 196 clear_used_math(); 202 197 #endif 203 198 } ··· 227 232 { 228 233 struct pt_regs ptregs; 229 234 230 - ptregs = *(struct pt_regs *) 231 - ((unsigned long)tsk->thread_info + THREAD_SIZE 232 - - sizeof(struct pt_regs) 233 - #ifdef CONFIG_SH_DSP 234 - - sizeof(struct pt_dspregs) 235 - #endif 236 - - sizeof(unsigned long)); 235 + ptregs = *task_pt_regs(tsk); 237 236 elf_core_copy_regs(regs, &ptregs); 238 237 239 238 return 1; ··· 241 252 #if defined(CONFIG_SH_FPU) 242 253 fpvalid = !!tsk_used_math(tsk); 243 254 if (fpvalid) { 244 - struct pt_regs *regs = (struct pt_regs *) 245 - ((unsigned long)tsk->thread_info 246 - + THREAD_SIZE - sizeof(struct pt_regs) 247 - - sizeof(unsigned long)); 248 - unlazy_fpu(tsk, regs); 255 + unlazy_fpu(tsk, task_pt_regs(tsk)); 249 256 memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu)); 250 257 } 251 258 #endif ··· 264 279 copy_to_stopped_child_used_math(p); 265 280 #endif 266 281 267 - childregs = ((struct pt_regs *) 268 - (THREAD_SIZE + (unsigned long) p->thread_info) 269 - #ifdef CONFIG_SH_DSP 270 - - sizeof(struct pt_dspregs) 271 - #endif 272 - - sizeof(unsigned long)) - 1; 282 + childregs = task_pt_regs(p); 273 283 *childregs = *regs; 274 284 275 285 if (user_mode(regs)) { ··· 313 333 struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next) 314 334 { 315 335 #if defined(CONFIG_SH_FPU) 316 - struct pt_regs *regs = (struct pt_regs *) 317 - ((unsigned long)prev->thread_info 318 - + THREAD_SIZE - sizeof(struct pt_regs) 319 - - sizeof(unsigned long)); 320 - unlazy_fpu(prev, regs); 336 + unlazy_fpu(prev, task_pt_regs(prev)); 321 337 #endif 322 338 323 339 #ifdef CONFIG_PREEMPT ··· 322 346 struct pt_regs *regs; 323 347 324 348 local_irq_save(flags); 325 - regs = (struct pt_regs *) 326 - ((unsigned long)prev->thread_info 327 - + THREAD_SIZE - sizeof(struct pt_regs) 328 - #ifdef CONFIG_SH_DSP 329 - - sizeof(struct pt_dspregs) 330 - #endif 331 - - sizeof(unsigned long)); 349 + regs = task_pt_regs(prev); 332 350 if (user_mode(regs) && regs->regs[15] >= 0xc0000000) { 333 351 int offset = (int)regs->regs[15]; 334 352
+2 -12
arch/sh/kernel/ptrace.c
··· 41 41 { 42 42 unsigned char *stack; 43 43 44 - stack = (unsigned char *) 45 - task->thread_info + THREAD_SIZE - sizeof(struct pt_regs) 46 - #ifdef CONFIG_SH_DSP 47 - - sizeof(struct pt_dspregs) 48 - #endif 49 - - sizeof(unsigned long); 44 + stack = (unsigned char *)task_pt_regs(task); 50 45 stack += offset; 51 46 return (*((int *)stack)); 52 47 } ··· 54 59 { 55 60 unsigned char *stack; 56 61 57 - stack = (unsigned char *) 58 - task->thread_info + THREAD_SIZE - sizeof(struct pt_regs) 59 - #ifdef CONFIG_SH_DSP 60 - - sizeof(struct pt_dspregs) 61 - #endif 62 - - sizeof(unsigned long); 62 + stack = (unsigned char *)task_pt_regs(task); 63 63 stack += offset; 64 64 *(unsigned long *) stack = data; 65 65 return 0;
+10
include/asm-sh/ptrace.h
··· 91 91 #define instruction_pointer(regs) ((regs)->pc) 92 92 extern void show_regs(struct pt_regs *); 93 93 94 + #ifdef CONFIG_SH_DSP 95 + #define task_pt_regs(task) \ 96 + ((struct pt_regs *) ((unsigned long)(task)->thread_info + THREAD_SIZE \ 97 + - sizeof(struct pt_dspregs) - sizeof(unsigned long)) - 1) 98 + #else 99 + #define task_pt_regs(task) \ 100 + ((struct pt_regs *) ((unsigned long)(task)->thread_info + THREAD_SIZE \ 101 + - sizeof(unsigned long)) - 1) 102 + #endif 103 + 94 104 static inline unsigned long profile_pc(struct pt_regs *regs) 95 105 { 96 106 unsigned long pc = instruction_pointer(regs);