Commit 218b29e0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

[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: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 00dd1e43
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/ioport.h> #include <linux/ioport.h>
...@@ -1010,14 +1011,11 @@ static int kenvctrld(void *__unused) ...@@ -1010,14 +1011,11 @@ static int kenvctrld(void *__unused)
poll_interval = 5000; /* TODO env_mon_interval */ poll_interval = 5000; /* TODO env_mon_interval */
daemonize("kenvctrld");
allow_signal(SIGKILL);
kenvctrld_task = current;
printk(KERN_INFO "envctrl: %s starting...\n", current->comm); printk(KERN_INFO "envctrl: %s starting...\n", current->comm);
for (;;) { for (;;) {
if(msleep_interruptible(poll_interval)) msleep_interruptible(poll_interval);
if (kthread_should_stop())
break; break;
for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) {
...@@ -1118,9 +1116,11 @@ static int __init envctrl_init(void) ...@@ -1118,9 +1116,11 @@ static int __init envctrl_init(void)
i2c_childlist[i].addr, (0 == i) ? ("\n") : (" ")); i2c_childlist[i].addr, (0 == i) ? ("\n") : (" "));
} }
err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES); kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld");
if (err < 0) if (IS_ERR(kenvctrld_task)) {
err = ERR_PTR(kenvctrld_task);
goto out_deregister; goto out_deregister;
}
return 0; return 0;
...@@ -1142,28 +1142,7 @@ static void __exit envctrl_cleanup(void) ...@@ -1142,28 +1142,7 @@ static void __exit envctrl_cleanup(void)
{ {
int i; int i;
if (NULL != kenvctrld_task) { kthread_stop(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;
}
iounmap(i2c); iounmap(i2c);
misc_deregister(&envctrl_dev); misc_deregister(&envctrl_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment