aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio/i8042.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/serio/i8042.c')
-rw-r--r--drivers/input/serio/i8042.c242
1 files changed, 142 insertions, 100 deletions
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 582245c497eb..eb3ff94af58c 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -28,35 +28,35 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
28MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver"); 28MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver");
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30 30
31static unsigned int i8042_nokbd; 31static bool i8042_nokbd;
32module_param_named(nokbd, i8042_nokbd, bool, 0); 32module_param_named(nokbd, i8042_nokbd, bool, 0);
33MODULE_PARM_DESC(nokbd, "Do not probe or use KBD port."); 33MODULE_PARM_DESC(nokbd, "Do not probe or use KBD port.");
34 34
35static unsigned int i8042_noaux; 35static bool i8042_noaux;
36module_param_named(noaux, i8042_noaux, bool, 0); 36module_param_named(noaux, i8042_noaux, bool, 0);
37MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); 37MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port.");
38 38
39static unsigned int i8042_nomux; 39static bool i8042_nomux;
40module_param_named(nomux, i8042_nomux, bool, 0); 40module_param_named(nomux, i8042_nomux, bool, 0);
41MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing conrtoller is present."); 41MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing conrtoller is present.");
42 42
43static unsigned int i8042_unlock; 43static bool i8042_unlock;
44module_param_named(unlock, i8042_unlock, bool, 0); 44module_param_named(unlock, i8042_unlock, bool, 0);
45MODULE_PARM_DESC(unlock, "Ignore keyboard lock."); 45MODULE_PARM_DESC(unlock, "Ignore keyboard lock.");
46 46
47static unsigned int i8042_reset; 47static bool i8042_reset;
48module_param_named(reset, i8042_reset, bool, 0); 48module_param_named(reset, i8042_reset, bool, 0);
49MODULE_PARM_DESC(reset, "Reset controller during init and cleanup."); 49MODULE_PARM_DESC(reset, "Reset controller during init and cleanup.");
50 50
51static unsigned int i8042_direct; 51static bool i8042_direct;
52module_param_named(direct, i8042_direct, bool, 0); 52module_param_named(direct, i8042_direct, bool, 0);
53MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode."); 53MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode.");
54 54
55static unsigned int i8042_dumbkbd; 55static bool i8042_dumbkbd;
56module_param_named(dumbkbd, i8042_dumbkbd, bool, 0); 56module_param_named(dumbkbd, i8042_dumbkbd, bool, 0);
57MODULE_PARM_DESC(dumbkbd, "Pretend that controller can only read data from keyboard"); 57MODULE_PARM_DESC(dumbkbd, "Pretend that controller can only read data from keyboard");
58 58
59static unsigned int i8042_noloop; 59static bool i8042_noloop;
60module_param_named(noloop, i8042_noloop, bool, 0); 60module_param_named(noloop, i8042_noloop, bool, 0);
61MODULE_PARM_DESC(noloop, "Disable the AUX Loopback command while probing for the AUX port"); 61MODULE_PARM_DESC(noloop, "Disable the AUX Loopback command while probing for the AUX port");
62 62
@@ -65,24 +65,26 @@ module_param_named(panicblink, i8042_blink_frequency, uint, 0600);
65MODULE_PARM_DESC(panicblink, "Frequency with which keyboard LEDs should blink when kernel panics"); 65MODULE_PARM_DESC(panicblink, "Frequency with which keyboard LEDs should blink when kernel panics");
66 66
67#ifdef CONFIG_X86 67#ifdef CONFIG_X86
68static unsigned int i8042_dritek; 68static bool i8042_dritek;
69module_param_named(dritek, i8042_dritek, bool, 0); 69module_param_named(dritek, i8042_dritek, bool, 0);
70MODULE_PARM_DESC(dritek, "Force enable the Dritek keyboard extension"); 70MODULE_PARM_DESC(dritek, "Force enable the Dritek keyboard extension");
71#endif 71#endif
72 72
73#ifdef CONFIG_PNP 73#ifdef CONFIG_PNP
74static int i8042_nopnp; 74static bool i8042_nopnp;
75module_param_named(nopnp, i8042_nopnp, bool, 0); 75module_param_named(nopnp, i8042_nopnp, bool, 0);
76MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings"); 76MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
77#endif 77#endif
78 78
79#define DEBUG 79#define DEBUG
80#ifdef DEBUG 80#ifdef DEBUG
81static int i8042_debug; 81static bool i8042_debug;
82module_param_named(debug, i8042_debug, bool, 0600); 82module_param_named(debug, i8042_debug, bool, 0600);
83MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off"); 83MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off");
84#endif 84#endif
85 85
86static bool i8042_bypass_aux_irq_test;
87
86#include "i8042.h" 88#include "i8042.h"
87 89
88static DEFINE_SPINLOCK(i8042_lock); 90static DEFINE_SPINLOCK(i8042_lock);
@@ -90,7 +92,7 @@ static DEFINE_SPINLOCK(i8042_lock);
90struct i8042_port { 92struct i8042_port {
91 struct serio *serio; 93 struct serio *serio;
92 int irq; 94 int irq;
93 unsigned char exists; 95 bool exists;
94 signed char mux; 96 signed char mux;
95}; 97};
96 98
@@ -103,9 +105,9 @@ static struct i8042_port i8042_ports[I8042_NUM_PORTS];
103 105
104static unsigned char i8042_initial_ctr; 106static unsigned char i8042_initial_ctr;
105static unsigned char i8042_ctr; 107static unsigned char i8042_ctr;
106static unsigned char i8042_mux_present; 108static bool i8042_mux_present;
107static unsigned char i8042_kbd_irq_registered; 109static bool i8042_kbd_irq_registered;
108static unsigned char i8042_aux_irq_registered; 110static bool i8042_aux_irq_registered;
109static unsigned char i8042_suppress_kbd_ack; 111static unsigned char i8042_suppress_kbd_ack;
110static struct platform_device *i8042_platform_device; 112static struct platform_device *i8042_platform_device;
111 113
@@ -262,6 +264,49 @@ static int i8042_aux_write(struct serio *serio, unsigned char c)
262 I8042_CMD_MUX_SEND + port->mux); 264 I8042_CMD_MUX_SEND + port->mux);
263} 265}
264 266
267
268/*
269 * i8042_aux_close attempts to clear AUX or KBD port state by disabling
270 * and then re-enabling it.
271 */
272
273static void i8042_port_close(struct serio *serio)
274{
275 int irq_bit;
276 int disable_bit;
277 const char *port_name;
278
279 if (serio == i8042_ports[I8042_AUX_PORT_NO].serio) {
280 irq_bit = I8042_CTR_AUXINT;
281 disable_bit = I8042_CTR_AUXDIS;
282 port_name = "AUX";
283 } else {
284 irq_bit = I8042_CTR_KBDINT;
285 disable_bit = I8042_CTR_KBDDIS;
286 port_name = "KBD";
287 }
288
289 i8042_ctr &= ~irq_bit;
290 if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR))
291 printk(KERN_WARNING
292 "i8042.c: Can't write CTR while closing %s port.\n",
293 port_name);
294
295 udelay(50);
296
297 i8042_ctr &= ~disable_bit;
298 i8042_ctr |= irq_bit;
299 if (i8042_command(&i8042_ctr, I8042_CMD_CTL_WCTR))
300 printk(KERN_ERR "i8042.c: Can't reactivate %s port.\n",
301 port_name);
302
303 /*
304 * See if there is any data appeared while we were messing with
305 * port state.
306 */
307 i8042_interrupt(0, NULL);
308}
309
265/* 310/*
266 * i8042_start() is called by serio core when port is about to finish 311 * i8042_start() is called by serio core when port is about to finish
267 * registering. It will mark port as existing so i8042_interrupt can 312 * registering. It will mark port as existing so i8042_interrupt can
@@ -271,7 +316,7 @@ static int i8042_start(struct serio *serio)
271{ 316{
272 struct i8042_port *port = serio->port_data; 317 struct i8042_port *port = serio->port_data;
273 318
274 port->exists = 1; 319 port->exists = true;
275 mb(); 320 mb();
276 return 0; 321 return 0;
277} 322}
@@ -285,7 +330,7 @@ static void i8042_stop(struct serio *serio)
285{ 330{
286 struct i8042_port *port = serio->port_data; 331 struct i8042_port *port = serio->port_data;
287 332
288 port->exists = 0; 333 port->exists = false;
289 334
290 /* 335 /*
291 * We synchronize with both AUX and KBD IRQs because there is 336 * We synchronize with both AUX and KBD IRQs because there is
@@ -391,7 +436,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
391} 436}
392 437
393/* 438/*
394 * i8042_enable_kbd_port enables keybaord port on chip 439 * i8042_enable_kbd_port enables keyboard port on chip
395 */ 440 */
396 441
397static int i8042_enable_kbd_port(void) 442static int i8042_enable_kbd_port(void)
@@ -447,14 +492,15 @@ static int i8042_enable_mux_ports(void)
447} 492}
448 493
449/* 494/*
450 * i8042_set_mux_mode checks whether the controller has an active 495 * i8042_set_mux_mode checks whether the controller has an
451 * multiplexor and puts the chip into Multiplexed (1) or Legacy (0) mode. 496 * active multiplexor and puts the chip into Multiplexed (true)
497 * or Legacy (false) mode.
452 */ 498 */
453 499
454static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version) 500static int i8042_set_mux_mode(bool multiplex, unsigned char *mux_version)
455{ 501{
456 502
457 unsigned char param; 503 unsigned char param, val;
458/* 504/*
459 * Get rid of bytes in the queue. 505 * Get rid of bytes in the queue.
460 */ 506 */
@@ -466,14 +512,21 @@ static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version)
466 * mouse interface, the last should be version. 512 * mouse interface, the last should be version.
467 */ 513 */
468 514
469 param = 0xf0; 515 param = val = 0xf0;
470 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != 0xf0) 516 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != val)
471 return -1; 517 return -1;
472 param = mode ? 0x56 : 0xf6; 518 param = val = multiplex ? 0x56 : 0xf6;
473 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != (mode ? 0x56 : 0xf6)) 519 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param != val)
474 return -1; 520 return -1;
475 param = mode ? 0xa4 : 0xa5; 521 param = val = multiplex ? 0xa4 : 0xa5;
476 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param == (mode ? 0xa4 : 0xa5)) 522 if (i8042_command(&param, I8042_CMD_AUX_LOOP) || param == val)
523 return -1;
524
525/*
526 * Workaround for interference with USB Legacy emulation
527 * that causes a v10.12 MUX to be found.
528 */
529 if (param == 0xac)
477 return -1; 530 return -1;
478 531
479 if (mux_version) 532 if (mux_version)
@@ -488,18 +541,11 @@ static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version)
488 * LCS/Telegraphics. 541 * LCS/Telegraphics.
489 */ 542 */
490 543
491static int __devinit i8042_check_mux(void) 544static int __init i8042_check_mux(void)
492{ 545{
493 unsigned char mux_version; 546 unsigned char mux_version;
494 547
495 if (i8042_set_mux_mode(1, &mux_version)) 548 if (i8042_set_mux_mode(true, &mux_version))
496 return -1;
497
498/*
499 * Workaround for interference with USB Legacy emulation
500 * that causes a v10.12 MUX to be found.
501 */
502 if (mux_version == 0xAC)
503 return -1; 549 return -1;
504 550
505 printk(KERN_INFO "i8042.c: Detected active multiplexing controller, rev %d.%d.\n", 551 printk(KERN_INFO "i8042.c: Detected active multiplexing controller, rev %d.%d.\n",
@@ -516,7 +562,7 @@ static int __devinit i8042_check_mux(void)
516 return -EIO; 562 return -EIO;
517 } 563 }
518 564
519 i8042_mux_present = 1; 565 i8042_mux_present = true;
520 566
521 return 0; 567 return 0;
522} 568}
@@ -524,10 +570,10 @@ static int __devinit i8042_check_mux(void)
524/* 570/*
525 * The following is used to test AUX IRQ delivery. 571 * The following is used to test AUX IRQ delivery.
526 */ 572 */
527static struct completion i8042_aux_irq_delivered __devinitdata; 573static struct completion i8042_aux_irq_delivered __initdata;
528static int i8042_irq_being_tested __devinitdata; 574static bool i8042_irq_being_tested __initdata;
529 575
530static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id) 576static irqreturn_t __init i8042_aux_test_irq(int irq, void *dev_id)
531{ 577{
532 unsigned long flags; 578 unsigned long flags;
533 unsigned char str, data; 579 unsigned char str, data;
@@ -552,7 +598,7 @@ static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id)
552 * verifies success by readinng CTR. Used when testing for presence of AUX 598 * verifies success by readinng CTR. Used when testing for presence of AUX
553 * port. 599 * port.
554 */ 600 */
555static int __devinit i8042_toggle_aux(int on) 601static int __init i8042_toggle_aux(bool on)
556{ 602{
557 unsigned char param; 603 unsigned char param;
558 int i; 604 int i;
@@ -580,11 +626,11 @@ static int __devinit i8042_toggle_aux(int on)
580 * the presence of an AUX interface. 626 * the presence of an AUX interface.
581 */ 627 */
582 628
583static int __devinit i8042_check_aux(void) 629static int __init i8042_check_aux(void)
584{ 630{
585 int retval = -1; 631 int retval = -1;
586 int irq_registered = 0; 632 bool irq_registered = false;
587 int aux_loop_broken = 0; 633 bool aux_loop_broken = false;
588 unsigned long flags; 634 unsigned long flags;
589 unsigned char param; 635 unsigned char param;
590 636
@@ -621,19 +667,19 @@ static int __devinit i8042_check_aux(void)
621 * mark it as broken 667 * mark it as broken
622 */ 668 */
623 if (!retval) 669 if (!retval)
624 aux_loop_broken = 1; 670 aux_loop_broken = true;
625 } 671 }
626 672
627/* 673/*
628 * Bit assignment test - filters out PS/2 i8042's in AT mode 674 * Bit assignment test - filters out PS/2 i8042's in AT mode
629 */ 675 */
630 676
631 if (i8042_toggle_aux(0)) { 677 if (i8042_toggle_aux(false)) {
632 printk(KERN_WARNING "Failed to disable AUX port, but continuing anyway... Is this a SiS?\n"); 678 printk(KERN_WARNING "Failed to disable AUX port, but continuing anyway... Is this a SiS?\n");
633 printk(KERN_WARNING "If AUX port is really absent please use the 'i8042.noaux' option.\n"); 679 printk(KERN_WARNING "If AUX port is really absent please use the 'i8042.noaux' option.\n");
634 } 680 }
635 681
636 if (i8042_toggle_aux(1)) 682 if (i8042_toggle_aux(true))
637 return -1; 683 return -1;
638 684
639/* 685/*
@@ -641,7 +687,7 @@ static int __devinit i8042_check_aux(void)
641 * used it for a PCI card or somethig else. 687 * used it for a PCI card or somethig else.
642 */ 688 */
643 689
644 if (i8042_noloop || aux_loop_broken) { 690 if (i8042_noloop || i8042_bypass_aux_irq_test || aux_loop_broken) {
645/* 691/*
646 * Without LOOP command we can't test AUX IRQ delivery. Assume the port 692 * Without LOOP command we can't test AUX IRQ delivery. Assume the port
647 * is working and hope we are right. 693 * is working and hope we are right.
@@ -654,7 +700,7 @@ static int __devinit i8042_check_aux(void)
654 "i8042", i8042_platform_device)) 700 "i8042", i8042_platform_device))
655 goto out; 701 goto out;
656 702
657 irq_registered = 1; 703 irq_registered = true;
658 704
659 if (i8042_enable_aux_port()) 705 if (i8042_enable_aux_port())
660 goto out; 706 goto out;
@@ -662,7 +708,7 @@ static int __devinit i8042_check_aux(void)
662 spin_lock_irqsave(&i8042_lock, flags); 708 spin_lock_irqsave(&i8042_lock, flags);
663 709
664 init_completion(&i8042_aux_irq_delivered); 710 init_completion(&i8042_aux_irq_delivered);
665 i8042_irq_being_tested = 1; 711 i8042_irq_being_tested = true;
666 712
667 param = 0xa5; 713 param = 0xa5;
668 retval = __i8042_command(&param, I8042_CMD_AUX_LOOP & 0xf0ff); 714 retval = __i8042_command(&param, I8042_CMD_AUX_LOOP & 0xf0ff);
@@ -799,7 +845,7 @@ static int i8042_controller_init(void)
799 */ 845 */
800 846
801 if (~i8042_ctr & I8042_CTR_XLATE) 847 if (~i8042_ctr & I8042_CTR_XLATE)
802 i8042_direct = 1; 848 i8042_direct = true;
803 849
804/* 850/*
805 * Set nontranslated mode for the kbd interface if requested by an option. 851 * Set nontranslated mode for the kbd interface if requested by an option.
@@ -839,12 +885,15 @@ static void i8042_controller_reset(void)
839 i8042_ctr |= I8042_CTR_KBDDIS | I8042_CTR_AUXDIS; 885 i8042_ctr |= I8042_CTR_KBDDIS | I8042_CTR_AUXDIS;
840 i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT); 886 i8042_ctr &= ~(I8042_CTR_KBDINT | I8042_CTR_AUXINT);
841 887
888 if (i8042_command(&i8042_initial_ctr, I8042_CMD_CTL_WCTR))
889 printk(KERN_WARNING "i8042.c: Can't write CTR while resetting.\n");
890
842/* 891/*
843 * Disable MUX mode if present. 892 * Disable MUX mode if present.
844 */ 893 */
845 894
846 if (i8042_mux_present) 895 if (i8042_mux_present)
847 i8042_set_mux_mode(0, NULL); 896 i8042_set_mux_mode(false, NULL);
848 897
849/* 898/*
850 * Reset the controller if requested. 899 * Reset the controller if requested.
@@ -923,41 +972,27 @@ static void i8042_dritek_enable(void)
923 972
924#ifdef CONFIG_PM 973#ifdef CONFIG_PM
925 974
926static bool i8042_suspended;
927
928/* 975/*
929 * Here we try to restore the original BIOS settings. We only want to 976 * Here we try to restore the original BIOS settings to avoid
930 * do that once, when we really suspend, not when we taking memory 977 * upsetting it.
931 * snapshot for swsusp (in this case we'll perform required cleanup
932 * as part of shutdown process).
933 */ 978 */
934 979
935static int i8042_suspend(struct platform_device *dev, pm_message_t state) 980static int i8042_pm_reset(struct device *dev)
936{ 981{
937 if (!i8042_suspended && state.event == PM_EVENT_SUSPEND) 982 i8042_controller_reset();
938 i8042_controller_reset();
939
940 i8042_suspended = state.event == PM_EVENT_SUSPEND ||
941 state.event == PM_EVENT_FREEZE;
942 983
943 return 0; 984 return 0;
944} 985}
945 986
946
947/* 987/*
948 * Here we try to reset everything back to a state in which suspended 988 * Here we try to reset everything back to a state we had
989 * before suspending.
949 */ 990 */
950 991
951static int i8042_resume(struct platform_device *dev) 992static int i8042_pm_restore(struct device *dev)
952{ 993{
953 int error; 994 int error;
954 995
955/*
956 * Do not bother with restoring state if we haven't suspened yet
957 */
958 if (!i8042_suspended)
959 return 0;
960
961 error = i8042_controller_check(); 996 error = i8042_controller_check();
962 if (error) 997 if (error)
963 return error; 998 return error;
@@ -991,7 +1026,7 @@ static int i8042_resume(struct platform_device *dev)
991#endif 1026#endif
992 1027
993 if (i8042_mux_present) { 1028 if (i8042_mux_present) {
994 if (i8042_set_mux_mode(1, NULL) || i8042_enable_mux_ports()) 1029 if (i8042_set_mux_mode(true, NULL) || i8042_enable_mux_ports())
995 printk(KERN_WARNING 1030 printk(KERN_WARNING
996 "i8042: failed to resume active multiplexor, " 1031 "i8042: failed to resume active multiplexor, "
997 "mouse won't work.\n"); 1032 "mouse won't work.\n");
@@ -1001,11 +1036,18 @@ static int i8042_resume(struct platform_device *dev)
1001 if (i8042_ports[I8042_KBD_PORT_NO].serio) 1036 if (i8042_ports[I8042_KBD_PORT_NO].serio)
1002 i8042_enable_kbd_port(); 1037 i8042_enable_kbd_port();
1003 1038
1004 i8042_suspended = false;
1005 i8042_interrupt(0, NULL); 1039 i8042_interrupt(0, NULL);
1006 1040
1007 return 0; 1041 return 0;
1008} 1042}
1043
1044static const struct dev_pm_ops i8042_pm_ops = {
1045 .suspend = i8042_pm_reset,
1046 .resume = i8042_pm_restore,
1047 .poweroff = i8042_pm_reset,
1048 .restore = i8042_pm_restore,
1049};
1050
1009#endif /* CONFIG_PM */ 1051#endif /* CONFIG_PM */
1010 1052
1011/* 1053/*
@@ -1018,7 +1060,7 @@ static void i8042_shutdown(struct platform_device *dev)
1018 i8042_controller_reset(); 1060 i8042_controller_reset();
1019} 1061}
1020 1062
1021static int __devinit i8042_create_kbd_port(void) 1063static int __init i8042_create_kbd_port(void)
1022{ 1064{
1023 struct serio *serio; 1065 struct serio *serio;
1024 struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO]; 1066 struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO];
@@ -1031,6 +1073,7 @@ static int __devinit i8042_create_kbd_port(void)
1031 serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; 1073 serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write;
1032 serio->start = i8042_start; 1074 serio->start = i8042_start;
1033 serio->stop = i8042_stop; 1075 serio->stop = i8042_stop;
1076 serio->close = i8042_port_close;
1034 serio->port_data = port; 1077 serio->port_data = port;
1035 serio->dev.parent = &i8042_platform_device->dev; 1078 serio->dev.parent = &i8042_platform_device->dev;
1036 strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name)); 1079 strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name));
@@ -1042,7 +1085,7 @@ static int __devinit i8042_create_kbd_port(void)
1042 return 0; 1085 return 0;
1043} 1086}
1044 1087
1045static int __devinit i8042_create_aux_port(int idx) 1088static int __init i8042_create_aux_port(int idx)
1046{ 1089{
1047 struct serio *serio; 1090 struct serio *serio;
1048 int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx; 1091 int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx;
@@ -1061,6 +1104,7 @@ static int __devinit i8042_create_aux_port(int idx)
1061 if (idx < 0) { 1104 if (idx < 0) {
1062 strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name)); 1105 strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name));
1063 strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); 1106 strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys));
1107 serio->close = i8042_port_close;
1064 } else { 1108 } else {
1065 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); 1109 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx);
1066 snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, idx + 1); 1110 snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, idx + 1);
@@ -1073,13 +1117,13 @@ static int __devinit i8042_create_aux_port(int idx)
1073 return 0; 1117 return 0;
1074} 1118}
1075 1119
1076static void __devinit i8042_free_kbd_port(void) 1120static void __init i8042_free_kbd_port(void)
1077{ 1121{
1078 kfree(i8042_ports[I8042_KBD_PORT_NO].serio); 1122 kfree(i8042_ports[I8042_KBD_PORT_NO].serio);
1079 i8042_ports[I8042_KBD_PORT_NO].serio = NULL; 1123 i8042_ports[I8042_KBD_PORT_NO].serio = NULL;
1080} 1124}
1081 1125
1082static void __devinit i8042_free_aux_ports(void) 1126static void __init i8042_free_aux_ports(void)
1083{ 1127{
1084 int i; 1128 int i;
1085 1129
@@ -1089,7 +1133,7 @@ static void __devinit i8042_free_aux_ports(void)
1089 } 1133 }
1090} 1134}
1091 1135
1092static void __devinit i8042_register_ports(void) 1136static void __init i8042_register_ports(void)
1093{ 1137{
1094 int i; 1138 int i;
1095 1139
@@ -1124,10 +1168,10 @@ static void i8042_free_irqs(void)
1124 if (i8042_kbd_irq_registered) 1168 if (i8042_kbd_irq_registered)
1125 free_irq(I8042_KBD_IRQ, i8042_platform_device); 1169 free_irq(I8042_KBD_IRQ, i8042_platform_device);
1126 1170
1127 i8042_aux_irq_registered = i8042_kbd_irq_registered = 0; 1171 i8042_aux_irq_registered = i8042_kbd_irq_registered = false;
1128} 1172}
1129 1173
1130static int __devinit i8042_setup_aux(void) 1174static int __init i8042_setup_aux(void)
1131{ 1175{
1132 int (*aux_enable)(void); 1176 int (*aux_enable)(void);
1133 int error; 1177 int error;
@@ -1158,7 +1202,7 @@ static int __devinit i8042_setup_aux(void)
1158 if (aux_enable()) 1202 if (aux_enable())
1159 goto err_free_irq; 1203 goto err_free_irq;
1160 1204
1161 i8042_aux_irq_registered = 1; 1205 i8042_aux_irq_registered = true;
1162 return 0; 1206 return 0;
1163 1207
1164 err_free_irq: 1208 err_free_irq:
@@ -1168,7 +1212,7 @@ static int __devinit i8042_setup_aux(void)
1168 return error; 1212 return error;
1169} 1213}
1170 1214
1171static int __devinit i8042_setup_kbd(void) 1215static int __init i8042_setup_kbd(void)
1172{ 1216{
1173 int error; 1217 int error;
1174 1218
@@ -1185,7 +1229,7 @@ static int __devinit i8042_setup_kbd(void)
1185 if (error) 1229 if (error)
1186 goto err_free_irq; 1230 goto err_free_irq;
1187 1231
1188 i8042_kbd_irq_registered = 1; 1232 i8042_kbd_irq_registered = true;
1189 return 0; 1233 return 0;
1190 1234
1191 err_free_irq: 1235 err_free_irq:
@@ -1195,7 +1239,7 @@ static int __devinit i8042_setup_kbd(void)
1195 return error; 1239 return error;
1196} 1240}
1197 1241
1198static int __devinit i8042_probe(struct platform_device *dev) 1242static int __init i8042_probe(struct platform_device *dev)
1199{ 1243{
1200 int error; 1244 int error;
1201 1245
@@ -1251,14 +1295,12 @@ static struct platform_driver i8042_driver = {
1251 .driver = { 1295 .driver = {
1252 .name = "i8042", 1296 .name = "i8042",
1253 .owner = THIS_MODULE, 1297 .owner = THIS_MODULE,
1298#ifdef CONFIG_PM
1299 .pm = &i8042_pm_ops,
1300#endif
1254 }, 1301 },
1255 .probe = i8042_probe,
1256 .remove = __devexit_p(i8042_remove), 1302 .remove = __devexit_p(i8042_remove),
1257 .shutdown = i8042_shutdown, 1303 .shutdown = i8042_shutdown,
1258#ifdef CONFIG_PM
1259 .suspend = i8042_suspend,
1260 .resume = i8042_resume,
1261#endif
1262}; 1304};
1263 1305
1264static int __init i8042_init(void) 1306static int __init i8042_init(void)
@@ -1275,28 +1317,28 @@ static int __init i8042_init(void)
1275 if (err) 1317 if (err)
1276 goto err_platform_exit; 1318 goto err_platform_exit;
1277 1319
1278 err = platform_driver_register(&i8042_driver);
1279 if (err)
1280 goto err_platform_exit;
1281
1282 i8042_platform_device = platform_device_alloc("i8042", -1); 1320 i8042_platform_device = platform_device_alloc("i8042", -1);
1283 if (!i8042_platform_device) { 1321 if (!i8042_platform_device) {
1284 err = -ENOMEM; 1322 err = -ENOMEM;
1285 goto err_unregister_driver; 1323 goto err_platform_exit;
1286 } 1324 }
1287 1325
1288 err = platform_device_add(i8042_platform_device); 1326 err = platform_device_add(i8042_platform_device);
1289 if (err) 1327 if (err)
1290 goto err_free_device; 1328 goto err_free_device;
1291 1329
1330 err = platform_driver_probe(&i8042_driver, i8042_probe);
1331 if (err)
1332 goto err_del_device;
1333
1292 panic_blink = i8042_panic_blink; 1334 panic_blink = i8042_panic_blink;
1293 1335
1294 return 0; 1336 return 0;
1295 1337
1338 err_del_device:
1339 platform_device_del(i8042_platform_device);
1296 err_free_device: 1340 err_free_device:
1297 platform_device_put(i8042_platform_device); 1341 platform_device_put(i8042_platform_device);
1298 err_unregister_driver:
1299 platform_driver_unregister(&i8042_driver);
1300 err_platform_exit: 1342 err_platform_exit:
1301 i8042_platform_exit(); 1343 i8042_platform_exit();
1302 1344
@@ -1305,8 +1347,8 @@ static int __init i8042_init(void)
1305 1347
1306static void __exit i8042_exit(void) 1348static void __exit i8042_exit(void)
1307{ 1349{
1308 platform_device_unregister(i8042_platform_device);
1309 platform_driver_unregister(&i8042_driver); 1350 platform_driver_unregister(&i8042_driver);
1351 platform_device_unregister(i8042_platform_device);
1310 i8042_platform_exit(); 1352 i8042_platform_exit();
1311 1353
1312 panic_blink = NULL; 1354 panic_blink = NULL;