aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-09-22 18:18:23 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-01 00:54:29 -0400
commit61b7fbc3f4ebdcfd34f9438adfab8df936a19e33 (patch)
tree95d590708d5f156f11ed891f9a88b296a2b89f22
parent6e75421014cd02cc66298d35c4667e493da78914 (diff)
mn10300: convert to generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/mn10300/Kconfig1
-rw-r--r--arch/mn10300/include/asm/processor.h5
-rw-r--r--arch/mn10300/kernel/process.c49
3 files changed, 19 insertions, 36 deletions
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 5cfb086b3903..ddbdc33471a8 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -8,6 +8,7 @@ config MN10300
8 select HAVE_ARCH_KGDB 8 select HAVE_ARCH_KGDB
9 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER 9 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER
10 select GENERIC_CLOCKEVENTS 10 select GENERIC_CLOCKEVENTS
11 select GENERIC_KERNEL_THREAD
11 12
12config AM33_2 13config AM33_2
13 def_bool n 14 def_bool n
diff --git a/arch/mn10300/include/asm/processor.h b/arch/mn10300/include/asm/processor.h
index 0b844a254067..8b80b19d0c8a 100644
--- a/arch/mn10300/include/asm/processor.h
+++ b/arch/mn10300/include/asm/processor.h
@@ -133,11 +133,6 @@ static inline void start_thread(struct pt_regs *regs,
133extern void release_thread(struct task_struct *); 133extern void release_thread(struct task_struct *);
134 134
135/* 135/*
136 * create a kernel thread without removing it from tasklists
137 */
138extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
139
140/*
141 * Return saved PC of a blocked thread. 136 * Return saved PC of a blocked thread.
142 */ 137 */
143extern unsigned long thread_saved_pc(struct task_struct *tsk); 138extern unsigned long thread_saved_pc(struct task_struct *tsk);
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c
index 49af5ca89343..8ee09d828c43 100644
--- a/arch/mn10300/kernel/process.c
+++ b/arch/mn10300/kernel/process.c
@@ -162,24 +162,6 @@ void show_regs(struct pt_regs *regs)
162} 162}
163 163
164/* 164/*
165 * create a kernel thread
166 */
167int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
168{
169 struct pt_regs regs = {
170 .a0 = (unsigned long) fn;
171 .d0 = (unsigned long) arg;
172 };
173
174 local_save_flags(regs.epsw);
175 regs.epsw |= EPSW_IE | EPSW_IM_7;
176
177 /* Ok, create the new process.. */
178 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0,
179 NULL, NULL);
180}
181
182/*
183 * free current thread data structures etc.. 165 * free current thread data structures etc..
184 */ 166 */
185void exit_thread(void) 167void exit_thread(void)
@@ -232,29 +214,34 @@ int copy_thread(unsigned long clone_flags,
232 /* allocate the userspace exception frame and set it up */ 214 /* allocate the userspace exception frame and set it up */
233 c_ksp -= sizeof(struct pt_regs); 215 c_ksp -= sizeof(struct pt_regs);
234 c_regs = (struct pt_regs *) c_ksp; 216 c_regs = (struct pt_regs *) c_ksp;
217 c_ksp -= 12; /* allocate function call ABI slack */
235 218
219 /* set up things up so the scheduler can start the new task */
236 p->thread.uregs = c_regs; 220 p->thread.uregs = c_regs;
221 ti->frame = c_regs;
222 p->thread.a3 = (unsigned long) c_regs;
223 p->thread.sp = c_ksp;
224 p->thread.wchan = p->thread.pc;
225 p->thread.usp = c_usp;
226
227 if (unlikely(!kregs)) {
228 memset(c_regs, 0, sizeof(struct pt_regs));
229 c_regs->a0 = c_usp; /* function */
230 c_regs->d0 = ustk_size; /* argument */
231 local_save_flags(c_regs->epsw);
232 c_regs->epsw |= EPSW_IE | EPSW_IM_7;
233 p->thread.pc = (unsigned long) ret_from_kernel_thread;
234 return 0;
235 }
237 *c_regs = *kregs; 236 *c_regs = *kregs;
238 c_regs->sp = c_usp; 237 c_regs->sp = c_usp;
239 c_regs->epsw &= ~EPSW_FE; /* my FPU */ 238 c_regs->epsw &= ~EPSW_FE; /* my FPU */
240 239
241 c_ksp -= 12; /* allocate function call ABI slack */
242
243 /* the new TLS pointer is passed in as arg #5 to sys_clone() */ 240 /* the new TLS pointer is passed in as arg #5 to sys_clone() */
244 if (clone_flags & CLONE_SETTLS) 241 if (clone_flags & CLONE_SETTLS)
245 c_regs->e2 = current_frame()->d3; 242 c_regs->e2 = current_frame()->d3;
246 243
247 if (unlikely(!user_mode(kregs))) 244 p->thread.pc = (unsigned long) ret_from_fork;
248 p->thread.pc = (unsigned long) ret_from_kernel_thread;
249 else
250 p->thread.pc = (unsigned long) ret_from_fork;
251
252 /* set up things up so the scheduler can start the new task */
253 ti->frame = c_regs;
254 p->thread.a3 = (unsigned long) c_regs;
255 p->thread.sp = c_ksp;
256 p->thread.wchan = p->thread.pc;
257 p->thread.usp = c_usp;
258 245
259 return 0; 246 return 0;
260} 247}