diff options
author | Christoph Hellwig <hch@lst.de> | 2005-08-09 12:30:07 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-08-09 12:30:07 -0700 |
commit | 218b29e0c3995ee15782de55ad1dd74cce1a728d (patch) | |
tree | e734f30f6123ae2b4e3ba545e9017d6d0498b3e7 /drivers/sbus/char | |
parent | 00dd1e433967872f3997a45d5adf35056fdf2f56 (diff) |
[SPARC]: Use kthread infrastructure in envctrl
envctrl currently uses very odd ways to stop a thread, using various
things that should be exposed to drivers at all.
This patch (which is untested as I don't have sparc hardware) switches
it to use the proper kthread infrastructure.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/sbus/char')
-rw-r--r-- | drivers/sbus/char/envctrl.c | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index 9a8c572554f..e103b12f9ef 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c @@ -24,6 +24,7 @@ #include <linux/config.h> #include <linux/module.h> #include <linux/sched.h> +#include <linux/kthread.h> #include <linux/errno.h> #include <linux/delay.h> #include <linux/ioport.h> @@ -1010,16 +1011,13 @@ static int kenvctrld(void *__unused) poll_interval = 5000; /* TODO env_mon_interval */ - daemonize("kenvctrld"); - allow_signal(SIGKILL); - - kenvctrld_task = current; - printk(KERN_INFO "envctrl: %s starting...\n", current->comm); for (;;) { - if(msleep_interruptible(poll_interval)) - break; + msleep_interruptible(poll_interval); + if (kthread_should_stop()) + break; + for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { if (0 < envctrl_read_cpu_info(whichcpu, cputemp, ENVCTRL_CPUTEMP_MON, @@ -1118,9 +1116,11 @@ done: i2c_childlist[i].addr, (0 == i) ? ("\n") : (" ")); } - err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES); - if (err < 0) + kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld"); + if (IS_ERR(kenvctrld_task)) { + err = ERR_PTR(kenvctrld_task); goto out_deregister; + } return 0; @@ -1142,28 +1142,7 @@ static void __exit envctrl_cleanup(void) { int i; - if (NULL != kenvctrld_task) { - force_sig(SIGKILL, kenvctrld_task); - for (;;) { - struct task_struct *p; - int found = 0; - - read_lock(&tasklist_lock); - for_each_process(p) { - if (p == kenvctrld_task) { - found = 1; - break; - } - } - read_unlock(&tasklist_lock); - - if (!found) - break; - - msleep(1000); - } - kenvctrld_task = NULL; - } + kthread_stop(kenvctrld_task); iounmap(i2c); misc_deregister(&envctrl_dev); |