aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/mach-voyager
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2007-04-22 15:30:43 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2007-05-01 11:09:29 -0400
commitf3402a4e52fc1bdfc386a7f512e6e384cd69ecad (patch)
tree41cc9fb7d6e3040d6b0d69158875f01a335c0144 /arch/i386/mach-voyager
parent9f483519be82420e308b9a90a96a9c62f28032ae (diff)
[VOYAGER] Convert the monitor thread to use the kthread API
full kthread conversion on the voyager power switch handling thread. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'arch/i386/mach-voyager')
-rw-r--r--arch/i386/mach-voyager/voyager_cat.c4
-rw-r--r--arch/i386/mach-voyager/voyager_thread.c69
2 files changed, 23 insertions, 50 deletions
diff --git a/arch/i386/mach-voyager/voyager_cat.c b/arch/i386/mach-voyager/voyager_cat.c
index 943a9473b138..26a2d4c54b68 100644
--- a/arch/i386/mach-voyager/voyager_cat.c
+++ b/arch/i386/mach-voyager/voyager_cat.c
@@ -1111,7 +1111,7 @@ voyager_cat_do_common_interrupt(void)
1111 printk(KERN_ERR "Voyager front panel switch turned off\n"); 1111 printk(KERN_ERR "Voyager front panel switch turned off\n");
1112 voyager_status.switch_off = 1; 1112 voyager_status.switch_off = 1;
1113 voyager_status.request_from_kernel = 1; 1113 voyager_status.request_from_kernel = 1;
1114 up(&kvoyagerd_sem); 1114 wake_up_process(voyager_thread);
1115 } 1115 }
1116 /* Tell the hardware we're taking care of the 1116 /* Tell the hardware we're taking care of the
1117 * shutdown, otherwise it will power the box off 1117 * shutdown, otherwise it will power the box off
@@ -1157,7 +1157,7 @@ voyager_cat_do_common_interrupt(void)
1157 outb(VOYAGER_CAT_END, CAT_CMD); 1157 outb(VOYAGER_CAT_END, CAT_CMD);
1158 voyager_status.power_fail = 1; 1158 voyager_status.power_fail = 1;
1159 voyager_status.request_from_kernel = 1; 1159 voyager_status.request_from_kernel = 1;
1160 up(&kvoyagerd_sem); 1160 wake_up_process(voyager_thread);
1161 } 1161 }
1162 1162
1163 1163
diff --git a/arch/i386/mach-voyager/voyager_thread.c b/arch/i386/mach-voyager/voyager_thread.c
index f39887359e8e..fdc1d926fb2a 100644
--- a/arch/i386/mach-voyager/voyager_thread.c
+++ b/arch/i386/mach-voyager/voyager_thread.c
@@ -24,33 +24,16 @@
24#include <linux/kmod.h> 24#include <linux/kmod.h>
25#include <linux/completion.h> 25#include <linux/completion.h>
26#include <linux/sched.h> 26#include <linux/sched.h>
27#include <linux/kthread.h>
27#include <asm/desc.h> 28#include <asm/desc.h>
28#include <asm/voyager.h> 29#include <asm/voyager.h>
29#include <asm/vic.h> 30#include <asm/vic.h>
30#include <asm/mtrr.h> 31#include <asm/mtrr.h>
31#include <asm/msr.h> 32#include <asm/msr.h>
32 33
33#define THREAD_NAME "kvoyagerd"
34 34
35/* external variables */ 35struct task_struct *voyager_thread;
36int kvoyagerd_running = 0; 36static __u8 set_timeout;
37DECLARE_MUTEX_LOCKED(kvoyagerd_sem);
38
39static int thread(void *);
40
41static __u8 set_timeout = 0;
42
43/* Start the machine monitor thread. Return 1 if OK, 0 if fail */
44static int __init
45voyager_thread_start(void)
46{
47 if(kernel_thread(thread, NULL, CLONE_KERNEL) < 0) {
48 /* This is serious, but not fatal */
49 printk(KERN_ERR "Voyager: Failed to create system monitor thread!!!\n");
50 return 1;
51 }
52 return 0;
53}
54 37
55static int 38static int
56execute(const char *string) 39execute(const char *string)
@@ -110,31 +93,15 @@ check_continuing_condition(void)
110 } 93 }
111} 94}
112 95
113static void
114wakeup(unsigned long unused)
115{
116 up(&kvoyagerd_sem);
117}
118
119static int 96static int
120thread(void *unused) 97thread(void *unused)
121{ 98{
122 struct timer_list wakeup_timer;
123
124 kvoyagerd_running = 1;
125
126 daemonize(THREAD_NAME);
127
128 set_timeout = 0;
129
130 init_timer(&wakeup_timer);
131
132 sigfillset(&current->blocked);
133
134 printk(KERN_NOTICE "Voyager starting monitor thread\n"); 99 printk(KERN_NOTICE "Voyager starting monitor thread\n");
135 100
136 for(;;) { 101 for (;;) {
137 down_interruptible(&kvoyagerd_sem); 102 set_current_state(TASK_INTERRUPTIBLE);
103 schedule_timeout(set_timeout ? HZ : MAX_SCHEDULE_TIMEOUT);
104
138 VDEBUG(("Voyager Daemon awoken\n")); 105 VDEBUG(("Voyager Daemon awoken\n"));
139 if(voyager_status.request_from_kernel == 0) { 106 if(voyager_status.request_from_kernel == 0) {
140 /* probably awoken from timeout */ 107 /* probably awoken from timeout */
@@ -143,20 +110,26 @@ thread(void *unused)
143 check_from_kernel(); 110 check_from_kernel();
144 voyager_status.request_from_kernel = 0; 111 voyager_status.request_from_kernel = 0;
145 } 112 }
146 if(set_timeout) {
147 del_timer(&wakeup_timer);
148 wakeup_timer.expires = HZ + jiffies;
149 wakeup_timer.function = wakeup;
150 add_timer(&wakeup_timer);
151 }
152 } 113 }
153} 114}
154 115
116static int __init
117voyager_thread_start(void)
118{
119 voyager_thread = kthread_run(thread, NULL, "kvoyagerd");
120 if (IS_ERR(voyager_thread)) {
121 printk(KERN_ERR "Voyager: Failed to create system monitor thread.\n");
122 return PTR_ERR(voyager_thread);
123 }
124 return 0;
125}
126
127
155static void __exit 128static void __exit
156voyager_thread_stop(void) 129voyager_thread_stop(void)
157{ 130{
158 /* FIXME: do nothing at the moment */ 131 kthread_stop(voyager_thread);
159} 132}
160 133
161module_init(voyager_thread_start); 134module_init(voyager_thread_start);
162//module_exit(voyager_thread_stop); 135module_exit(voyager_thread_stop);