aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-06-01 03:38:12 -0400
committerDmitry Torokhov <dtor_core@ameritech.net>2005-06-01 03:38:12 -0400
commita9180ab2e21b0c0ffcec7461c3a52ab7608d023a (patch)
treef4994ab5ca4a60b4e57141536bc01794bab7d461 /drivers/input
parent9d5432979951c8761c2b4517007039b9bcc1c110 (diff)
Input: switch serio core to using kthread API instead of using
daemonize() and signals. This way kseriod will never be accidentially killed. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/serio/serio.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 0beacb77ee18..2c93ceab831a 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -31,10 +31,9 @@
31#include <linux/serio.h> 31#include <linux/serio.h>
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/wait.h> 33#include <linux/wait.h>
34#include <linux/completion.h>
35#include <linux/sched.h> 34#include <linux/sched.h>
36#include <linux/smp_lock.h>
37#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/kthread.h>
38 37
39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 38MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
40MODULE_DESCRIPTION("Serio abstraction core"); 39MODULE_DESCRIPTION("Serio abstraction core");
@@ -138,8 +137,7 @@ struct serio_event {
138static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */ 137static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */
139static LIST_HEAD(serio_event_list); 138static LIST_HEAD(serio_event_list);
140static DECLARE_WAIT_QUEUE_HEAD(serio_wait); 139static DECLARE_WAIT_QUEUE_HEAD(serio_wait);
141static DECLARE_COMPLETION(serio_exited); 140static struct task_struct *serio_task;
142static int serio_pid;
143 141
144static void serio_queue_event(void *object, struct module *owner, 142static void serio_queue_event(void *object, struct module *owner,
145 enum serio_event_type event_type) 143 enum serio_event_type event_type)
@@ -337,20 +335,15 @@ static struct serio *serio_get_pending_child(struct serio *parent)
337 335
338static int serio_thread(void *nothing) 336static int serio_thread(void *nothing)
339{ 337{
340 lock_kernel();
341 daemonize("kseriod");
342 allow_signal(SIGTERM);
343
344 do { 338 do {
345 serio_handle_events(); 339 serio_handle_events();
346 wait_event_interruptible(serio_wait, !list_empty(&serio_event_list)); 340 wait_event_interruptible(serio_wait,
341 kthread_should_stop() || !list_empty(&serio_event_list));
347 try_to_freeze(PF_FREEZE); 342 try_to_freeze(PF_FREEZE);
348 } while (!signal_pending(current)); 343 } while (!kthread_should_stop());
349 344
350 printk(KERN_DEBUG "serio: kseriod exiting\n"); 345 printk(KERN_DEBUG "serio: kseriod exiting\n");
351 346 return 0;
352 unlock_kernel();
353 complete_and_exit(&serio_exited, 0);
354} 347}
355 348
356 349
@@ -848,9 +841,10 @@ irqreturn_t serio_interrupt(struct serio *serio,
848 841
849static int __init serio_init(void) 842static int __init serio_init(void)
850{ 843{
851 if (!(serio_pid = kernel_thread(serio_thread, NULL, CLONE_KERNEL))) { 844 serio_task = kthread_run(serio_thread, NULL, "kseriod");
845 if (IS_ERR(serio_task)) {
852 printk(KERN_ERR "serio: Failed to start kseriod\n"); 846 printk(KERN_ERR "serio: Failed to start kseriod\n");
853 return -1; 847 return PTR_ERR(serio_task);
854 } 848 }
855 849
856 serio_bus.dev_attrs = serio_device_attrs; 850 serio_bus.dev_attrs = serio_device_attrs;
@@ -866,8 +860,7 @@ static int __init serio_init(void)
866static void __exit serio_exit(void) 860static void __exit serio_exit(void)
867{ 861{
868 bus_unregister(&serio_bus); 862 bus_unregister(&serio_bus);
869 kill_proc(serio_pid, SIGTERM, 1); 863 kthread_stop(serio_task);
870 wait_for_completion(&serio_exited);
871} 864}
872 865
873module_init(serio_init); 866module_init(serio_init);