aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/evdev.c9
-rw-r--r--drivers/input/gameport/gameport.c39
-rw-r--r--drivers/input/input.c10
-rw-r--r--drivers/input/joydev.c8
-rw-r--r--drivers/input/keyboard/atkbd.c6
-rw-r--r--drivers/input/mouse/alps.c2
-rw-r--r--drivers/input/mouse/psmouse.h4
-rw-r--r--drivers/input/mousedev.c16
-rw-r--r--drivers/input/serio/i8042.c2
-rw-r--r--drivers/input/serio/serio.c107
-rw-r--r--drivers/input/serio/serport.c2
-rw-r--r--drivers/input/tsdev.c9
12 files changed, 95 insertions, 119 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index d62c73f5ba93..374f404e81da 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -678,9 +678,9 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
678 678
679 devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), 679 devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
680 S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor); 680 S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
681 class_simple_device_add(input_class, 681 class_device_create(input_class,
682 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor), 682 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
683 dev->dev, "event%d", minor); 683 dev->dev, "event%d", minor);
684 684
685 return &evdev->handle; 685 return &evdev->handle;
686} 686}
@@ -690,7 +690,8 @@ static void evdev_disconnect(struct input_handle *handle)
690 struct evdev *evdev = handle->private; 690 struct evdev *evdev = handle->private;
691 struct evdev_list *list; 691 struct evdev_list *list;
692 692
693 class_simple_device_remove(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor)); 693 class_device_destroy(input_class,
694 MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
694 devfs_remove("input/event%d", evdev->minor); 695 devfs_remove("input/event%d", evdev->minor);
695 evdev->exist = 0; 696 evdev->exist = 0;
696 697
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index d7dfa6f53cf6..c77a82e46055 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -17,10 +17,11 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/gameport.h> 18#include <linux/gameport.h>
19#include <linux/wait.h> 19#include <linux/wait.h>
20#include <linux/completion.h>
20#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/smp_lock.h>
21#include <linux/slab.h> 23#include <linux/slab.h>
22#include <linux/delay.h> 24#include <linux/delay.h>
23#include <linux/kthread.h>
24 25
25/*#include <asm/io.h>*/ 26/*#include <asm/io.h>*/
26 27
@@ -133,7 +134,7 @@ static int gameport_measure_speed(struct gameport *gameport)
133 } 134 }
134 135
135 gameport_close(gameport); 136 gameport_close(gameport);
136 return (cpu_data[_smp_processor_id()].loops_per_jiffy * (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx); 137 return (cpu_data[raw_smp_processor_id()].loops_per_jiffy * (unsigned long)HZ / (1000 / 50)) / (tx < 1 ? 1 : tx);
137 138
138#else 139#else
139 140
@@ -237,7 +238,8 @@ struct gameport_event {
237static DEFINE_SPINLOCK(gameport_event_lock); /* protects gameport_event_list */ 238static DEFINE_SPINLOCK(gameport_event_lock); /* protects gameport_event_list */
238static LIST_HEAD(gameport_event_list); 239static LIST_HEAD(gameport_event_list);
239static DECLARE_WAIT_QUEUE_HEAD(gameport_wait); 240static DECLARE_WAIT_QUEUE_HEAD(gameport_wait);
240static struct task_struct *gameport_task; 241static DECLARE_COMPLETION(gameport_exited);
242static int gameport_pid;
241 243
242static void gameport_queue_event(void *object, struct module *owner, 244static void gameport_queue_event(void *object, struct module *owner,
243 enum gameport_event_type event_type) 245 enum gameport_event_type event_type)
@@ -248,12 +250,12 @@ static void gameport_queue_event(void *object, struct module *owner,
248 spin_lock_irqsave(&gameport_event_lock, flags); 250 spin_lock_irqsave(&gameport_event_lock, flags);
249 251
250 /* 252 /*
251 * Scan event list for the other events for the same gameport port, 253 * Scan event list for the other events for the same gameport port,
252 * starting with the most recent one. If event is the same we 254 * starting with the most recent one. If event is the same we
253 * do not need add new one. If event is of different type we 255 * do not need add new one. If event is of different type we
254 * need to add this event and should not look further because 256 * need to add this event and should not look further because
255 * we need to preseve sequence of distinct events. 257 * we need to preseve sequence of distinct events.
256 */ 258 */
257 list_for_each_entry_reverse(event, &gameport_event_list, node) { 259 list_for_each_entry_reverse(event, &gameport_event_list, node) {
258 if (event->object == object) { 260 if (event->object == object) {
259 if (event->type == event_type) 261 if (event->type == event_type)
@@ -430,15 +432,20 @@ static struct gameport *gameport_get_pending_child(struct gameport *parent)
430 432
431static int gameport_thread(void *nothing) 433static int gameport_thread(void *nothing)
432{ 434{
435 lock_kernel();
436 daemonize("kgameportd");
437 allow_signal(SIGTERM);
438
433 do { 439 do {
434 gameport_handle_events(); 440 gameport_handle_events();
435 wait_event_interruptible(gameport_wait, 441 wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list));
436 kthread_should_stop() || !list_empty(&gameport_event_list)); 442 try_to_freeze();
437 try_to_freeze(PF_FREEZE); 443 } while (!signal_pending(current));
438 } while (!kthread_should_stop());
439 444
440 printk(KERN_DEBUG "gameport: kgameportd exiting\n"); 445 printk(KERN_DEBUG "gameport: kgameportd exiting\n");
441 return 0; 446
447 unlock_kernel();
448 complete_and_exit(&gameport_exited, 0);
442} 449}
443 450
444 451
@@ -446,13 +453,13 @@ static int gameport_thread(void *nothing)
446 * Gameport port operations 453 * Gameport port operations
447 */ 454 */
448 455
449static ssize_t gameport_show_description(struct device *dev, char *buf) 456static ssize_t gameport_show_description(struct device *dev, struct device_attribute *attr, char *buf)
450{ 457{
451 struct gameport *gameport = to_gameport_port(dev); 458 struct gameport *gameport = to_gameport_port(dev);
452 return sprintf(buf, "%s\n", gameport->name); 459 return sprintf(buf, "%s\n", gameport->name);
453} 460}
454 461
455static ssize_t gameport_rebind_driver(struct device *dev, const char *buf, size_t count) 462static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
456{ 463{
457 struct gameport *gameport = to_gameport_port(dev); 464 struct gameport *gameport = to_gameport_port(dev);
458 struct device_driver *drv; 465 struct device_driver *drv;
@@ -766,10 +773,9 @@ void gameport_close(struct gameport *gameport)
766 773
767static int __init gameport_init(void) 774static int __init gameport_init(void)
768{ 775{
769 gameport_task = kthread_run(gameport_thread, NULL, "kgameportd"); 776 if (!(gameport_pid = kernel_thread(gameport_thread, NULL, CLONE_KERNEL))) {
770 if (IS_ERR(gameport_task)) {
771 printk(KERN_ERR "gameport: Failed to start kgameportd\n"); 777 printk(KERN_ERR "gameport: Failed to start kgameportd\n");
772 return PTR_ERR(gameport_task); 778 return -1;
773 } 779 }
774 780
775 gameport_bus.dev_attrs = gameport_device_attrs; 781 gameport_bus.dev_attrs = gameport_device_attrs;
@@ -783,7 +789,8 @@ static int __init gameport_init(void)
783static void __exit gameport_exit(void) 789static void __exit gameport_exit(void)
784{ 790{
785 bus_unregister(&gameport_bus); 791 bus_unregister(&gameport_bus);
786 kthread_stop(gameport_task); 792 kill_proc(gameport_pid, SIGTERM, 1);
793 wait_for_completion(&gameport_exited);
787} 794}
788 795
789module_init(gameport_init); 796module_init(gameport_init);
diff --git a/drivers/input/input.c b/drivers/input/input.c
index c1dbc04cf54a..7c4b4d37b3e6 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -729,13 +729,13 @@ static int __init input_proc_init(void)
729static inline int input_proc_init(void) { return 0; } 729static inline int input_proc_init(void) { return 0; }
730#endif 730#endif
731 731
732struct class_simple *input_class; 732struct class *input_class;
733 733
734static int __init input_init(void) 734static int __init input_init(void)
735{ 735{
736 int retval = -ENOMEM; 736 int retval = -ENOMEM;
737 737
738 input_class = class_simple_create(THIS_MODULE, "input"); 738 input_class = class_create(THIS_MODULE, "input");
739 if (IS_ERR(input_class)) 739 if (IS_ERR(input_class))
740 return PTR_ERR(input_class); 740 return PTR_ERR(input_class);
741 input_proc_init(); 741 input_proc_init();
@@ -745,7 +745,7 @@ static int __init input_init(void)
745 remove_proc_entry("devices", proc_bus_input_dir); 745 remove_proc_entry("devices", proc_bus_input_dir);
746 remove_proc_entry("handlers", proc_bus_input_dir); 746 remove_proc_entry("handlers", proc_bus_input_dir);
747 remove_proc_entry("input", proc_bus); 747 remove_proc_entry("input", proc_bus);
748 class_simple_destroy(input_class); 748 class_destroy(input_class);
749 return retval; 749 return retval;
750 } 750 }
751 751
@@ -755,7 +755,7 @@ static int __init input_init(void)
755 remove_proc_entry("handlers", proc_bus_input_dir); 755 remove_proc_entry("handlers", proc_bus_input_dir);
756 remove_proc_entry("input", proc_bus); 756 remove_proc_entry("input", proc_bus);
757 unregister_chrdev(INPUT_MAJOR, "input"); 757 unregister_chrdev(INPUT_MAJOR, "input");
758 class_simple_destroy(input_class); 758 class_destroy(input_class);
759 } 759 }
760 return retval; 760 return retval;
761} 761}
@@ -768,7 +768,7 @@ static void __exit input_exit(void)
768 768
769 devfs_remove("input"); 769 devfs_remove("input");
770 unregister_chrdev(INPUT_MAJOR, "input"); 770 unregister_chrdev(INPUT_MAJOR, "input");
771 class_simple_destroy(input_class); 771 class_destroy(input_class);
772} 772}
773 773
774subsys_initcall(input_init); 774subsys_initcall(input_init);
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 816a585a0e6b..ff8e1bbd0e13 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -518,9 +518,9 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
518 518
519 devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), 519 devfs_mk_cdev(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
520 S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor); 520 S_IFCHR|S_IRUGO|S_IWUSR, "input/js%d", minor);
521 class_simple_device_add(input_class, 521 class_device_create(input_class,
522 MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor), 522 MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor),
523 dev->dev, "js%d", minor); 523 dev->dev, "js%d", minor);
524 524
525 return &joydev->handle; 525 return &joydev->handle;
526} 526}
@@ -530,7 +530,7 @@ static void joydev_disconnect(struct input_handle *handle)
530 struct joydev *joydev = handle->private; 530 struct joydev *joydev = handle->private;
531 struct joydev_list *list; 531 struct joydev_list *list;
532 532
533 class_simple_device_remove(MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor)); 533 class_device_destroy(input_class, MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + joydev->minor));
534 devfs_remove("input/js%d", joydev->minor); 534 devfs_remove("input/js%d", joydev->minor);
535 joydev->exist = 0; 535 joydev->exist = 0;
536 536
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 9f9da6d4a23f..4d4985b59abf 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -54,7 +54,7 @@ static int atkbd_softraw = 1;
54module_param_named(softraw, atkbd_softraw, bool, 0); 54module_param_named(softraw, atkbd_softraw, bool, 0);
55MODULE_PARM_DESC(softraw, "Use software generated rawmode"); 55MODULE_PARM_DESC(softraw, "Use software generated rawmode");
56 56
57static int atkbd_scroll = 1; 57static int atkbd_scroll = 0;
58module_param_named(scroll, atkbd_scroll, bool, 0); 58module_param_named(scroll, atkbd_scroll, bool, 0);
59MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards"); 59MODULE_PARM_DESC(scroll, "Enable scroll-wheel on MS Office and similar keyboards");
60 60
@@ -219,11 +219,11 @@ static ssize_t atkbd_attr_set_helper(struct device *dev, const char *buf, size_t
219#define ATKBD_DEFINE_ATTR(_name) \ 219#define ATKBD_DEFINE_ATTR(_name) \
220static ssize_t atkbd_show_##_name(struct atkbd *, char *); \ 220static ssize_t atkbd_show_##_name(struct atkbd *, char *); \
221static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \ 221static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \
222static ssize_t atkbd_do_show_##_name(struct device *d, char *b) \ 222static ssize_t atkbd_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \
223{ \ 223{ \
224 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \ 224 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \
225} \ 225} \
226static ssize_t atkbd_do_set_##_name(struct device *d, const char *b, size_t s) \ 226static ssize_t atkbd_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s) \
227{ \ 227{ \
228 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \ 228 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \
229} \ 229} \
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index ffdc82313192..a12e98158a75 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -364,7 +364,7 @@ static int alps_reconnect(struct psmouse *psmouse)
364 if (alps_get_status(psmouse, param)) 364 if (alps_get_status(psmouse, param))
365 return -1; 365 return -1;
366 366
367 if (param[0] & 0x04) 367 if (!(param[0] & 0x04))
368 alps_tap_mode(psmouse, 1); 368 alps_tap_mode(psmouse, 1);
369 369
370 if (alps_absolute_mode(psmouse)) { 370 if (alps_absolute_mode(psmouse)) {
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index dc8e9ae07f32..86691cf43433 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -93,11 +93,11 @@ ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t coun
93#define PSMOUSE_DEFINE_ATTR(_name) \ 93#define PSMOUSE_DEFINE_ATTR(_name) \
94static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \ 94static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \
95static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\ 95static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\
96static ssize_t psmouse_do_show_##_name(struct device *d, char *b) \ 96static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \
97{ \ 97{ \
98 return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \ 98 return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \
99} \ 99} \
100static ssize_t psmouse_do_set_##_name(struct device *d, const char *b, size_t s)\ 100static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\
101{ \ 101{ \
102 return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \ 102 return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \
103} \ 103} \
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 08b191180af0..c6194a9dd174 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -651,9 +651,9 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
651 651
652 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), 652 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
653 S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor); 653 S_IFCHR|S_IRUGO|S_IWUSR, "input/mouse%d", minor);
654 class_simple_device_add(input_class, 654 class_device_create(input_class,
655 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor), 655 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor),
656 dev->dev, "mouse%d", minor); 656 dev->dev, "mouse%d", minor);
657 657
658 return &mousedev->handle; 658 return &mousedev->handle;
659} 659}
@@ -663,7 +663,8 @@ static void mousedev_disconnect(struct input_handle *handle)
663 struct mousedev *mousedev = handle->private; 663 struct mousedev *mousedev = handle->private;
664 struct mousedev_list *list; 664 struct mousedev_list *list;
665 665
666 class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor)); 666 class_device_destroy(input_class,
667 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + mousedev->minor));
667 devfs_remove("input/mouse%d", mousedev->minor); 668 devfs_remove("input/mouse%d", mousedev->minor);
668 mousedev->exist = 0; 669 mousedev->exist = 0;
669 670
@@ -739,8 +740,8 @@ static int __init mousedev_init(void)
739 740
740 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), 741 devfs_mk_cdev(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX),
741 S_IFCHR|S_IRUGO|S_IWUSR, "input/mice"); 742 S_IFCHR|S_IRUGO|S_IWUSR, "input/mice");
742 class_simple_device_add(input_class, MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), 743 class_device_create(input_class,
743 NULL, "mice"); 744 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX), NULL, "mice");
744 745
745#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 746#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
746 if (!(psaux_registered = !misc_register(&psaux_mouse))) 747 if (!(psaux_registered = !misc_register(&psaux_mouse)))
@@ -759,7 +760,8 @@ static void __exit mousedev_exit(void)
759 misc_deregister(&psaux_mouse); 760 misc_deregister(&psaux_mouse);
760#endif 761#endif
761 devfs_remove("input/mice"); 762 devfs_remove("input/mice");
762 class_simple_device_remove(MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX)); 763 class_device_destroy(input_class,
764 MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + MOUSEDEV_MIX));
763 input_unregister_handler(&mousedev_handler); 765 input_unregister_handler(&mousedev_handler);
764} 766}
765 767
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 5900de3c3f4f..a9bf549c8dc5 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -396,7 +396,7 @@ static void i8042_stop(struct serio *serio)
396 struct i8042_port *port = serio->port_data; 396 struct i8042_port *port = serio->port_data;
397 397
398 port->exists = 0; 398 port->exists = 0;
399 synchronize_kernel(); 399 synchronize_sched();
400 port->serio = NULL; 400 port->serio = NULL;
401} 401}
402 402
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 615bf62ad468..341824c48529 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -31,9 +31,10 @@
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>
34#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/smp_lock.h>
35#include <linux/slab.h> 37#include <linux/slab.h>
36#include <linux/kthread.h>
37 38
38MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
39MODULE_DESCRIPTION("Serio abstraction core"); 40MODULE_DESCRIPTION("Serio abstraction core");
@@ -42,7 +43,6 @@ MODULE_LICENSE("GPL");
42EXPORT_SYMBOL(serio_interrupt); 43EXPORT_SYMBOL(serio_interrupt);
43EXPORT_SYMBOL(__serio_register_port); 44EXPORT_SYMBOL(__serio_register_port);
44EXPORT_SYMBOL(serio_unregister_port); 45EXPORT_SYMBOL(serio_unregister_port);
45EXPORT_SYMBOL(serio_unregister_child_port);
46EXPORT_SYMBOL(__serio_unregister_port_delayed); 46EXPORT_SYMBOL(__serio_unregister_port_delayed);
47EXPORT_SYMBOL(__serio_register_driver); 47EXPORT_SYMBOL(__serio_register_driver);
48EXPORT_SYMBOL(serio_unregister_driver); 48EXPORT_SYMBOL(serio_unregister_driver);
@@ -68,37 +68,6 @@ static void serio_destroy_port(struct serio *serio);
68static void serio_reconnect_port(struct serio *serio); 68static void serio_reconnect_port(struct serio *serio);
69static void serio_disconnect_port(struct serio *serio); 69static void serio_disconnect_port(struct serio *serio);
70 70
71static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
72{
73 int retval;
74
75 down(&serio->drv_sem);
76 retval = drv->connect(serio, drv);
77 up(&serio->drv_sem);
78
79 return retval;
80}
81
82static int serio_reconnect_driver(struct serio *serio)
83{
84 int retval = -1;
85
86 down(&serio->drv_sem);
87 if (serio->drv && serio->drv->reconnect)
88 retval = serio->drv->reconnect(serio);
89 up(&serio->drv_sem);
90
91 return retval;
92}
93
94static void serio_disconnect_driver(struct serio *serio)
95{
96 down(&serio->drv_sem);
97 if (serio->drv)
98 serio->drv->disconnect(serio);
99 up(&serio->drv_sem);
100}
101
102static int serio_match_port(const struct serio_device_id *ids, struct serio *serio) 71static int serio_match_port(const struct serio_device_id *ids, struct serio *serio)
103{ 72{
104 while (ids->type || ids->proto) { 73 while (ids->type || ids->proto) {
@@ -122,7 +91,7 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
122 91
123 if (serio_match_port(drv->id_table, serio)) { 92 if (serio_match_port(drv->id_table, serio)) {
124 serio->dev.driver = &drv->driver; 93 serio->dev.driver = &drv->driver;
125 if (serio_connect_driver(serio, drv)) { 94 if (drv->connect(serio, drv)) {
126 serio->dev.driver = NULL; 95 serio->dev.driver = NULL;
127 goto out; 96 goto out;
128 } 97 }
@@ -169,7 +138,8 @@ struct serio_event {
169static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */ 138static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */
170static LIST_HEAD(serio_event_list); 139static LIST_HEAD(serio_event_list);
171static DECLARE_WAIT_QUEUE_HEAD(serio_wait); 140static DECLARE_WAIT_QUEUE_HEAD(serio_wait);
172static struct task_struct *serio_task; 141static DECLARE_COMPLETION(serio_exited);
142static int serio_pid;
173 143
174static void serio_queue_event(void *object, struct module *owner, 144static void serio_queue_event(void *object, struct module *owner,
175 enum serio_event_type event_type) 145 enum serio_event_type event_type)
@@ -180,12 +150,12 @@ static void serio_queue_event(void *object, struct module *owner,
180 spin_lock_irqsave(&serio_event_lock, flags); 150 spin_lock_irqsave(&serio_event_lock, flags);
181 151
182 /* 152 /*
183 * Scan event list for the other events for the same serio port, 153 * Scan event list for the other events for the same serio port,
184 * starting with the most recent one. If event is the same we 154 * starting with the most recent one. If event is the same we
185 * do not need add new one. If event is of different type we 155 * do not need add new one. If event is of different type we
186 * need to add this event and should not look further because 156 * need to add this event and should not look further because
187 * we need to preseve sequence of distinct events. 157 * we need to preseve sequence of distinct events.
188 */ 158 */
189 list_for_each_entry_reverse(event, &serio_event_list, node) { 159 list_for_each_entry_reverse(event, &serio_event_list, node) {
190 if (event->object == object) { 160 if (event->object == object) {
191 if (event->type == event_type) 161 if (event->type == event_type)
@@ -367,15 +337,20 @@ static struct serio *serio_get_pending_child(struct serio *parent)
367 337
368static int serio_thread(void *nothing) 338static int serio_thread(void *nothing)
369{ 339{
340 lock_kernel();
341 daemonize("kseriod");
342 allow_signal(SIGTERM);
343
370 do { 344 do {
371 serio_handle_events(); 345 serio_handle_events();
372 wait_event_interruptible(serio_wait, 346 wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
373 kthread_should_stop() || !list_empty(&serio_event_list)); 347 try_to_freeze();
374 try_to_freeze(PF_FREEZE); 348 } while (!signal_pending(current));
375 } while (!kthread_should_stop());
376 349
377 printk(KERN_DEBUG "serio: kseriod exiting\n"); 350 printk(KERN_DEBUG "serio: kseriod exiting\n");
378 return 0; 351
352 unlock_kernel();
353 complete_and_exit(&serio_exited, 0);
379} 354}
380 355
381 356
@@ -383,31 +358,31 @@ static int serio_thread(void *nothing)
383 * Serio port operations 358 * Serio port operations
384 */ 359 */
385 360
386static ssize_t serio_show_description(struct device *dev, char *buf) 361static ssize_t serio_show_description(struct device *dev, struct device_attribute *attr, char *buf)
387{ 362{
388 struct serio *serio = to_serio_port(dev); 363 struct serio *serio = to_serio_port(dev);
389 return sprintf(buf, "%s\n", serio->name); 364 return sprintf(buf, "%s\n", serio->name);
390} 365}
391 366
392static ssize_t serio_show_id_type(struct device *dev, char *buf) 367static ssize_t serio_show_id_type(struct device *dev, struct device_attribute *attr, char *buf)
393{ 368{
394 struct serio *serio = to_serio_port(dev); 369 struct serio *serio = to_serio_port(dev);
395 return sprintf(buf, "%02x\n", serio->id.type); 370 return sprintf(buf, "%02x\n", serio->id.type);
396} 371}
397 372
398static ssize_t serio_show_id_proto(struct device *dev, char *buf) 373static ssize_t serio_show_id_proto(struct device *dev, struct device_attribute *attr, char *buf)
399{ 374{
400 struct serio *serio = to_serio_port(dev); 375 struct serio *serio = to_serio_port(dev);
401 return sprintf(buf, "%02x\n", serio->id.proto); 376 return sprintf(buf, "%02x\n", serio->id.proto);
402} 377}
403 378
404static ssize_t serio_show_id_id(struct device *dev, char *buf) 379static ssize_t serio_show_id_id(struct device *dev, struct device_attribute *attr, char *buf)
405{ 380{
406 struct serio *serio = to_serio_port(dev); 381 struct serio *serio = to_serio_port(dev);
407 return sprintf(buf, "%02x\n", serio->id.id); 382 return sprintf(buf, "%02x\n", serio->id.id);
408} 383}
409 384
410static ssize_t serio_show_id_extra(struct device *dev, char *buf) 385static ssize_t serio_show_id_extra(struct device *dev, struct device_attribute *attr, char *buf)
411{ 386{
412 struct serio *serio = to_serio_port(dev); 387 struct serio *serio = to_serio_port(dev);
413 return sprintf(buf, "%02x\n", serio->id.extra); 388 return sprintf(buf, "%02x\n", serio->id.extra);
@@ -431,7 +406,7 @@ static struct attribute_group serio_id_attr_group = {
431 .attrs = serio_device_id_attrs, 406 .attrs = serio_device_id_attrs,
432}; 407};
433 408
434static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t count) 409static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
435{ 410{
436 struct serio *serio = to_serio_port(dev); 411 struct serio *serio = to_serio_port(dev);
437 struct device_driver *drv; 412 struct device_driver *drv;
@@ -462,13 +437,13 @@ static ssize_t serio_rebind_driver(struct device *dev, const char *buf, size_t c
462 return retval; 437 return retval;
463} 438}
464 439
465static ssize_t serio_show_bind_mode(struct device *dev, char *buf) 440static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf)
466{ 441{
467 struct serio *serio = to_serio_port(dev); 442 struct serio *serio = to_serio_port(dev);
468 return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto"); 443 return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto");
469} 444}
470 445
471static ssize_t serio_set_bind_mode(struct device *dev, const char *buf, size_t count) 446static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
472{ 447{
473 struct serio *serio = to_serio_port(dev); 448 struct serio *serio = to_serio_port(dev);
474 int retval; 449 int retval;
@@ -582,7 +557,7 @@ static void serio_destroy_port(struct serio *serio)
582static void serio_reconnect_port(struct serio *serio) 557static void serio_reconnect_port(struct serio *serio)
583{ 558{
584 do { 559 do {
585 if (serio_reconnect_driver(serio)) { 560 if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) {
586 serio_disconnect_port(serio); 561 serio_disconnect_port(serio);
587 serio_find_driver(serio); 562 serio_find_driver(serio);
588 /* Ok, old children are now gone, we are done */ 563 /* Ok, old children are now gone, we are done */
@@ -655,19 +630,6 @@ void serio_unregister_port(struct serio *serio)
655} 630}
656 631
657/* 632/*
658 * Safely unregisters child port if one is present.
659 */
660void serio_unregister_child_port(struct serio *serio)
661{
662 down(&serio_sem);
663 if (serio->child) {
664 serio_disconnect_port(serio->child);
665 serio_destroy_port(serio->child);
666 }
667 up(&serio_sem);
668}
669
670/*
671 * Submits register request to kseriod for subsequent execution. 633 * Submits register request to kseriod for subsequent execution.
672 * Can be used when it is not obvious whether the serio_sem is 634 * Can be used when it is not obvious whether the serio_sem is
673 * taken or not and when delayed execution is feasible. 635 * taken or not and when delayed execution is feasible.
@@ -724,14 +686,15 @@ static int serio_driver_probe(struct device *dev)
724 struct serio *serio = to_serio_port(dev); 686 struct serio *serio = to_serio_port(dev);
725 struct serio_driver *drv = to_serio_driver(dev->driver); 687 struct serio_driver *drv = to_serio_driver(dev->driver);
726 688
727 return serio_connect_driver(serio, drv); 689 return drv->connect(serio, drv);
728} 690}
729 691
730static int serio_driver_remove(struct device *dev) 692static int serio_driver_remove(struct device *dev)
731{ 693{
732 struct serio *serio = to_serio_port(dev); 694 struct serio *serio = to_serio_port(dev);
695 struct serio_driver *drv = to_serio_driver(dev->driver);
733 696
734 serio_disconnect_driver(serio); 697 drv->disconnect(serio);
735 return 0; 698 return 0;
736} 699}
737 700
@@ -767,9 +730,11 @@ start_over:
767 730
768static void serio_set_drv(struct serio *serio, struct serio_driver *drv) 731static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
769{ 732{
733 down(&serio->drv_sem);
770 serio_pause_rx(serio); 734 serio_pause_rx(serio);
771 serio->drv = drv; 735 serio->drv = drv;
772 serio_continue_rx(serio); 736 serio_continue_rx(serio);
737 up(&serio->drv_sem);
773} 738}
774 739
775static int serio_bus_match(struct device *dev, struct device_driver *drv) 740static int serio_bus_match(struct device *dev, struct device_driver *drv)
@@ -829,7 +794,7 @@ static int serio_resume(struct device *dev)
829{ 794{
830 struct serio *serio = to_serio_port(dev); 795 struct serio *serio = to_serio_port(dev);
831 796
832 if (serio_reconnect_driver(serio)) { 797 if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) {
833 /* 798 /*
834 * Driver re-probing can take a while, so better let kseriod 799 * Driver re-probing can take a while, so better let kseriod
835 * deal with it. 800 * deal with it.
@@ -883,10 +848,9 @@ irqreturn_t serio_interrupt(struct serio *serio,
883 848
884static int __init serio_init(void) 849static int __init serio_init(void)
885{ 850{
886 serio_task = kthread_run(serio_thread, NULL, "kseriod"); 851 if (!(serio_pid = kernel_thread(serio_thread, NULL, CLONE_KERNEL))) {
887 if (IS_ERR(serio_task)) {
888 printk(KERN_ERR "serio: Failed to start kseriod\n"); 852 printk(KERN_ERR "serio: Failed to start kseriod\n");
889 return PTR_ERR(serio_task); 853 return -1;
890 } 854 }
891 855
892 serio_bus.dev_attrs = serio_device_attrs; 856 serio_bus.dev_attrs = serio_device_attrs;
@@ -902,7 +866,8 @@ static int __init serio_init(void)
902static void __exit serio_exit(void) 866static void __exit serio_exit(void)
903{ 867{
904 bus_unregister(&serio_bus); 868 bus_unregister(&serio_bus);
905 kthread_stop(serio_task); 869 kill_proc(serio_pid, SIGTERM, 1);
870 wait_for_completion(&serio_exited);
906} 871}
907 872
908module_init(serio_init); 873module_init(serio_init);
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index f6b85222ba3d..79ca38469159 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -257,7 +257,7 @@ static int __init serport_init(void)
257 257
258static void __exit serport_exit(void) 258static void __exit serport_exit(void)
259{ 259{
260 tty_register_ldisc(N_MOUSE, NULL); 260 tty_unregister_ldisc(N_MOUSE);
261} 261}
262 262
263module_init(serport_init); 263module_init(serport_init);
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index d0afba85720b..50c63a155156 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -414,9 +414,9 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
414 S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor); 414 S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor);
415 devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2), 415 devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2),
416 S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor); 416 S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor);
417 class_simple_device_add(input_class, 417 class_device_create(input_class,
418 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), 418 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor),
419 dev->dev, "ts%d", minor); 419 dev->dev, "ts%d", minor);
420 420
421 return &tsdev->handle; 421 return &tsdev->handle;
422} 422}
@@ -426,7 +426,8 @@ static void tsdev_disconnect(struct input_handle *handle)
426 struct tsdev *tsdev = handle->private; 426 struct tsdev *tsdev = handle->private;
427 struct tsdev_list *list; 427 struct tsdev_list *list;
428 428
429 class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); 429 class_device_destroy(input_class,
430 MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor));
430 devfs_remove("input/ts%d", tsdev->minor); 431 devfs_remove("input/ts%d", tsdev->minor);
431 devfs_remove("input/tsraw%d", tsdev->minor); 432 devfs_remove("input/tsraw%d", tsdev->minor);
432 tsdev->exist = 0; 433 tsdev->exist = 0;