diff options
author | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-06-01 03:38:12 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2005-06-01 03:38:12 -0400 |
commit | a9180ab2e21b0c0ffcec7461c3a52ab7608d023a (patch) | |
tree | f4994ab5ca4a60b4e57141536bc01794bab7d461 /drivers/input | |
parent | 9d5432979951c8761c2b4517007039b9bcc1c110 (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.c | 27 |
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 | ||
39 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 38 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
40 | MODULE_DESCRIPTION("Serio abstraction core"); | 39 | MODULE_DESCRIPTION("Serio abstraction core"); |
@@ -138,8 +137,7 @@ struct serio_event { | |||
138 | static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */ | 137 | static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */ |
139 | static LIST_HEAD(serio_event_list); | 138 | static LIST_HEAD(serio_event_list); |
140 | static DECLARE_WAIT_QUEUE_HEAD(serio_wait); | 139 | static DECLARE_WAIT_QUEUE_HEAD(serio_wait); |
141 | static DECLARE_COMPLETION(serio_exited); | 140 | static struct task_struct *serio_task; |
142 | static int serio_pid; | ||
143 | 141 | ||
144 | static void serio_queue_event(void *object, struct module *owner, | 142 | static 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 | ||
338 | static int serio_thread(void *nothing) | 336 | static 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 | ||
849 | static int __init serio_init(void) | 842 | static 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) | |||
866 | static void __exit serio_exit(void) | 860 | static 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 | ||
873 | module_init(serio_init); | 866 | module_init(serio_init); |