[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>
This commit is contained in:
Родитель
ca9bda00b4
Коммит
fc09561d63
|
@ -225,6 +225,7 @@
|
||||||
#include <linux/smp_lock.h>
|
#include <linux/smp_lock.h>
|
||||||
#include <linux/dmi.h>
|
#include <linux/dmi.h>
|
||||||
#include <linux/suspend.h>
|
#include <linux/suspend.h>
|
||||||
|
#include <linux/kthread.h>
|
||||||
|
|
||||||
#include <asm/system.h>
|
#include <asm/system.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
|
@ -402,8 +403,6 @@ static int realmode_power_off = 1;
|
||||||
#else
|
#else
|
||||||
static int realmode_power_off;
|
static int realmode_power_off;
|
||||||
#endif
|
#endif
|
||||||
static int exit_kapmd __read_mostly;
|
|
||||||
static int kapmd_running __read_mostly;
|
|
||||||
#ifdef CONFIG_APM_ALLOW_INTS
|
#ifdef CONFIG_APM_ALLOW_INTS
|
||||||
static int allow_ints = 1;
|
static int allow_ints = 1;
|
||||||
#else
|
#else
|
||||||
|
@ -419,6 +418,8 @@ static const struct desc_struct bad_bios_desc = { 0, 0x00409200 };
|
||||||
|
|
||||||
static const char driver_version[] = "1.16ac"; /* no spaces */
|
static const char driver_version[] = "1.16ac"; /* no spaces */
|
||||||
|
|
||||||
|
static struct task_struct *kapmd_task;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* APM event names taken from the APM 1.2 specification. These are
|
* APM event names taken from the APM 1.2 specification. These are
|
||||||
* the message codes that the BIOS uses to tell us about events
|
* the message codes that the BIOS uses to tell us about events
|
||||||
|
@ -1423,7 +1424,7 @@ static void apm_mainloop(void)
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
schedule_timeout(APM_CHECK_TIMEOUT);
|
schedule_timeout(APM_CHECK_TIMEOUT);
|
||||||
if (exit_kapmd)
|
if (kthread_should_stop())
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* Ok, check all events, check for idle (and mark us sleeping
|
* Ok, check all events, check for idle (and mark us sleeping
|
||||||
|
@ -1706,12 +1707,6 @@ static int apm(void *unused)
|
||||||
char * power_stat;
|
char * power_stat;
|
||||||
char * bat_stat;
|
char * bat_stat;
|
||||||
|
|
||||||
kapmd_running = 1;
|
|
||||||
|
|
||||||
daemonize("kapmd");
|
|
||||||
|
|
||||||
current->flags |= PF_NOFREEZE;
|
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
/* 2002/08/01 - WT
|
/* 2002/08/01 - WT
|
||||||
* This is to avoid random crashes at boot time during initialization
|
* This is to avoid random crashes at boot time during initialization
|
||||||
|
@ -1821,7 +1816,6 @@ static int apm(void *unused)
|
||||||
console_blank_hook = NULL;
|
console_blank_hook = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
kapmd_running = 0;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2220,7 +2214,7 @@ static int __init apm_init(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *apm_proc;
|
struct proc_dir_entry *apm_proc;
|
||||||
struct desc_struct *gdt;
|
struct desc_struct *gdt;
|
||||||
int ret;
|
int err;
|
||||||
|
|
||||||
dmi_check_system(apm_dmi_table);
|
dmi_check_system(apm_dmi_table);
|
||||||
|
|
||||||
|
@ -2329,12 +2323,17 @@ static int __init apm_init(void)
|
||||||
if (apm_proc)
|
if (apm_proc)
|
||||||
apm_proc->owner = THIS_MODULE;
|
apm_proc->owner = THIS_MODULE;
|
||||||
|
|
||||||
ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD);
|
kapmd_task = kthread_create(apm, NULL, "kapmd");
|
||||||
if (ret < 0) {
|
if (IS_ERR(kapmd_task)) {
|
||||||
printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n");
|
printk(KERN_ERR "apm: disabled - Unable to start kernel "
|
||||||
|
"thread.\n");
|
||||||
|
err = PTR_ERR(kapmd_task);
|
||||||
|
kapmd_task = NULL;
|
||||||
remove_proc_entry("apm", NULL);
|
remove_proc_entry("apm", NULL);
|
||||||
return -ENOMEM;
|
return err;
|
||||||
}
|
}
|
||||||
|
kapmd_task->flags |= PF_NOFREEZE;
|
||||||
|
wake_up_process(kapmd_task);
|
||||||
|
|
||||||
if (num_online_cpus() > 1 && !smp ) {
|
if (num_online_cpus() > 1 && !smp ) {
|
||||||
printk(KERN_NOTICE
|
printk(KERN_NOTICE
|
||||||
|
@ -2384,9 +2383,10 @@ static void __exit apm_exit(void)
|
||||||
remove_proc_entry("apm", NULL);
|
remove_proc_entry("apm", NULL);
|
||||||
if (power_off)
|
if (power_off)
|
||||||
pm_power_off = NULL;
|
pm_power_off = NULL;
|
||||||
exit_kapmd = 1;
|
if (kapmd_task) {
|
||||||
while (kapmd_running)
|
kthread_stop(kapmd_task);
|
||||||
schedule();
|
kapmd_task = NULL;
|
||||||
|
}
|
||||||
#ifdef CONFIG_PM_LEGACY
|
#ifdef CONFIG_PM_LEGACY
|
||||||
pm_active = 0;
|
pm_active = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче