diff options
| author | Christoph Hellwig <hch@infradead.org> | 2007-04-22 15:30:43 -0400 |
|---|---|---|
| committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2007-05-01 11:09:29 -0400 |
| commit | f3402a4e52fc1bdfc386a7f512e6e384cd69ecad (patch) | |
| tree | 41cc9fb7d6e3040d6b0d69158875f01a335c0144 | |
| parent | 9f483519be82420e308b9a90a96a9c62f28032ae (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>
| -rw-r--r-- | arch/i386/mach-voyager/voyager_cat.c | 4 | ||||
| -rw-r--r-- | arch/i386/mach-voyager/voyager_thread.c | 69 | ||||
| -rw-r--r-- | include/asm-i386/voyager.h | 6 |
3 files changed, 24 insertions, 55 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 */ | 35 | struct task_struct *voyager_thread; |
| 36 | int kvoyagerd_running = 0; | 36 | static __u8 set_timeout; |
| 37 | DECLARE_MUTEX_LOCKED(kvoyagerd_sem); | ||
| 38 | |||
| 39 | static int thread(void *); | ||
| 40 | |||
| 41 | static __u8 set_timeout = 0; | ||
| 42 | |||
| 43 | /* Start the machine monitor thread. Return 1 if OK, 0 if fail */ | ||
| 44 | static int __init | ||
| 45 | voyager_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 | ||
| 55 | static int | 38 | static int |
| 56 | execute(const char *string) | 39 | execute(const char *string) |
| @@ -110,31 +93,15 @@ check_continuing_condition(void) | |||
| 110 | } | 93 | } |
| 111 | } | 94 | } |
| 112 | 95 | ||
| 113 | static void | ||
| 114 | wakeup(unsigned long unused) | ||
| 115 | { | ||
| 116 | up(&kvoyagerd_sem); | ||
| 117 | } | ||
| 118 | |||
| 119 | static int | 96 | static int |
| 120 | thread(void *unused) | 97 | thread(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(¤t->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 | ||
| 116 | static int __init | ||
| 117 | voyager_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 | |||
| 155 | static void __exit | 128 | static void __exit |
| 156 | voyager_thread_stop(void) | 129 | voyager_thread_stop(void) |
| 157 | { | 130 | { |
| 158 | /* FIXME: do nothing at the moment */ | 131 | kthread_stop(voyager_thread); |
| 159 | } | 132 | } |
| 160 | 133 | ||
| 161 | module_init(voyager_thread_start); | 134 | module_init(voyager_thread_start); |
| 162 | //module_exit(voyager_thread_stop); | 135 | module_exit(voyager_thread_stop); |
diff --git a/include/asm-i386/voyager.h b/include/asm-i386/voyager.h index 5b27838905b2..91a9932937ab 100644 --- a/include/asm-i386/voyager.h +++ b/include/asm-i386/voyager.h | |||
| @@ -487,15 +487,11 @@ extern struct voyager_qic_cpi *voyager_quad_cpi_addr[NR_CPUS]; | |||
| 487 | extern struct voyager_SUS *voyager_SUS; | 487 | extern struct voyager_SUS *voyager_SUS; |
| 488 | 488 | ||
| 489 | /* variables exported always */ | 489 | /* variables exported always */ |
| 490 | extern struct task_struct *voyager_thread; | ||
| 490 | extern int voyager_level; | 491 | extern int voyager_level; |
| 491 | extern int kvoyagerd_running; | ||
| 492 | extern struct semaphore kvoyagerd_sem; | ||
| 493 | extern struct voyager_status voyager_status; | 492 | extern struct voyager_status voyager_status; |
| 494 | 493 | ||
| 495 | |||
| 496 | |||
| 497 | /* functions exported by the voyager and voyager_smp modules */ | 494 | /* functions exported by the voyager and voyager_smp modules */ |
| 498 | |||
| 499 | extern int voyager_cat_readb(__u8 module, __u8 asic, int reg); | 495 | extern int voyager_cat_readb(__u8 module, __u8 asic, int reg); |
| 500 | extern void voyager_cat_init(void); | 496 | extern void voyager_cat_init(void); |
| 501 | extern void voyager_detect(struct voyager_bios_info *); | 497 | extern void voyager_detect(struct voyager_bios_info *); |
