aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/sbus/char/bbc_envctrl.c39
-rw-r--r--drivers/sbus/char/envctrl.c45
2 files changed, 20 insertions, 64 deletions
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index b8a2c7353b0..d44205d52bf 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -7,6 +7,7 @@
7#define __KERNEL_SYSCALLS__ 7#define __KERNEL_SYSCALLS__
8 8
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/kthread.h>
10#include <linux/sched.h> 11#include <linux/sched.h>
11#include <linux/slab.h> 12#include <linux/slab.h>
12#include <linux/delay.h> 13#include <linux/delay.h>
@@ -459,10 +460,6 @@ static struct task_struct *kenvctrld_task;
459 460
460static int kenvctrld(void *__unused) 461static int kenvctrld(void *__unused)
461{ 462{
462 daemonize("kenvctrld");
463 allow_signal(SIGKILL);
464 kenvctrld_task = current;
465
466 printk(KERN_INFO "bbc_envctrl: kenvctrld starting...\n"); 463 printk(KERN_INFO "bbc_envctrl: kenvctrld starting...\n");
467 last_warning_jiffies = jiffies - WARN_INTERVAL; 464 last_warning_jiffies = jiffies - WARN_INTERVAL;
468 for (;;) { 465 for (;;) {
@@ -470,7 +467,7 @@ static int kenvctrld(void *__unused)
470 struct bbc_fan_control *fp; 467 struct bbc_fan_control *fp;
471 468
472 msleep_interruptible(POLL_INTERVAL); 469 msleep_interruptible(POLL_INTERVAL);
473 if (signal_pending(current)) 470 if (kthread_should_stop())
474 break; 471 break;
475 472
476 for (tp = all_bbc_temps; tp; tp = tp->next) { 473 for (tp = all_bbc_temps; tp; tp = tp->next) {
@@ -577,7 +574,6 @@ int bbc_envctrl_init(void)
577 int temp_index = 0; 574 int temp_index = 0;
578 int fan_index = 0; 575 int fan_index = 0;
579 int devidx = 0; 576 int devidx = 0;
580 int err = 0;
581 577
582 while ((echild = bbc_i2c_getdev(devidx++)) != NULL) { 578 while ((echild = bbc_i2c_getdev(devidx++)) != NULL) {
583 if (!strcmp(echild->prom_name, "temperature")) 579 if (!strcmp(echild->prom_name, "temperature"))
@@ -585,9 +581,13 @@ int bbc_envctrl_init(void)
585 if (!strcmp(echild->prom_name, "fan-control")) 581 if (!strcmp(echild->prom_name, "fan-control"))
586 attach_one_fan(echild, fan_index++); 582 attach_one_fan(echild, fan_index++);
587 } 583 }
588 if (temp_index != 0 && fan_index != 0) 584 if (temp_index != 0 && fan_index != 0) {
589 err = kernel_thread(kenvctrld, NULL, CLONE_FS | CLONE_FILES); 585 kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld");
590 return err; 586 if (IS_ERR(kenvctrld_task))
587 return PTR_ERR(kenvctrld_task);
588 }
589
590 return 0;
591} 591}
592 592
593static void destroy_one_temp(struct bbc_cpu_temperature *tp) 593static void destroy_one_temp(struct bbc_cpu_temperature *tp)
@@ -607,26 +607,7 @@ void bbc_envctrl_cleanup(void)
607 struct bbc_cpu_temperature *tp; 607 struct bbc_cpu_temperature *tp;
608 struct bbc_fan_control *fp; 608 struct bbc_fan_control *fp;
609 609
610 if (kenvctrld_task != NULL) { 610 kthread_stop(kenvctrld_task);
611 force_sig(SIGKILL, kenvctrld_task);
612 for (;;) {
613 struct task_struct *p;
614 int found = 0;
615
616 read_lock(&tasklist_lock);
617 for_each_process(p) {
618 if (p == kenvctrld_task) {
619 found = 1;
620 break;
621 }
622 }
623 read_unlock(&tasklist_lock);
624 if (!found)
625 break;
626 msleep(1000);
627 }
628 kenvctrld_task = NULL;
629 }
630 611
631 tp = all_bbc_temps; 612 tp = all_bbc_temps;
632 while (tp != NULL) { 613 while (tp != NULL) {
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 9a8c572554f..d765cc1bf06 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);