aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sbus/char/envctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sbus/char/envctrl.c')
-rw-r--r--drivers/sbus/char/envctrl.c45
1 files changed, 10 insertions, 35 deletions
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 9a8c572554f5..d765cc1bf060 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,
@@ -1041,7 +1039,6 @@ static int kenvctrld(void *__unused)
1041 1039
1042static int __init envctrl_init(void) 1040static int __init envctrl_init(void)
1043{ 1041{
1044#ifdef CONFIG_PCI
1045 struct linux_ebus *ebus = NULL; 1042 struct linux_ebus *ebus = NULL;
1046 struct linux_ebus_device *edev = NULL; 1043 struct linux_ebus_device *edev = NULL;
1047 struct linux_ebus_child *edev_child = NULL; 1044 struct linux_ebus_child *edev_child = NULL;
@@ -1118,9 +1115,11 @@ done:
1118 i2c_childlist[i].addr, (0 == i) ? ("\n") : (" ")); 1115 i2c_childlist[i].addr, (0 == i) ? ("\n") : (" "));
1119 } 1116 }
1120 1117
1121 err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES); 1118 kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld");
1122 if (err < 0) 1119 if (IS_ERR(kenvctrld_task)) {
1120 err = PTR_ERR(kenvctrld_task);
1123 goto out_deregister; 1121 goto out_deregister;
1122 }
1124 1123
1125 return 0; 1124 return 0;
1126 1125
@@ -1133,37 +1132,13 @@ out_iounmap:
1133 kfree(i2c_childlist[i].tables); 1132 kfree(i2c_childlist[i].tables);
1134 } 1133 }
1135 return err; 1134 return err;
1136#else
1137 return -ENODEV;
1138#endif
1139} 1135}
1140 1136
1141static void __exit envctrl_cleanup(void) 1137static void __exit envctrl_cleanup(void)
1142{ 1138{
1143 int i; 1139 int i;
1144 1140
1145 if (NULL != kenvctrld_task) { 1141 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 1142
1168 iounmap(i2c); 1143 iounmap(i2c);
1169 misc_deregister(&envctrl_dev); 1144 misc_deregister(&envctrl_dev);