Input: pmouse - introduce proper locking so state-changing
[linux-2.6/kvm.git] / drivers / input / serio / serio.c
blobb82815a0b65b60feb04bb8e7fdb46320f710d1df
1 /*
2 * The Serio abstraction module
4 * Copyright (c) 1999-2004 Vojtech Pavlik
5 * Copyright (c) 2004 Dmitry Torokhov
6 * Copyright (c) 2003 Daniele Bellucci
7 */
9 /*
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Should you need to contact me, the author, you can do so either by
25 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
26 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
29 #include <linux/stddef.h>
30 #include <linux/module.h>
31 #include <linux/serio.h>
32 #include <linux/errno.h>
33 #include <linux/wait.h>
34 #include <linux/sched.h>
35 #include <linux/slab.h>
36 #include <linux/kthread.h>
38 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
39 MODULE_DESCRIPTION("Serio abstraction core");
40 MODULE_LICENSE("GPL");
42 EXPORT_SYMBOL(serio_interrupt);
43 EXPORT_SYMBOL(__serio_register_port);
44 EXPORT_SYMBOL(serio_unregister_port);
45 EXPORT_SYMBOL(__serio_unregister_port_delayed);
46 EXPORT_SYMBOL(__serio_register_driver);
47 EXPORT_SYMBOL(serio_unregister_driver);
48 EXPORT_SYMBOL(serio_open);
49 EXPORT_SYMBOL(serio_close);
50 EXPORT_SYMBOL(serio_rescan);
51 EXPORT_SYMBOL(serio_reconnect);
54 * serio_sem protects entire serio subsystem and is taken every time
55 * serio port or driver registrered or unregistered.
57 static DECLARE_MUTEX(serio_sem);
59 static LIST_HEAD(serio_list);
61 static struct bus_type serio_bus = {
62 .name = "serio",
65 static void serio_add_port(struct serio *serio);
66 static void serio_destroy_port(struct serio *serio);
67 static void serio_reconnect_port(struct serio *serio);
68 static void serio_disconnect_port(struct serio *serio);
70 static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
72 int retval;
74 down(&serio->drv_sem);
75 retval = drv->connect(serio, drv);
76 up(&serio->drv_sem);
78 return retval;
81 static int serio_reconnect_driver(struct serio *serio)
83 int retval = -1;
85 down(&serio->drv_sem);
86 if (serio->drv && serio->drv->reconnect)
87 retval = serio->drv->reconnect(serio);
88 up(&serio->drv_sem);
90 return retval;
93 static void serio_disconnect_driver(struct serio *serio)
95 down(&serio->drv_sem);
96 if (serio->drv)
97 serio->drv->disconnect(serio);
98 up(&serio->drv_sem);
101 static int serio_match_port(const struct serio_device_id *ids, struct serio *serio)
103 while (ids->type || ids->proto) {
104 if ((ids->type == SERIO_ANY || ids->type == serio->id.type) &&
105 (ids->proto == SERIO_ANY || ids->proto == serio->id.proto) &&
106 (ids->extra == SERIO_ANY || ids->extra == serio->id.extra) &&
107 (ids->id == SERIO_ANY || ids->id == serio->id.id))
108 return 1;
109 ids++;
111 return 0;
115 * Basic serio -> driver core mappings
118 static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
120 down_write(&serio_bus.subsys.rwsem);
122 if (serio_match_port(drv->id_table, serio)) {
123 serio->dev.driver = &drv->driver;
124 if (serio_connect_driver(serio, drv)) {
125 serio->dev.driver = NULL;
126 goto out;
128 device_bind_driver(&serio->dev);
130 out:
131 up_write(&serio_bus.subsys.rwsem);
134 static void serio_release_driver(struct serio *serio)
136 down_write(&serio_bus.subsys.rwsem);
137 device_release_driver(&serio->dev);
138 up_write(&serio_bus.subsys.rwsem);
141 static void serio_find_driver(struct serio *serio)
143 down_write(&serio_bus.subsys.rwsem);
144 device_attach(&serio->dev);
145 up_write(&serio_bus.subsys.rwsem);
150 * Serio event processing.
153 enum serio_event_type {
154 SERIO_RESCAN,
155 SERIO_RECONNECT,
156 SERIO_REGISTER_PORT,
157 SERIO_UNREGISTER_PORT,
158 SERIO_REGISTER_DRIVER,
161 struct serio_event {
162 enum serio_event_type type;
163 void *object;
164 struct module *owner;
165 struct list_head node;
168 static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */
169 static LIST_HEAD(serio_event_list);
170 static DECLARE_WAIT_QUEUE_HEAD(serio_wait);
171 static struct task_struct *serio_task;
173 static void serio_queue_event(void *object, struct module *owner,
174 enum serio_event_type event_type)
176 unsigned long flags;
177 struct serio_event *event;
179 spin_lock_irqsave(&serio_event_lock, flags);
182 * Scan event list for the other events for the same serio port,
183 * starting with the most recent one. If event is the same we
184 * do not need add new one. If event is of different type we
185 * need to add this event and should not look further because
186 * we need to preseve sequence of distinct events.
188 list_for_each_entry_reverse(event, &serio_event_list, node) {
189 if (event->object == object) {
190 if (event->type == event_type)
191 goto out;
192 break;
196 if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) {
197 if (!try_module_get(owner)) {
198 printk(KERN_WARNING "serio: Can't get module reference, dropping event %d\n", event_type);
199 goto out;
202 event->type = event_type;
203 event->object = object;
204 event->owner = owner;
206 list_add_tail(&event->node, &serio_event_list);
207 wake_up(&serio_wait);
208 } else {
209 printk(KERN_ERR "serio: Not enough memory to queue event %d\n", event_type);
211 out:
212 spin_unlock_irqrestore(&serio_event_lock, flags);
215 static void serio_free_event(struct serio_event *event)
217 module_put(event->owner);
218 kfree(event);
221 static void serio_remove_duplicate_events(struct serio_event *event)
223 struct list_head *node, *next;
224 struct serio_event *e;
225 unsigned long flags;
227 spin_lock_irqsave(&serio_event_lock, flags);
229 list_for_each_safe(node, next, &serio_event_list) {
230 e = list_entry(node, struct serio_event, node);
231 if (event->object == e->object) {
233 * If this event is of different type we should not
234 * look further - we only suppress duplicate events
235 * that were sent back-to-back.
237 if (event->type != e->type)
238 break;
240 list_del_init(node);
241 serio_free_event(e);
245 spin_unlock_irqrestore(&serio_event_lock, flags);
249 static struct serio_event *serio_get_event(void)
251 struct serio_event *event;
252 struct list_head *node;
253 unsigned long flags;
255 spin_lock_irqsave(&serio_event_lock, flags);
257 if (list_empty(&serio_event_list)) {
258 spin_unlock_irqrestore(&serio_event_lock, flags);
259 return NULL;
262 node = serio_event_list.next;
263 event = list_entry(node, struct serio_event, node);
264 list_del_init(node);
266 spin_unlock_irqrestore(&serio_event_lock, flags);
268 return event;
271 static void serio_handle_events(void)
273 struct serio_event *event;
274 struct serio_driver *serio_drv;
276 down(&serio_sem);
278 while ((event = serio_get_event())) {
280 switch (event->type) {
281 case SERIO_REGISTER_PORT:
282 serio_add_port(event->object);
283 break;
285 case SERIO_UNREGISTER_PORT:
286 serio_disconnect_port(event->object);
287 serio_destroy_port(event->object);
288 break;
290 case SERIO_RECONNECT:
291 serio_reconnect_port(event->object);
292 break;
294 case SERIO_RESCAN:
295 serio_disconnect_port(event->object);
296 serio_find_driver(event->object);
297 break;
299 case SERIO_REGISTER_DRIVER:
300 serio_drv = event->object;
301 driver_register(&serio_drv->driver);
302 break;
304 default:
305 break;
308 serio_remove_duplicate_events(event);
309 serio_free_event(event);
312 up(&serio_sem);
316 * Remove all events that have been submitted for a given serio port.
318 static void serio_remove_pending_events(struct serio *serio)
320 struct list_head *node, *next;
321 struct serio_event *event;
322 unsigned long flags;
324 spin_lock_irqsave(&serio_event_lock, flags);
326 list_for_each_safe(node, next, &serio_event_list) {
327 event = list_entry(node, struct serio_event, node);
328 if (event->object == serio) {
329 list_del_init(node);
330 serio_free_event(event);
334 spin_unlock_irqrestore(&serio_event_lock, flags);
338 * Destroy child serio port (if any) that has not been fully registered yet.
340 * Note that we rely on the fact that port can have only one child and therefore
341 * only one child registration request can be pending. Additionally, children
342 * are registered by driver's connect() handler so there can't be a grandchild
343 * pending registration together with a child.
345 static struct serio *serio_get_pending_child(struct serio *parent)
347 struct serio_event *event;
348 struct serio *serio, *child = NULL;
349 unsigned long flags;
351 spin_lock_irqsave(&serio_event_lock, flags);
353 list_for_each_entry(event, &serio_event_list, node) {
354 if (event->type == SERIO_REGISTER_PORT) {
355 serio = event->object;
356 if (serio->parent == parent) {
357 child = serio;
358 break;
363 spin_unlock_irqrestore(&serio_event_lock, flags);
364 return child;
367 static int serio_thread(void *nothing)
369 do {
370 serio_handle_events();
371 wait_event_interruptible(serio_wait,
372 kthread_should_stop() || !list_empty(&serio_event_list));
373 try_to_freeze(PF_FREEZE);
374 } while (!kthread_should_stop());
376 printk(KERN_DEBUG "serio: kseriod exiting\n");
377 return 0;
382 * Serio port operations
385 static ssize_t serio_show_description(struct device *dev, char *buf)
387 struct serio *serio = to_serio_port(dev);
388 return sprintf(buf, "%s\n", serio->name);
391 static ssize_t serio_show_id_type(struct device *dev, char *buf)
393 struct serio *serio = to_serio_port(dev);
394 return sprintf(buf, "%02x\n", serio->id.type);
397 static ssize_t serio_show_id_proto(struct device *dev, char *buf)
399 struct serio *serio = to_serio_port(dev);
400 return sprintf(buf, "%02x\n", serio->id.proto);
403 static ssize_t serio_show_id_id(struct device *dev, char *buf)
405 struct serio *serio = to_serio_port(dev);
406 return sprintf(buf, "%02x\n", serio->id.id);
409 static ssize_t serio_show_id_extra(struct device *dev, char *buf)
411 struct serio *serio = to_serio_port(dev);
412 return sprintf(buf, "%02x\n", serio->id.extra);
415 static DEVICE_ATTR(type, S_IRUGO, serio_show_id_type, NULL);
416 static DEVICE_ATTR(proto, S_IRUGO, serio_show_id_proto, NULL);
417 static DEVICE_ATTR(id, S_IRUGO, serio_show_id_id, NULL);
418 static DEVICE_ATTR(extra, S_IRUGO, serio_show_id_extra, NULL);
420 static struct attribute *serio_device_id_attrs[] = {
421 &dev_attr_type.attr,
422 &dev_attr_proto.attr,
423 &dev_attr_id.attr,
424 &dev_attr_extra.attr,
425 NULL
428 static struct attribute_group serio_id_attr_group = {
429 .name = "id",
430 .attrs = serio_device_id_attrs,
433 static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count)
435 struct serio *serio = to_serio_port(dev);
436 struct device_driver *drv;
437 int retval;
439 retval = down_interruptible(&serio_sem);
440 if (retval)
441 return retval;
443 retval = count;
444 if (!strncmp(buf, "none", count)) {
445 serio_disconnect_port(serio);
446 } else if (!strncmp(buf, "reconnect", count)) {
447 serio_reconnect_port(serio);
448 } else if (!strncmp(buf, "rescan", count)) {
449 serio_disconnect_port(serio);
450 serio_find_driver(serio);
451 } else if ((drv = driver_find(buf, &serio_bus)) != NULL) {
452 serio_disconnect_port(serio);
453 serio_bind_driver(serio, to_serio_driver(drv));
454 put_driver(drv);
455 } else {
456 retval = -EINVAL;
459 up(&serio_sem);
461 return retval;
464 static ssize_t serio_show_bind_mode(struct device *dev, char *buf)
466 struct serio *serio = to_serio_port(dev);
467 return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto");
470 static ssize_t serio_set_bind_mode(struct device *dev, const char *buf, size_t count)
472 struct serio *serio = to_serio_port(dev);
473 int retval;
475 retval = count;
476 if (!strncmp(buf, "manual", count)) {
477 serio->manual_bind = 1;
478 } else if (!strncmp(buf, "auto", count)) {
479 serio->manual_bind = 0;
480 } else {
481 retval = -EINVAL;
484 return retval;
487 static struct device_attribute serio_device_attrs[] = {
488 __ATTR(description, S_IRUGO, serio_show_description, NULL),
489 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver),
490 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode),
491 __ATTR_NULL
495 static void serio_release_port(struct device *dev)
497 struct serio *serio = to_serio_port(dev);
499 kfree(serio);
500 module_put(THIS_MODULE);
504 * Prepare serio port for registration.
506 static void serio_init_port(struct serio *serio)
508 static atomic_t serio_no = ATOMIC_INIT(0);
510 __module_get(THIS_MODULE);
512 spin_lock_init(&serio->lock);
513 init_MUTEX(&serio->drv_sem);
514 device_initialize(&serio->dev);
515 snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id),
516 "serio%ld", (long)atomic_inc_return(&serio_no) - 1);
517 serio->dev.bus = &serio_bus;
518 serio->dev.release = serio_release_port;
519 if (serio->parent)
520 serio->dev.parent = &serio->parent->dev;
524 * Complete serio port registration.
525 * Driver core will attempt to find appropriate driver for the port.
527 static void serio_add_port(struct serio *serio)
529 if (serio->parent) {
530 serio_pause_rx(serio->parent);
531 serio->parent->child = serio;
532 serio_continue_rx(serio->parent);
535 list_add_tail(&serio->node, &serio_list);
536 if (serio->start)
537 serio->start(serio);
538 device_add(&serio->dev);
539 sysfs_create_group(&serio->dev.kobj, &serio_id_attr_group);
540 serio->registered = 1;
544 * serio_destroy_port() completes deregistration process and removes
545 * port from the system
547 static void serio_destroy_port(struct serio *serio)
549 struct serio *child;
551 child = serio_get_pending_child(serio);
552 if (child) {
553 serio_remove_pending_events(child);
554 put_device(&child->dev);
557 if (serio->stop)
558 serio->stop(serio);
560 if (serio->parent) {
561 serio_pause_rx(serio->parent);
562 serio->parent->child = NULL;
563 serio_continue_rx(serio->parent);
564 serio->parent = NULL;
567 if (serio->registered) {
568 sysfs_remove_group(&serio->dev.kobj, &serio_id_attr_group);
569 device_del(&serio->dev);
570 list_del_init(&serio->node);
571 serio->registered = 0;
574 serio_remove_pending_events(serio);
575 put_device(&serio->dev);
579 * Reconnect serio port and all its children (re-initialize attached devices)
581 static void serio_reconnect_port(struct serio *serio)
583 do {
584 if (serio_reconnect_driver(serio)) {
585 serio_disconnect_port(serio);
586 serio_find_driver(serio);
587 /* Ok, old children are now gone, we are done */
588 break;
590 serio = serio->child;
591 } while (serio);
595 * serio_disconnect_port() unbinds a port from its driver. As a side effect
596 * all child ports are unbound and destroyed.
598 static void serio_disconnect_port(struct serio *serio)
600 struct serio *s, *parent;
602 if (serio->child) {
604 * Children ports should be disconnected and destroyed
605 * first, staring with the leaf one, since we don't want
606 * to do recursion
608 for (s = serio; s->child; s = s->child)
609 /* empty */;
611 do {
612 parent = s->parent;
614 serio_release_driver(s);
615 serio_destroy_port(s);
616 } while ((s = parent) != serio);
620 * Ok, no children left, now disconnect this port
622 serio_release_driver(serio);
625 void serio_rescan(struct serio *serio)
627 serio_queue_event(serio, NULL, SERIO_RESCAN);
630 void serio_reconnect(struct serio *serio)
632 serio_queue_event(serio, NULL, SERIO_RECONNECT);
636 * Submits register request to kseriod for subsequent execution.
637 * Note that port registration is always asynchronous.
639 void __serio_register_port(struct serio *serio, struct module *owner)
641 serio_init_port(serio);
642 serio_queue_event(serio, owner, SERIO_REGISTER_PORT);
646 * Synchronously unregisters serio port.
648 void serio_unregister_port(struct serio *serio)
650 down(&serio_sem);
651 serio_disconnect_port(serio);
652 serio_destroy_port(serio);
653 up(&serio_sem);
657 * Submits register request to kseriod for subsequent execution.
658 * Can be used when it is not obvious whether the serio_sem is
659 * taken or not and when delayed execution is feasible.
661 void __serio_unregister_port_delayed(struct serio *serio, struct module *owner)
663 serio_queue_event(serio, owner, SERIO_UNREGISTER_PORT);
668 * Serio driver operations
671 static ssize_t serio_driver_show_description(struct device_driver *drv, char *buf)
673 struct serio_driver *driver = to_serio_driver(drv);
674 return sprintf(buf, "%s\n", driver->description ? driver->description : "(none)");
677 static ssize_t serio_driver_show_bind_mode(struct device_driver *drv, char *buf)
679 struct serio_driver *serio_drv = to_serio_driver(drv);
680 return sprintf(buf, "%s\n", serio_drv->manual_bind ? "manual" : "auto");
683 static ssize_t serio_driver_set_bind_mode(struct device_driver *drv, const char *buf, size_t count)
685 struct serio_driver *serio_drv = to_serio_driver(drv);
686 int retval;
688 retval = count;
689 if (!strncmp(buf, "manual", count)) {
690 serio_drv->manual_bind = 1;
691 } else if (!strncmp(buf, "auto", count)) {
692 serio_drv->manual_bind = 0;
693 } else {
694 retval = -EINVAL;
697 return retval;
701 static struct driver_attribute serio_driver_attrs[] = {
702 __ATTR(description, S_IRUGO, serio_driver_show_description, NULL),
703 __ATTR(bind_mode, S_IWUSR | S_IRUGO,
704 serio_driver_show_bind_mode, serio_driver_set_bind_mode),
705 __ATTR_NULL
708 static int serio_driver_probe(struct device *dev)
710 struct serio *serio = to_serio_port(dev);
711 struct serio_driver *drv = to_serio_driver(dev->driver);
713 return serio_connect_driver(serio, drv);
716 static int serio_driver_remove(struct device *dev)
718 struct serio *serio = to_serio_port(dev);
720 serio_disconnect_driver(serio);
721 return 0;
724 void __serio_register_driver(struct serio_driver *drv, struct module *owner)
726 drv->driver.bus = &serio_bus;
727 drv->driver.probe = serio_driver_probe;
728 drv->driver.remove = serio_driver_remove;
730 serio_queue_event(drv, owner, SERIO_REGISTER_DRIVER);
733 void serio_unregister_driver(struct serio_driver *drv)
735 struct serio *serio;
737 down(&serio_sem);
738 drv->manual_bind = 1; /* so serio_find_driver ignores it */
740 start_over:
741 list_for_each_entry(serio, &serio_list, node) {
742 if (serio->drv == drv) {
743 serio_disconnect_port(serio);
744 serio_find_driver(serio);
745 /* we could've deleted some ports, restart */
746 goto start_over;
750 driver_unregister(&drv->driver);
751 up(&serio_sem);
754 static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
756 serio_pause_rx(serio);
757 serio->drv = drv;
758 serio_continue_rx(serio);
761 static int serio_bus_match(struct device *dev, struct device_driver *drv)
763 struct serio *serio = to_serio_port(dev);
764 struct serio_driver *serio_drv = to_serio_driver(drv);
766 if (serio->manual_bind || serio_drv->manual_bind)
767 return 0;
769 return serio_match_port(serio_drv->id_table, serio);
772 #ifdef CONFIG_HOTPLUG
774 #define PUT_ENVP(fmt, val) \
775 do { \
776 envp[i++] = buffer; \
777 length += snprintf(buffer, buffer_size - length, fmt, val); \
778 if (buffer_size - length <= 0 || i >= num_envp) \
779 return -ENOMEM; \
780 length++; \
781 buffer += length; \
782 } while (0)
783 static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
785 struct serio *serio;
786 int i = 0;
787 int length = 0;
789 if (!dev)
790 return -ENODEV;
792 serio = to_serio_port(dev);
794 PUT_ENVP("SERIO_TYPE=%02x", serio->id.type);
795 PUT_ENVP("SERIO_PROTO=%02x", serio->id.proto);
796 PUT_ENVP("SERIO_ID=%02x", serio->id.id);
797 PUT_ENVP("SERIO_EXTRA=%02x", serio->id.extra);
799 envp[i] = NULL;
801 return 0;
803 #undef PUT_ENVP
805 #else
807 static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
809 return -ENODEV;
812 #endif /* CONFIG_HOTPLUG */
814 static int serio_resume(struct device *dev)
816 struct serio *serio = to_serio_port(dev);
818 if (serio_reconnect_driver(serio)) {
820 * Driver re-probing can take a while, so better let kseriod
821 * deal with it.
823 serio_rescan(serio);
826 return 0;
829 /* called from serio_driver->connect/disconnect methods under serio_sem */
830 int serio_open(struct serio *serio, struct serio_driver *drv)
832 serio_set_drv(serio, drv);
834 if (serio->open && serio->open(serio)) {
835 serio_set_drv(serio, NULL);
836 return -1;
838 return 0;
841 /* called from serio_driver->connect/disconnect methods under serio_sem */
842 void serio_close(struct serio *serio)
844 if (serio->close)
845 serio->close(serio);
847 serio_set_drv(serio, NULL);
850 irqreturn_t serio_interrupt(struct serio *serio,
851 unsigned char data, unsigned int dfl, struct pt_regs *regs)
853 unsigned long flags;
854 irqreturn_t ret = IRQ_NONE;
856 spin_lock_irqsave(&serio->lock, flags);
858 if (likely(serio->drv)) {
859 ret = serio->drv->interrupt(serio, data, dfl, regs);
860 } else if (!dfl && serio->registered) {
861 serio_rescan(serio);
862 ret = IRQ_HANDLED;
865 spin_unlock_irqrestore(&serio->lock, flags);
867 return ret;
870 static int __init serio_init(void)
872 serio_task = kthread_run(serio_thread, NULL, "kseriod");
873 if (IS_ERR(serio_task)) {
874 printk(KERN_ERR "serio: Failed to start kseriod\n");
875 return PTR_ERR(serio_task);
878 serio_bus.dev_attrs = serio_device_attrs;
879 serio_bus.drv_attrs = serio_driver_attrs;
880 serio_bus.match = serio_bus_match;
881 serio_bus.hotplug = serio_hotplug;
882 serio_bus.resume = serio_resume;
883 bus_register(&serio_bus);
885 return 0;
888 static void __exit serio_exit(void)
890 bus_unregister(&serio_bus);
891 kthread_stop(serio_task);
894 module_init(serio_init);
895 module_exit(serio_exit);