diff options
author | Christoph Hellwig <hch@lst.de> | 2005-08-09 16:32:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-08-09 16:32:25 -0400 |
commit | bc2406684b5929cea5d40b9cc4fd872816956779 (patch) | |
tree | e7e9f356f14b5353f8b07273948beb1eef0ec8f9 | |
parent | 218b29e0c3995ee15782de55ad1dd74cce1a728d (diff) |
[SPARC]: Use kthread infrastructure in bbc_envctrl
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/sbus/char/bbc_envctrl.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c index b8a2c7353b0a..d44205d52bf3 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 | ||
460 | static int kenvctrld(void *__unused) | 461 | static 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 | ||
593 | static void destroy_one_temp(struct bbc_cpu_temperature *tp) | 593 | static 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) { |