diff options
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 9a8c572554f5..e103b12f9efe 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/config.h> | 24 | #include <linux/config.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/sched.h> | 26 | #include <linux/sched.h> |
27 | #include <linux/kthread.h> | ||
27 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
28 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
29 | #include <linux/ioport.h> | 30 | #include <linux/ioport.h> |
@@ -1010,16 +1011,13 @@ static int kenvctrld(void *__unused) | |||
1010 | 1011 | ||
1011 | poll_interval = 5000; /* TODO env_mon_interval */ | 1012 | poll_interval = 5000; /* TODO env_mon_interval */ |
1012 | 1013 | ||
1013 | daemonize("kenvctrld"); | ||
1014 | allow_signal(SIGKILL); | ||
1015 | |||
1016 | kenvctrld_task = current; | ||
1017 | |||
1018 | printk(KERN_INFO "envctrl: %s starting...\n", current->comm); | 1014 | printk(KERN_INFO "envctrl: %s starting...\n", current->comm); |
1019 | for (;;) { | 1015 | for (;;) { |
1020 | if(msleep_interruptible(poll_interval)) | 1016 | msleep_interruptible(poll_interval); |
1021 | break; | ||
1022 | 1017 | ||
1018 | if (kthread_should_stop()) | ||
1019 | break; | ||
1020 | |||
1023 | for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { | 1021 | for (whichcpu = 0; whichcpu < ENVCTRL_MAX_CPU; ++whichcpu) { |
1024 | if (0 < envctrl_read_cpu_info(whichcpu, cputemp, | 1022 | if (0 < envctrl_read_cpu_info(whichcpu, cputemp, |
1025 | ENVCTRL_CPUTEMP_MON, | 1023 | ENVCTRL_CPUTEMP_MON, |
@@ -1118,9 +1116,11 @@ done: | |||
1118 | i2c_childlist[i].addr, (0 == i) ? ("\n") : (" ")); | 1116 | i2c_childlist[i].addr, (0 == i) ? ("\n") : (" ")); |
1119 | } | 1117 | } |
1120 | 1118 | ||
1121 | err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES); | 1119 | kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld"); |
1122 | if (err < 0) | 1120 | if (IS_ERR(kenvctrld_task)) { |
1121 | err = ERR_PTR(kenvctrld_task); | ||
1123 | goto out_deregister; | 1122 | goto out_deregister; |
1123 | } | ||
1124 | 1124 | ||
1125 | return 0; | 1125 | return 0; |
1126 | 1126 | ||
@@ -1142,28 +1142,7 @@ static void __exit envctrl_cleanup(void) | |||
1142 | { | 1142 | { |
1143 | int i; | 1143 | int i; |
1144 | 1144 | ||
1145 | if (NULL != kenvctrld_task) { | 1145 | kthread_stop(kenvctrld_task); |
1146 | force_sig(SIGKILL, kenvctrld_task); | ||
1147 | for (;;) { | ||
1148 | struct task_struct *p; | ||
1149 | int found = 0; | ||
1150 | |||
1151 | read_lock(&tasklist_lock); | ||
1152 | for_each_process(p) { | ||
1153 | if (p == kenvctrld_task) { | ||
1154 | found = 1; | ||
1155 | break; | ||
1156 | } | ||
1157 | } | ||
1158 | read_unlock(&tasklist_lock); | ||
1159 | |||
1160 | if (!found) | ||
1161 | break; | ||
1162 | |||
1163 | msleep(1000); | ||
1164 | } | ||
1165 | kenvctrld_task = NULL; | ||
1166 | } | ||
1167 | 1146 | ||
1168 | iounmap(i2c); | 1147 | iounmap(i2c); |
1169 | misc_deregister(&envctrl_dev); | 1148 | misc_deregister(&envctrl_dev); |