aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSerge E. Hallyn <serue@us.ibm.com>2006-09-29 05:00:04 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:12 -0400
commitfc09561d6392771a392dea55c287de7e849b6b63 (patch)
tree8f754252a1e3109c4187f9e6f53f66eaf9486f49 /arch
parentca9bda00b4aafc42cd3d1b9d32934463e2993b4c (diff)
[PATCH] kthread: convert arch/i386/kernel/apm.c
Convert i386 apm.c from kernel_thread(), whose export is deprecated, to kthread API. Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/i386/kernel/apm.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index ff9ce4b5eaa8..b42f2d914af3 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -225,6 +225,7 @@
225#include <linux/smp_lock.h> 225#include <linux/smp_lock.h>
226#include <linux/dmi.h> 226#include <linux/dmi.h>
227#include <linux/suspend.h> 227#include <linux/suspend.h>
228#include <linux/kthread.h>
228 229
229#include <asm/system.h> 230#include <asm/system.h>
230#include <asm/uaccess.h> 231#include <asm/uaccess.h>
@@ -402,8 +403,6 @@ static int realmode_power_off = 1;
402#else 403#else
403static int realmode_power_off; 404static int realmode_power_off;
404#endif 405#endif
405static int exit_kapmd __read_mostly;
406static int kapmd_running __read_mostly;
407#ifdef CONFIG_APM_ALLOW_INTS 406#ifdef CONFIG_APM_ALLOW_INTS
408static int allow_ints = 1; 407static int allow_ints = 1;
409#else 408#else
@@ -419,6 +418,8 @@ static const struct desc_struct bad_bios_desc = { 0, 0x00409200 };
419 418
420static const char driver_version[] = "1.16ac"; /* no spaces */ 419static const char driver_version[] = "1.16ac"; /* no spaces */
421 420
421static struct task_struct *kapmd_task;
422
422/* 423/*
423 * APM event names taken from the APM 1.2 specification. These are 424 * APM event names taken from the APM 1.2 specification. These are
424 * the message codes that the BIOS uses to tell us about events 425 * the message codes that the BIOS uses to tell us about events
@@ -1423,7 +1424,7 @@ static void apm_mainloop(void)
1423 set_current_state(TASK_INTERRUPTIBLE); 1424 set_current_state(TASK_INTERRUPTIBLE);
1424 for (;;) { 1425 for (;;) {
1425 schedule_timeout(APM_CHECK_TIMEOUT); 1426 schedule_timeout(APM_CHECK_TIMEOUT);
1426 if (exit_kapmd) 1427 if (kthread_should_stop())
1427 break; 1428 break;
1428 /* 1429 /*
1429 * Ok, check all events, check for idle (and mark us sleeping 1430 * Ok, check all events, check for idle (and mark us sleeping
@@ -1706,12 +1707,6 @@ static int apm(void *unused)
1706 char * power_stat; 1707 char * power_stat;
1707 char * bat_stat; 1708 char * bat_stat;
1708 1709
1709 kapmd_running = 1;
1710
1711 daemonize("kapmd");
1712
1713 current->flags |= PF_NOFREEZE;
1714
1715#ifdef CONFIG_SMP 1710#ifdef CONFIG_SMP
1716 /* 2002/08/01 - WT 1711 /* 2002/08/01 - WT
1717 * This is to avoid random crashes at boot time during initialization 1712 * This is to avoid random crashes at boot time during initialization
@@ -1821,7 +1816,6 @@ static int apm(void *unused)
1821 console_blank_hook = NULL; 1816 console_blank_hook = NULL;
1822#endif 1817#endif
1823 } 1818 }
1824 kapmd_running = 0;
1825 1819
1826 return 0; 1820 return 0;
1827} 1821}
@@ -2220,7 +2214,7 @@ static int __init apm_init(void)
2220{ 2214{
2221 struct proc_dir_entry *apm_proc; 2215 struct proc_dir_entry *apm_proc;
2222 struct desc_struct *gdt; 2216 struct desc_struct *gdt;
2223 int ret; 2217 int err;
2224 2218
2225 dmi_check_system(apm_dmi_table); 2219 dmi_check_system(apm_dmi_table);
2226 2220
@@ -2329,12 +2323,17 @@ static int __init apm_init(void)
2329 if (apm_proc) 2323 if (apm_proc)
2330 apm_proc->owner = THIS_MODULE; 2324 apm_proc->owner = THIS_MODULE;
2331 2325
2332 ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD); 2326 kapmd_task = kthread_create(apm, NULL, "kapmd");
2333 if (ret < 0) { 2327 if (IS_ERR(kapmd_task)) {
2334 printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n"); 2328 printk(KERN_ERR "apm: disabled - Unable to start kernel "
2329 "thread.\n");
2330 err = PTR_ERR(kapmd_task);
2331 kapmd_task = NULL;
2335 remove_proc_entry("apm", NULL); 2332 remove_proc_entry("apm", NULL);
2336 return -ENOMEM; 2333 return err;
2337 } 2334 }
2335 kapmd_task->flags |= PF_NOFREEZE;
2336 wake_up_process(kapmd_task);
2338 2337
2339 if (num_online_cpus() > 1 && !smp ) { 2338 if (num_online_cpus() > 1 && !smp ) {
2340 printk(KERN_NOTICE 2339 printk(KERN_NOTICE
@@ -2384,9 +2383,10 @@ static void __exit apm_exit(void)
2384 remove_proc_entry("apm", NULL); 2383 remove_proc_entry("apm", NULL);
2385 if (power_off) 2384 if (power_off)
2386 pm_power_off = NULL; 2385 pm_power_off = NULL;
2387 exit_kapmd = 1; 2386 if (kapmd_task) {
2388 while (kapmd_running) 2387 kthread_stop(kapmd_task);
2389 schedule(); 2388 kapmd_task = NULL;
2389 }
2390#ifdef CONFIG_PM_LEGACY 2390#ifdef CONFIG_PM_LEGACY
2391 pm_active = 0; 2391 pm_active = 0;
2392#endif 2392#endif