summaryrefslogtreecommitdiffstats
path: root/arch/c6x/kernel/process.c
diff options
context:
space:
mode:
authorMark Salter <msalter@redhat.com>2012-09-21 18:26:37 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-01 06:59:08 +0200
commit46f15067c020a0ce712cb2d3ef38c0589a521c15 (patch)
treef980e4faf9dccc1be052fdbbb1dbd785c6238cc6 /arch/c6x/kernel/process.c
parentmn10300: convert to generic kernel_thread() (diff)
downloadlinux-46f15067c020a0ce712cb2d3ef38c0589a521c15.tar.xz
linux-46f15067c020a0ce712cb2d3ef38c0589a521c15.zip
c6x: add ret_from_kernel_thread(), simplify kernel_thread()
Signed-off-by: Mark Salter <msalter@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/c6x/kernel/process.c')
-rw-r--r--arch/c6x/kernel/process.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c
index 45e924a636a0..d2ffc9bdaba1 100644
--- a/arch/c6x/kernel/process.c
+++ b/arch/c6x/kernel/process.c
@@ -25,6 +25,7 @@ void (*c6x_restart)(void);
void (*c6x_halt)(void);
extern asmlinkage void ret_from_fork(void);
+extern asmlinkage void ret_from_kernel_thread(void);
/*
* power off function, if any
@@ -103,36 +104,21 @@ void machine_power_off(void)
halt_loop();
}
-static void kernel_thread_helper(int dummy, void *arg, int (*fn)(void *))
-{
- do_exit(fn(arg));
-}
-
/*
* Create a kernel thread
*/
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
- struct pt_regs regs;
-
- /*
- * copy_thread sets a4 to zero (child return from fork)
- * so we can't just set things up to directly return to
- * fn.
- */
- memset(&regs, 0, sizeof(regs));
- regs.b4 = (unsigned long) arg;
- regs.a6 = (unsigned long) fn;
- regs.pc = (unsigned long) kernel_thread_helper;
- local_save_flags(regs.csr);
- regs.csr |= 1;
- regs.tsr = 5; /* Set GEE and GIE in TSR */
+ struct pt_regs regs = {
+ .a0 = (unsigned long)fn,
+ .a1 = (unsigned long)arg,
+ .tsr = 0, /* kernel mode */
+ };
/* Ok, create the new process.. */
return do_fork(flags | CLONE_VM | CLONE_UNTRACED, -1, &regs,
0, NULL, NULL);
}
-EXPORT_SYMBOL(kernel_thread);
void flush_thread(void)
{
@@ -192,21 +178,21 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
childregs = task_pt_regs(p);
*childregs = *regs;
- childregs->a4 = 0;
- if (usp == -1)
+ if (usp == -1) {
/* case of __kernel_thread: we return to supervisor space */
childregs->sp = (unsigned long)(childregs + 1);
- else
+ p->thread.pc = (unsigned long) ret_from_kernel_thread;
+ } else {
/* Otherwise use the given stack */
childregs->sp = usp;
+ p->thread.pc = (unsigned long) ret_from_fork;
+ }
/* Set usp/ksp */
p->thread.usp = childregs->sp;
- /* switch_to uses stack to save/restore 14 callee-saved regs */
thread_saved_ksp(p) = (unsigned long)childregs - 8;
- p->thread.pc = (unsigned int) ret_from_fork;
- p->thread.wchan = (unsigned long) ret_from_fork;
+ p->thread.wchan = p->thread.pc;
#ifdef __DSBT__
{
unsigned long dp;