]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/staging/unisys/uislib/uisthread.c
3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT. See the GNU General Public License for more
19 #include <asm/processor.h>
20 #include <linux/signal.h>
21 #include <linux/sched.h>
22 #include <linux/kthread.h>
24 #include "uisthread.h"
26 /* this is shorter than using __FILE__ (full path name) in
27 * debug/info/error messages
29 #define CURRENT_FILE_PC UISLIB_PC_uisthread_c
30 #define __MYFILE__ "uisthread.c"
32 /*****************************************************/
33 /* Exported functions */
34 /*****************************************************/
36 /* returns 0 for failure, 1 for success */
38 uisthread_start(struct uisthread_info
*thrinfo
,
39 int (*threadfn
)(void *), void *thrcontext
, char *name
)
41 /* used to stop the thread */
42 init_completion(&thrinfo
->has_stopped
);
43 thrinfo
->task
= kthread_run(threadfn
, thrcontext
, name
);
44 if (IS_ERR(thrinfo
->task
)) {
46 return 0; /* failure */
48 thrinfo
->id
= thrinfo
->task
->pid
;
51 EXPORT_SYMBOL_GPL(uisthread_start
);
54 uisthread_stop(struct uisthread_info
*thrinfo
)
59 return; /* thread not running */
61 kthread_stop(thrinfo
->task
);
62 /* give up if the thread has NOT died in 1 minute */
63 if (wait_for_completion_timeout(&thrinfo
->has_stopped
, 60 * HZ
))
69 EXPORT_SYMBOL_GPL(uisthread_stop
);