Commit ea33a598 authored by Serge E. Hallyn's avatar Serge E. Hallyn Committed by Russell King

[ARM] kthread: switch arch/arm/kernel/apm.c

Switch arch/arm/kernel/apm.c from using kernel_thread - whose export
is deprecated - to kthread.
Signed-off-by: default avatarSerge E. Hallyn <serue@us.ibm.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent d1d8f7de
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/kthread.h>
#include <asm/apm.h> /* apm_power_info */ #include <asm/apm.h> /* apm_power_info */
#include <asm/system.h> #include <asm/system.h>
...@@ -80,7 +81,7 @@ struct apm_user { ...@@ -80,7 +81,7 @@ struct apm_user {
*/ */
static int suspends_pending; static int suspends_pending;
static int apm_disabled; static int apm_disabled;
static int arm_apm_active; static struct task_struct *kapmd_tsk;
static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue); static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
...@@ -97,7 +98,6 @@ static LIST_HEAD(apm_user_list); ...@@ -97,7 +98,6 @@ static LIST_HEAD(apm_user_list);
* to be suspending the system. * to be suspending the system.
*/ */
static DECLARE_WAIT_QUEUE_HEAD(kapmd_wait); static DECLARE_WAIT_QUEUE_HEAD(kapmd_wait);
static DECLARE_COMPLETION(kapmd_exit);
static DEFINE_SPINLOCK(kapmd_queue_lock); static DEFINE_SPINLOCK(kapmd_queue_lock);
static struct apm_queue kapmd_queue; static struct apm_queue kapmd_queue;
...@@ -468,16 +468,13 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length) ...@@ -468,16 +468,13 @@ static int apm_get_info(char *buf, char **start, off_t fpos, int length)
static int kapmd(void *arg) static int kapmd(void *arg)
{ {
daemonize("kapmd");
current->flags |= PF_NOFREEZE;
do { do {
apm_event_t event; apm_event_t event;
wait_event_interruptible(kapmd_wait, wait_event_interruptible(kapmd_wait,
!queue_empty(&kapmd_queue) || !arm_apm_active); !queue_empty(&kapmd_queue) || kthread_should_stop());
if (!arm_apm_active) if (kthread_should_stop())
break; break;
spin_lock_irq(&kapmd_queue_lock); spin_lock_irq(&kapmd_queue_lock);
...@@ -508,7 +505,7 @@ static int kapmd(void *arg) ...@@ -508,7 +505,7 @@ static int kapmd(void *arg)
} }
} while (1); } while (1);
complete_and_exit(&kapmd_exit, 0); return 0;
} }
static int __init apm_init(void) static int __init apm_init(void)
...@@ -520,13 +517,14 @@ static int __init apm_init(void) ...@@ -520,13 +517,14 @@ static int __init apm_init(void)
return -ENODEV; return -ENODEV;
} }
arm_apm_active = 1; kapmd_tsk = kthread_create(kapmd, NULL, "kapmd");
if (IS_ERR(kapmd_tsk)) {
ret = kernel_thread(kapmd, NULL, CLONE_KERNEL); ret = PTR_ERR(kapmd_tsk);
if (ret < 0) { kapmd_tsk = NULL;
arm_apm_active = 0;
return ret; return ret;
} }
kapmd_tsk->flags |= PF_NOFREEZE;
wake_up_process(kapmd_tsk);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
create_proc_info_entry("apm", 0, NULL, apm_get_info); create_proc_info_entry("apm", 0, NULL, apm_get_info);
...@@ -535,10 +533,7 @@ static int __init apm_init(void) ...@@ -535,10 +533,7 @@ static int __init apm_init(void)
ret = misc_register(&apm_device); ret = misc_register(&apm_device);
if (ret != 0) { if (ret != 0) {
remove_proc_entry("apm", NULL); remove_proc_entry("apm", NULL);
kthread_stop(kapmd_tsk);
arm_apm_active = 0;
wake_up(&kapmd_wait);
wait_for_completion(&kapmd_exit);
} }
return ret; return ret;
...@@ -549,9 +544,7 @@ static void __exit apm_exit(void) ...@@ -549,9 +544,7 @@ static void __exit apm_exit(void)
misc_deregister(&apm_device); misc_deregister(&apm_device);
remove_proc_entry("apm", NULL); remove_proc_entry("apm", NULL);
arm_apm_active = 0; kthread_stop(kapmd_tsk);
wake_up(&kapmd_wait);
wait_for_completion(&kapmd_exit);
} }
module_init(apm_init); module_init(apm_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment