2 * The Serio abstraction module
4 * Copyright (c) 1999-2004 Vojtech Pavlik
5 * Copyright (c) 2004 Dmitry Torokhov
6 * Copyright (c) 2003 Daniele Bellucci
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 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 #include <linux/stddef.h>
32 #include <linux/module.h>
33 #include <linux/serio.h>
34 #include <linux/errno.h>
35 #include <linux/wait.h>
36 #include <linux/sched.h>
37 #include <linux/slab.h>
38 #include <linux/kthread.h>
39 #include <linux/mutex.h>
40 #include <linux/freezer.h>
42 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
43 MODULE_DESCRIPTION("Serio abstraction core");
44 MODULE_LICENSE("GPL");
47 * serio_mutex protects entire serio subsystem and is taken every time
48 * serio port or driver registrered or unregistered.
50 static DEFINE_MUTEX(serio_mutex);
52 static LIST_HEAD(serio_list);
54 static struct bus_type serio_bus;
56 static void serio_add_port(struct serio *serio);
57 static int serio_reconnect_port(struct serio *serio);
58 static void serio_disconnect_port(struct serio *serio);
59 static void serio_reconnect_chain(struct serio *serio);
60 static void serio_attach_driver(struct serio_driver *drv);
62 static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
66 mutex_lock(&serio->drv_mutex);
67 retval = drv->connect(serio, drv);
68 mutex_unlock(&serio->drv_mutex);
73 static int serio_reconnect_driver(struct serio *serio)
77 mutex_lock(&serio->drv_mutex);
78 if (serio->drv && serio->drv->reconnect)
79 retval = serio->drv->reconnect(serio);
80 mutex_unlock(&serio->drv_mutex);
85 static void serio_disconnect_driver(struct serio *serio)
87 mutex_lock(&serio->drv_mutex);
89 serio->drv->disconnect(serio);
90 mutex_unlock(&serio->drv_mutex);
93 static int serio_match_port(const struct serio_device_id *ids, struct serio *serio)
95 while (ids->type || ids->proto) {
96 if ((ids->type == SERIO_ANY || ids->type == serio->id.type) &&
97 (ids->proto == SERIO_ANY || ids->proto == serio->id.proto) &&
98 (ids->extra == SERIO_ANY || ids->extra == serio->id.extra) &&
99 (ids->id == SERIO_ANY || ids->id == serio->id.id))
107 * Basic serio -> driver core mappings
110 static int serio_bind_driver(struct serio *serio, struct serio_driver *drv)
114 if (serio_match_port(drv->id_table, serio)) {
116 serio->dev.driver = &drv->driver;
117 if (serio_connect_driver(serio, drv)) {
118 serio->dev.driver = NULL;
122 error = device_bind_driver(&serio->dev);
124 dev_warn(&serio->dev,
125 "device_bind_driver() failed for %s (%s) and %s, error: %d\n",
126 serio->phys, serio->name,
127 drv->description, error);
128 serio_disconnect_driver(serio);
129 serio->dev.driver = NULL;
136 static void serio_find_driver(struct serio *serio)
140 error = device_attach(&serio->dev);
142 dev_warn(&serio->dev,
143 "device_attach() failed for %s (%s), error: %d\n",
144 serio->phys, serio->name, error);
149 * Serio event processing.
152 enum serio_event_type {
154 SERIO_RECONNECT_PORT,
155 SERIO_RECONNECT_CHAIN,
161 enum serio_event_type type;
163 struct module *owner;
164 struct list_head node;
167 static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */
168 static LIST_HEAD(serio_event_list);
169 static DECLARE_WAIT_QUEUE_HEAD(serio_wait);
170 static struct task_struct *serio_task;
172 static int serio_queue_event(void *object, struct module *owner,
173 enum serio_event_type event_type)
176 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)
196 event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC);
198 pr_err("Not enough memory to queue event %d\n", event_type);
203 if (!try_module_get(owner)) {
204 pr_warning("Can't get module reference, dropping event %d\n",
211 event->type = event_type;
212 event->object = object;
213 event->owner = owner;
215 list_add_tail(&event->node, &serio_event_list);
216 wake_up(&serio_wait);
219 spin_unlock_irqrestore(&serio_event_lock, flags);
223 static void serio_free_event(struct serio_event *event)
225 module_put(event->owner);
229 static void serio_remove_duplicate_events(struct serio_event *event)
231 struct serio_event *e, *next;
234 spin_lock_irqsave(&serio_event_lock, flags);
236 list_for_each_entry_safe(e, next, &serio_event_list, node) {
237 if (event->object == e->object) {
239 * If this event is of different type we should not
240 * look further - we only suppress duplicate events
241 * that were sent back-to-back.
243 if (event->type != e->type)
246 list_del_init(&e->node);
251 spin_unlock_irqrestore(&serio_event_lock, flags);
255 static struct serio_event *serio_get_event(void)
257 struct serio_event *event = NULL;
260 spin_lock_irqsave(&serio_event_lock, flags);
262 if (!list_empty(&serio_event_list)) {
263 event = list_first_entry(&serio_event_list,
264 struct serio_event, node);
265 list_del_init(&event->node);
268 spin_unlock_irqrestore(&serio_event_lock, flags);
272 static void serio_handle_event(void)
274 struct serio_event *event;
276 mutex_lock(&serio_mutex);
279 * Note that we handle only one event here to give swsusp
280 * a chance to freeze kseriod thread. Serio events should
281 * be pretty rare so we are not concerned about taking
284 if ((event = serio_get_event())) {
286 switch (event->type) {
288 case SERIO_REGISTER_PORT:
289 serio_add_port(event->object);
292 case SERIO_RECONNECT_PORT:
293 serio_reconnect_port(event->object);
296 case SERIO_RESCAN_PORT:
297 serio_disconnect_port(event->object);
298 serio_find_driver(event->object);
301 case SERIO_RECONNECT_CHAIN:
302 serio_reconnect_chain(event->object);
305 case SERIO_ATTACH_DRIVER:
306 serio_attach_driver(event->object);
310 serio_remove_duplicate_events(event);
311 serio_free_event(event);
314 mutex_unlock(&serio_mutex);
318 * Remove all events that have been submitted for a given
319 * object, be it serio port or driver.
321 static void serio_remove_pending_events(void *object)
323 struct serio_event *event, *next;
326 spin_lock_irqsave(&serio_event_lock, flags);
328 list_for_each_entry_safe(event, next, &serio_event_list, node) {
329 if (event->object == object) {
330 list_del_init(&event->node);
331 serio_free_event(event);
335 spin_unlock_irqrestore(&serio_event_lock, flags);
339 * Destroy child serio port (if any) that has not been fully registered yet.
341 * Note that we rely on the fact that port can have only one child and therefore
342 * only one child registration request can be pending. Additionally, children
343 * are registered by driver's connect() handler so there can't be a grandchild
344 * pending registration together with a child.
346 static struct serio *serio_get_pending_child(struct serio *parent)
348 struct serio_event *event;
349 struct serio *serio, *child = NULL;
352 spin_lock_irqsave(&serio_event_lock, flags);
354 list_for_each_entry(event, &serio_event_list, node) {
355 if (event->type == SERIO_REGISTER_PORT) {
356 serio = event->object;
357 if (serio->parent == parent) {
364 spin_unlock_irqrestore(&serio_event_lock, flags);
368 static int serio_thread(void *nothing)
372 serio_handle_event();
373 wait_event_freezable(serio_wait,
374 kthread_should_stop() || !list_empty(&serio_event_list));
375 } while (!kthread_should_stop());
382 * Serio port operations
385 static ssize_t serio_show_description(struct device *dev, struct device_attribute *attr, char *buf)
387 struct serio *serio = to_serio_port(dev);
388 return sprintf(buf, "%s\n", serio->name);
391 static ssize_t serio_show_modalias(struct device *dev, struct device_attribute *attr, char *buf)
393 struct serio *serio = to_serio_port(dev);
395 return sprintf(buf, "serio:ty%02Xpr%02Xid%02Xex%02X\n",
396 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra);
399 static ssize_t serio_show_id_type(struct device *dev, struct device_attribute *attr, char *buf)
401 struct serio *serio = to_serio_port(dev);
402 return sprintf(buf, "%02x\n", serio->id.type);
405 static ssize_t serio_show_id_proto(struct device *dev, struct device_attribute *attr, char *buf)
407 struct serio *serio = to_serio_port(dev);
408 return sprintf(buf, "%02x\n", serio->id.proto);
411 static ssize_t serio_show_id_id(struct device *dev, struct device_attribute *attr, char *buf)
413 struct serio *serio = to_serio_port(dev);
414 return sprintf(buf, "%02x\n", serio->id.id);
417 static ssize_t serio_show_id_extra(struct device *dev, struct device_attribute *attr, char *buf)
419 struct serio *serio = to_serio_port(dev);
420 return sprintf(buf, "%02x\n", serio->id.extra);
423 static DEVICE_ATTR(type, S_IRUGO, serio_show_id_type, NULL);
424 static DEVICE_ATTR(proto, S_IRUGO, serio_show_id_proto, NULL);
425 static DEVICE_ATTR(id, S_IRUGO, serio_show_id_id, NULL);
426 static DEVICE_ATTR(extra, S_IRUGO, serio_show_id_extra, NULL);
428 static struct attribute *serio_device_id_attrs[] = {
430 &dev_attr_proto.attr,
432 &dev_attr_extra.attr,
436 static struct attribute_group serio_id_attr_group = {
438 .attrs = serio_device_id_attrs,
441 static const struct attribute_group *serio_device_attr_groups[] = {
442 &serio_id_attr_group,
446 static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
448 struct serio *serio = to_serio_port(dev);
449 struct device_driver *drv;
452 error = mutex_lock_interruptible(&serio_mutex);
456 if (!strncmp(buf, "none", count)) {
457 serio_disconnect_port(serio);
458 } else if (!strncmp(buf, "reconnect", count)) {
459 serio_reconnect_chain(serio);
460 } else if (!strncmp(buf, "rescan", count)) {
461 serio_disconnect_port(serio);
462 serio_find_driver(serio);
463 } else if ((drv = driver_find(buf, &serio_bus)) != NULL) {
464 serio_disconnect_port(serio);
465 error = serio_bind_driver(serio, to_serio_driver(drv));
471 mutex_unlock(&serio_mutex);
473 return error ? error : count;
476 static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf)
478 struct serio *serio = to_serio_port(dev);
479 return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto");
482 static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
484 struct serio *serio = to_serio_port(dev);
488 if (!strncmp(buf, "manual", count)) {
489 serio->manual_bind = true;
490 } else if (!strncmp(buf, "auto", count)) {
491 serio->manual_bind = false;
499 static struct device_attribute serio_device_attrs[] = {
500 __ATTR(description, S_IRUGO, serio_show_description, NULL),
501 __ATTR(modalias, S_IRUGO, serio_show_modalias, NULL),
502 __ATTR(drvctl, S_IWUSR, NULL, serio_rebind_driver),
503 __ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode),
508 static void serio_release_port(struct device *dev)
510 struct serio *serio = to_serio_port(dev);
513 module_put(THIS_MODULE);
517 * Prepare serio port for registration.
519 static void serio_init_port(struct serio *serio)
521 static atomic_t serio_no = ATOMIC_INIT(0);
523 __module_get(THIS_MODULE);
525 INIT_LIST_HEAD(&serio->node);
526 spin_lock_init(&serio->lock);
527 mutex_init(&serio->drv_mutex);
528 device_initialize(&serio->dev);
529 dev_set_name(&serio->dev, "serio%ld",
530 (long)atomic_inc_return(&serio_no) - 1);
531 serio->dev.bus = &serio_bus;
532 serio->dev.release = serio_release_port;
533 serio->dev.groups = serio_device_attr_groups;
535 serio->dev.parent = &serio->parent->dev;
536 serio->depth = serio->parent->depth + 1;
539 lockdep_set_subclass(&serio->lock, serio->depth);
543 * Complete serio port registration.
544 * Driver core will attempt to find appropriate driver for the port.
546 static void serio_add_port(struct serio *serio)
551 serio_pause_rx(serio->parent);
552 serio->parent->child = serio;
553 serio_continue_rx(serio->parent);
556 list_add_tail(&serio->node, &serio_list);
561 error = device_add(&serio->dev);
564 "device_add() failed for %s (%s), error: %d\n",
565 serio->phys, serio->name, error);
569 * serio_destroy_port() completes deregistration process and removes
570 * port from the system
572 static void serio_destroy_port(struct serio *serio)
576 child = serio_get_pending_child(serio);
578 serio_remove_pending_events(child);
579 put_device(&child->dev);
586 serio_pause_rx(serio->parent);
587 serio->parent->child = NULL;
588 serio_continue_rx(serio->parent);
589 serio->parent = NULL;
592 if (device_is_registered(&serio->dev))
593 device_del(&serio->dev);
595 list_del_init(&serio->node);
596 serio_remove_pending_events(serio);
597 put_device(&serio->dev);
601 * Reconnect serio port (re-initialize attached device).
602 * If reconnect fails (old device is no longer attached or
603 * there was no device to begin with) we do full rescan in
604 * hope of finding a driver for the port.
606 static int serio_reconnect_port(struct serio *serio)
608 int error = serio_reconnect_driver(serio);
611 serio_disconnect_port(serio);
612 serio_find_driver(serio);
619 * Reconnect serio port and all its children (re-initialize attached devices)
621 static void serio_reconnect_chain(struct serio *serio)
624 if (serio_reconnect_port(serio)) {
625 /* Ok, old children are now gone, we are done */
628 serio = serio->child;
633 * serio_disconnect_port() unbinds a port from its driver. As a side effect
634 * all child ports are unbound and destroyed.
636 static void serio_disconnect_port(struct serio *serio)
638 struct serio *s, *parent;
642 * Children ports should be disconnected and destroyed
643 * first, staring with the leaf one, since we don't want
646 for (s = serio; s->child; s = s->child)
652 device_release_driver(&s->dev);
653 serio_destroy_port(s);
654 } while ((s = parent) != serio);
658 * Ok, no children left, now disconnect this port
660 device_release_driver(&serio->dev);
663 void serio_rescan(struct serio *serio)
665 serio_queue_event(serio, NULL, SERIO_RESCAN_PORT);
667 EXPORT_SYMBOL(serio_rescan);
669 void serio_reconnect(struct serio *serio)
671 serio_queue_event(serio, NULL, SERIO_RECONNECT_CHAIN);
673 EXPORT_SYMBOL(serio_reconnect);
676 * Submits register request to kseriod for subsequent execution.
677 * Note that port registration is always asynchronous.
679 void __serio_register_port(struct serio *serio, struct module *owner)
681 serio_init_port(serio);
682 serio_queue_event(serio, owner, SERIO_REGISTER_PORT);
684 EXPORT_SYMBOL(__serio_register_port);
687 * Synchronously unregisters serio port.
689 void serio_unregister_port(struct serio *serio)
691 mutex_lock(&serio_mutex);
692 serio_disconnect_port(serio);
693 serio_destroy_port(serio);
694 mutex_unlock(&serio_mutex);
696 EXPORT_SYMBOL(serio_unregister_port);
699 * Safely unregisters child port if one is present.
701 void serio_unregister_child_port(struct serio *serio)
703 mutex_lock(&serio_mutex);
705 serio_disconnect_port(serio->child);
706 serio_destroy_port(serio->child);
708 mutex_unlock(&serio_mutex);
710 EXPORT_SYMBOL(serio_unregister_child_port);
714 * Serio driver operations
717 static ssize_t serio_driver_show_description(struct device_driver *drv, char *buf)
719 struct serio_driver *driver = to_serio_driver(drv);
720 return sprintf(buf, "%s\n", driver->description ? driver->description : "(none)");
723 static ssize_t serio_driver_show_bind_mode(struct device_driver *drv, char *buf)
725 struct serio_driver *serio_drv = to_serio_driver(drv);
726 return sprintf(buf, "%s\n", serio_drv->manual_bind ? "manual" : "auto");
729 static ssize_t serio_driver_set_bind_mode(struct device_driver *drv, const char *buf, size_t count)
731 struct serio_driver *serio_drv = to_serio_driver(drv);
735 if (!strncmp(buf, "manual", count)) {
736 serio_drv->manual_bind = true;
737 } else if (!strncmp(buf, "auto", count)) {
738 serio_drv->manual_bind = false;
747 static struct driver_attribute serio_driver_attrs[] = {
748 __ATTR(description, S_IRUGO, serio_driver_show_description, NULL),
749 __ATTR(bind_mode, S_IWUSR | S_IRUGO,
750 serio_driver_show_bind_mode, serio_driver_set_bind_mode),
754 static int serio_driver_probe(struct device *dev)
756 struct serio *serio = to_serio_port(dev);
757 struct serio_driver *drv = to_serio_driver(dev->driver);
759 return serio_connect_driver(serio, drv);
762 static int serio_driver_remove(struct device *dev)
764 struct serio *serio = to_serio_port(dev);
766 serio_disconnect_driver(serio);
770 static void serio_cleanup(struct serio *serio)
772 mutex_lock(&serio->drv_mutex);
773 if (serio->drv && serio->drv->cleanup)
774 serio->drv->cleanup(serio);
775 mutex_unlock(&serio->drv_mutex);
778 static void serio_shutdown(struct device *dev)
780 struct serio *serio = to_serio_port(dev);
782 serio_cleanup(serio);
785 static void serio_attach_driver(struct serio_driver *drv)
789 error = driver_attach(&drv->driver);
791 pr_warning("driver_attach() failed for %s with error %d\n",
792 drv->driver.name, error);
795 int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
797 bool manual_bind = drv->manual_bind;
800 drv->driver.bus = &serio_bus;
801 drv->driver.owner = owner;
802 drv->driver.mod_name = mod_name;
805 * Temporarily disable automatic binding because probing
806 * takes long time and we are better off doing it in kseriod
808 drv->manual_bind = true;
810 error = driver_register(&drv->driver);
812 pr_err("driver_register() failed for %s, error: %d\n",
813 drv->driver.name, error);
818 * Restore original bind mode and let kseriod bind the
819 * driver to free ports
822 drv->manual_bind = false;
823 error = serio_queue_event(drv, NULL, SERIO_ATTACH_DRIVER);
825 driver_unregister(&drv->driver);
832 EXPORT_SYMBOL(__serio_register_driver);
834 void serio_unregister_driver(struct serio_driver *drv)
838 mutex_lock(&serio_mutex);
840 drv->manual_bind = true; /* so serio_find_driver ignores it */
841 serio_remove_pending_events(drv);
844 list_for_each_entry(serio, &serio_list, node) {
845 if (serio->drv == drv) {
846 serio_disconnect_port(serio);
847 serio_find_driver(serio);
848 /* we could've deleted some ports, restart */
853 driver_unregister(&drv->driver);
854 mutex_unlock(&serio_mutex);
856 EXPORT_SYMBOL(serio_unregister_driver);
858 static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
860 serio_pause_rx(serio);
862 serio_continue_rx(serio);
865 static int serio_bus_match(struct device *dev, struct device_driver *drv)
867 struct serio *serio = to_serio_port(dev);
868 struct serio_driver *serio_drv = to_serio_driver(drv);
870 if (serio->manual_bind || serio_drv->manual_bind)
873 return serio_match_port(serio_drv->id_table, serio);
876 #ifdef CONFIG_HOTPLUG
878 #define SERIO_ADD_UEVENT_VAR(fmt, val...) \
880 int err = add_uevent_var(env, fmt, val); \
885 static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
892 serio = to_serio_port(dev);
894 SERIO_ADD_UEVENT_VAR("SERIO_TYPE=%02x", serio->id.type);
895 SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto);
896 SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id);
897 SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra);
898 SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X",
899 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra);
903 #undef SERIO_ADD_UEVENT_VAR
907 static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
912 #endif /* CONFIG_HOTPLUG */
915 static int serio_suspend(struct device *dev)
917 struct serio *serio = to_serio_port(dev);
919 serio_cleanup(serio);
924 static int serio_resume(struct device *dev)
926 struct serio *serio = to_serio_port(dev);
929 * Driver reconnect can take a while, so better let kseriod
932 serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
937 static const struct dev_pm_ops serio_pm_ops = {
938 .suspend = serio_suspend,
939 .resume = serio_resume,
940 .poweroff = serio_suspend,
941 .restore = serio_resume,
943 #endif /* CONFIG_PM */
945 /* called from serio_driver->connect/disconnect methods under serio_mutex */
946 int serio_open(struct serio *serio, struct serio_driver *drv)
948 serio_set_drv(serio, drv);
950 if (serio->open && serio->open(serio)) {
951 serio_set_drv(serio, NULL);
956 EXPORT_SYMBOL(serio_open);
958 /* called from serio_driver->connect/disconnect methods under serio_mutex */
959 void serio_close(struct serio *serio)
964 serio_set_drv(serio, NULL);
966 EXPORT_SYMBOL(serio_close);
968 irqreturn_t serio_interrupt(struct serio *serio,
969 unsigned char data, unsigned int dfl)
972 irqreturn_t ret = IRQ_NONE;
974 spin_lock_irqsave(&serio->lock, flags);
976 if (likely(serio->drv)) {
977 ret = serio->drv->interrupt(serio, data, dfl);
978 } else if (!dfl && device_is_registered(&serio->dev)) {
983 spin_unlock_irqrestore(&serio->lock, flags);
987 EXPORT_SYMBOL(serio_interrupt);
989 static struct bus_type serio_bus = {
991 .dev_attrs = serio_device_attrs,
992 .drv_attrs = serio_driver_attrs,
993 .match = serio_bus_match,
994 .uevent = serio_uevent,
995 .probe = serio_driver_probe,
996 .remove = serio_driver_remove,
997 .shutdown = serio_shutdown,
1003 static int __init serio_init(void)
1007 error = bus_register(&serio_bus);
1009 pr_err("Failed to register serio bus, error: %d\n", error);
1013 serio_task = kthread_run(serio_thread, NULL, "kseriod");
1014 if (IS_ERR(serio_task)) {
1015 bus_unregister(&serio_bus);
1016 error = PTR_ERR(serio_task);
1017 pr_err("Failed to start kseriod, error: %d\n", error);
1024 static void __exit serio_exit(void)
1026 bus_unregister(&serio_bus);
1027 kthread_stop(serio_task);
1030 subsys_initcall(serio_init);
1031 module_exit(serio_exit);