diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-09-09 22:08:16 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-09-11 01:11:36 -0400 |
commit | 386b384900a200d5fcabdd4a9c27eb21db606cd4 (patch) | |
tree | 5aff549948b9df8fd1f05853856cf174be0c8d1c /drivers/input/serio/i8042.c | |
parent | 5ddbc77c3eb54336fcd44b7b66b44784d65677e2 (diff) |
Input: i8042 - use boolean type where it makes sense
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/serio/i8042.c')
-rw-r--r-- | drivers/input/serio/i8042.c | 103 |
1 files changed, 52 insertions, 51 deletions
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 8aaf8fcacf62..61ed7a966c60 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c | |||
@@ -28,35 +28,35 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); | |||
28 | MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver"); | 28 | MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver"); |
29 | MODULE_LICENSE("GPL"); | 29 | MODULE_LICENSE("GPL"); |
30 | 30 | ||
31 | static unsigned int i8042_nokbd; | 31 | static bool i8042_nokbd; |
32 | module_param_named(nokbd, i8042_nokbd, bool, 0); | 32 | module_param_named(nokbd, i8042_nokbd, bool, 0); |
33 | MODULE_PARM_DESC(nokbd, "Do not probe or use KBD port."); | 33 | MODULE_PARM_DESC(nokbd, "Do not probe or use KBD port."); |
34 | 34 | ||
35 | static unsigned int i8042_noaux; | 35 | static bool i8042_noaux; |
36 | module_param_named(noaux, i8042_noaux, bool, 0); | 36 | module_param_named(noaux, i8042_noaux, bool, 0); |
37 | MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); | 37 | MODULE_PARM_DESC(noaux, "Do not probe or use AUX (mouse) port."); |
38 | 38 | ||
39 | static unsigned int i8042_nomux; | 39 | static bool i8042_nomux; |
40 | module_param_named(nomux, i8042_nomux, bool, 0); | 40 | module_param_named(nomux, i8042_nomux, bool, 0); |
41 | MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing conrtoller is present."); | 41 | MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing conrtoller is present."); |
42 | 42 | ||
43 | static unsigned int i8042_unlock; | 43 | static bool i8042_unlock; |
44 | module_param_named(unlock, i8042_unlock, bool, 0); | 44 | module_param_named(unlock, i8042_unlock, bool, 0); |
45 | MODULE_PARM_DESC(unlock, "Ignore keyboard lock."); | 45 | MODULE_PARM_DESC(unlock, "Ignore keyboard lock."); |
46 | 46 | ||
47 | static unsigned int i8042_reset; | 47 | static bool i8042_reset; |
48 | module_param_named(reset, i8042_reset, bool, 0); | 48 | module_param_named(reset, i8042_reset, bool, 0); |
49 | MODULE_PARM_DESC(reset, "Reset controller during init and cleanup."); | 49 | MODULE_PARM_DESC(reset, "Reset controller during init and cleanup."); |
50 | 50 | ||
51 | static unsigned int i8042_direct; | 51 | static bool i8042_direct; |
52 | module_param_named(direct, i8042_direct, bool, 0); | 52 | module_param_named(direct, i8042_direct, bool, 0); |
53 | MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode."); | 53 | MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode."); |
54 | 54 | ||
55 | static unsigned int i8042_dumbkbd; | 55 | static bool i8042_dumbkbd; |
56 | module_param_named(dumbkbd, i8042_dumbkbd, bool, 0); | 56 | module_param_named(dumbkbd, i8042_dumbkbd, bool, 0); |
57 | MODULE_PARM_DESC(dumbkbd, "Pretend that controller can only read data from keyboard"); | 57 | MODULE_PARM_DESC(dumbkbd, "Pretend that controller can only read data from keyboard"); |
58 | 58 | ||
59 | static unsigned int i8042_noloop; | 59 | static bool i8042_noloop; |
60 | module_param_named(noloop, i8042_noloop, bool, 0); | 60 | module_param_named(noloop, i8042_noloop, bool, 0); |
61 | MODULE_PARM_DESC(noloop, "Disable the AUX Loopback command while probing for the AUX port"); | 61 | MODULE_PARM_DESC(noloop, "Disable the AUX Loopback command while probing for the AUX port"); |
62 | 62 | ||
@@ -65,20 +65,20 @@ module_param_named(panicblink, i8042_blink_frequency, uint, 0600); | |||
65 | MODULE_PARM_DESC(panicblink, "Frequency with which keyboard LEDs should blink when kernel panics"); | 65 | MODULE_PARM_DESC(panicblink, "Frequency with which keyboard LEDs should blink when kernel panics"); |
66 | 66 | ||
67 | #ifdef CONFIG_X86 | 67 | #ifdef CONFIG_X86 |
68 | static unsigned int i8042_dritek; | 68 | static bool i8042_dritek; |
69 | module_param_named(dritek, i8042_dritek, bool, 0); | 69 | module_param_named(dritek, i8042_dritek, bool, 0); |
70 | MODULE_PARM_DESC(dritek, "Force enable the Dritek keyboard extension"); | 70 | MODULE_PARM_DESC(dritek, "Force enable the Dritek keyboard extension"); |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #ifdef CONFIG_PNP | 73 | #ifdef CONFIG_PNP |
74 | static int i8042_nopnp; | 74 | static bool i8042_nopnp; |
75 | module_param_named(nopnp, i8042_nopnp, bool, 0); | 75 | module_param_named(nopnp, i8042_nopnp, bool, 0); |
76 | MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings"); | 76 | MODULE_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 |
81 | static int i8042_debug; | 81 | static bool i8042_debug; |
82 | module_param_named(debug, i8042_debug, bool, 0600); | 82 | module_param_named(debug, i8042_debug, bool, 0600); |
83 | MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off"); | 83 | MODULE_PARM_DESC(debug, "Turn i8042 debugging mode on and off"); |
84 | #endif | 84 | #endif |
@@ -92,7 +92,7 @@ static DEFINE_SPINLOCK(i8042_lock); | |||
92 | struct i8042_port { | 92 | struct i8042_port { |
93 | struct serio *serio; | 93 | struct serio *serio; |
94 | int irq; | 94 | int irq; |
95 | unsigned char exists; | 95 | bool exists; |
96 | signed char mux; | 96 | signed char mux; |
97 | }; | 97 | }; |
98 | 98 | ||
@@ -105,9 +105,9 @@ static struct i8042_port i8042_ports[I8042_NUM_PORTS]; | |||
105 | 105 | ||
106 | static unsigned char i8042_initial_ctr; | 106 | static unsigned char i8042_initial_ctr; |
107 | static unsigned char i8042_ctr; | 107 | static unsigned char i8042_ctr; |
108 | static unsigned char i8042_mux_present; | 108 | static bool i8042_mux_present; |
109 | static unsigned char i8042_kbd_irq_registered; | 109 | static bool i8042_kbd_irq_registered; |
110 | static unsigned char i8042_aux_irq_registered; | 110 | static bool i8042_aux_irq_registered; |
111 | static unsigned char i8042_suppress_kbd_ack; | 111 | static unsigned char i8042_suppress_kbd_ack; |
112 | static struct platform_device *i8042_platform_device; | 112 | static struct platform_device *i8042_platform_device; |
113 | 113 | ||
@@ -316,7 +316,7 @@ static int i8042_start(struct serio *serio) | |||
316 | { | 316 | { |
317 | struct i8042_port *port = serio->port_data; | 317 | struct i8042_port *port = serio->port_data; |
318 | 318 | ||
319 | port->exists = 1; | 319 | port->exists = true; |
320 | mb(); | 320 | mb(); |
321 | return 0; | 321 | return 0; |
322 | } | 322 | } |
@@ -330,7 +330,7 @@ static void i8042_stop(struct serio *serio) | |||
330 | { | 330 | { |
331 | struct i8042_port *port = serio->port_data; | 331 | struct i8042_port *port = serio->port_data; |
332 | 332 | ||
333 | port->exists = 0; | 333 | port->exists = false; |
334 | 334 | ||
335 | /* | 335 | /* |
336 | * We synchronize with both AUX and KBD IRQs because there is | 336 | * We synchronize with both AUX and KBD IRQs because there is |
@@ -492,14 +492,15 @@ static int i8042_enable_mux_ports(void) | |||
492 | } | 492 | } |
493 | 493 | ||
494 | /* | 494 | /* |
495 | * i8042_set_mux_mode checks whether the controller has an active | 495 | * i8042_set_mux_mode checks whether the controller has an |
496 | * 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. | ||
497 | */ | 498 | */ |
498 | 499 | ||
499 | static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version) | 500 | static int i8042_set_mux_mode(bool multiplex, unsigned char *mux_version) |
500 | { | 501 | { |
501 | 502 | ||
502 | unsigned char param; | 503 | unsigned char param, val; |
503 | /* | 504 | /* |
504 | * Get rid of bytes in the queue. | 505 | * Get rid of bytes in the queue. |
505 | */ | 506 | */ |
@@ -511,14 +512,21 @@ static int i8042_set_mux_mode(unsigned int mode, unsigned char *mux_version) | |||
511 | * mouse interface, the last should be version. | 512 | * mouse interface, the last should be version. |
512 | */ | 513 | */ |
513 | 514 | ||
514 | param = 0xf0; | 515 | param = val = 0xf0; |
515 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != 0xf0) | 516 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != val) |
517 | return -1; | ||
518 | param = val = multiplex ? 0x56 : 0xf6; | ||
519 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != val) | ||
516 | return -1; | 520 | return -1; |
517 | param = mode ? 0x56 : 0xf6; | 521 | param = val = multiplex ? 0xa4 : 0xa5; |
518 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param != (mode ? 0x56 : 0xf6)) | 522 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param == val) |
519 | return -1; | 523 | return -1; |
520 | param = mode ? 0xa4 : 0xa5; | 524 | |
521 | if (i8042_command(¶m, I8042_CMD_AUX_LOOP) || param == (mode ? 0xa4 : 0xa5)) | 525 | /* |
526 | * Workaround for interference with USB Legacy emulation | ||
527 | * that causes a v10.12 MUX to be found. | ||
528 | */ | ||
529 | if (param == 0xac) | ||
522 | return -1; | 530 | return -1; |
523 | 531 | ||
524 | if (mux_version) | 532 | if (mux_version) |
@@ -537,14 +545,7 @@ static int __devinit i8042_check_mux(void) | |||
537 | { | 545 | { |
538 | unsigned char mux_version; | 546 | unsigned char mux_version; |
539 | 547 | ||
540 | if (i8042_set_mux_mode(1, &mux_version)) | 548 | if (i8042_set_mux_mode(true, &mux_version)) |
541 | return -1; | ||
542 | |||
543 | /* | ||
544 | * Workaround for interference with USB Legacy emulation | ||
545 | * that causes a v10.12 MUX to be found. | ||
546 | */ | ||
547 | if (mux_version == 0xAC) | ||
548 | return -1; | 549 | return -1; |
549 | 550 | ||
550 | 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", |
@@ -561,7 +562,7 @@ static int __devinit i8042_check_mux(void) | |||
561 | return -EIO; | 562 | return -EIO; |
562 | } | 563 | } |
563 | 564 | ||
564 | i8042_mux_present = 1; | 565 | i8042_mux_present = true; |
565 | 566 | ||
566 | return 0; | 567 | return 0; |
567 | } | 568 | } |
@@ -570,7 +571,7 @@ static int __devinit i8042_check_mux(void) | |||
570 | * The following is used to test AUX IRQ delivery. | 571 | * The following is used to test AUX IRQ delivery. |
571 | */ | 572 | */ |
572 | static struct completion i8042_aux_irq_delivered __devinitdata; | 573 | static struct completion i8042_aux_irq_delivered __devinitdata; |
573 | static int i8042_irq_being_tested __devinitdata; | 574 | static bool i8042_irq_being_tested __devinitdata; |
574 | 575 | ||
575 | static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id) | 576 | static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id) |
576 | { | 577 | { |
@@ -597,7 +598,7 @@ static irqreturn_t __devinit i8042_aux_test_irq(int irq, void *dev_id) | |||
597 | * 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 |
598 | * port. | 599 | * port. |
599 | */ | 600 | */ |
600 | static int __devinit i8042_toggle_aux(int on) | 601 | static int __devinit i8042_toggle_aux(bool on) |
601 | { | 602 | { |
602 | unsigned char param; | 603 | unsigned char param; |
603 | int i; | 604 | int i; |
@@ -628,8 +629,8 @@ static int __devinit i8042_toggle_aux(int on) | |||
628 | static int __devinit i8042_check_aux(void) | 629 | static int __devinit i8042_check_aux(void) |
629 | { | 630 | { |
630 | int retval = -1; | 631 | int retval = -1; |
631 | int irq_registered = 0; | 632 | bool irq_registered = false; |
632 | int aux_loop_broken = 0; | 633 | bool aux_loop_broken = false; |
633 | unsigned long flags; | 634 | unsigned long flags; |
634 | unsigned char param; | 635 | unsigned char param; |
635 | 636 | ||
@@ -666,19 +667,19 @@ static int __devinit i8042_check_aux(void) | |||
666 | * mark it as broken | 667 | * mark it as broken |
667 | */ | 668 | */ |
668 | if (!retval) | 669 | if (!retval) |
669 | aux_loop_broken = 1; | 670 | aux_loop_broken = true; |
670 | } | 671 | } |
671 | 672 | ||
672 | /* | 673 | /* |
673 | * 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 |
674 | */ | 675 | */ |
675 | 676 | ||
676 | if (i8042_toggle_aux(0)) { | 677 | if (i8042_toggle_aux(false)) { |
677 | 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"); |
678 | 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"); |
679 | } | 680 | } |
680 | 681 | ||
681 | if (i8042_toggle_aux(1)) | 682 | if (i8042_toggle_aux(true)) |
682 | return -1; | 683 | return -1; |
683 | 684 | ||
684 | /* | 685 | /* |
@@ -699,7 +700,7 @@ static int __devinit i8042_check_aux(void) | |||
699 | "i8042", i8042_platform_device)) | 700 | "i8042", i8042_platform_device)) |
700 | goto out; | 701 | goto out; |
701 | 702 | ||
702 | irq_registered = 1; | 703 | irq_registered = true; |
703 | 704 | ||
704 | if (i8042_enable_aux_port()) | 705 | if (i8042_enable_aux_port()) |
705 | goto out; | 706 | goto out; |
@@ -707,7 +708,7 @@ static int __devinit i8042_check_aux(void) | |||
707 | spin_lock_irqsave(&i8042_lock, flags); | 708 | spin_lock_irqsave(&i8042_lock, flags); |
708 | 709 | ||
709 | init_completion(&i8042_aux_irq_delivered); | 710 | init_completion(&i8042_aux_irq_delivered); |
710 | i8042_irq_being_tested = 1; | 711 | i8042_irq_being_tested = true; |
711 | 712 | ||
712 | param = 0xa5; | 713 | param = 0xa5; |
713 | retval = __i8042_command(¶m, I8042_CMD_AUX_LOOP & 0xf0ff); | 714 | retval = __i8042_command(¶m, I8042_CMD_AUX_LOOP & 0xf0ff); |
@@ -844,7 +845,7 @@ static int i8042_controller_init(void) | |||
844 | */ | 845 | */ |
845 | 846 | ||
846 | if (~i8042_ctr & I8042_CTR_XLATE) | 847 | if (~i8042_ctr & I8042_CTR_XLATE) |
847 | i8042_direct = 1; | 848 | i8042_direct = true; |
848 | 849 | ||
849 | /* | 850 | /* |
850 | * 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. |
@@ -892,7 +893,7 @@ static void i8042_controller_reset(void) | |||
892 | */ | 893 | */ |
893 | 894 | ||
894 | if (i8042_mux_present) | 895 | if (i8042_mux_present) |
895 | i8042_set_mux_mode(0, NULL); | 896 | i8042_set_mux_mode(false, NULL); |
896 | 897 | ||
897 | /* | 898 | /* |
898 | * Reset the controller if requested. | 899 | * Reset the controller if requested. |
@@ -1025,7 +1026,7 @@ static int i8042_pm_restore(struct device *dev) | |||
1025 | #endif | 1026 | #endif |
1026 | 1027 | ||
1027 | if (i8042_mux_present) { | 1028 | if (i8042_mux_present) { |
1028 | if (i8042_set_mux_mode(1, NULL) || i8042_enable_mux_ports()) | 1029 | if (i8042_set_mux_mode(true, NULL) || i8042_enable_mux_ports()) |
1029 | printk(KERN_WARNING | 1030 | printk(KERN_WARNING |
1030 | "i8042: failed to resume active multiplexor, " | 1031 | "i8042: failed to resume active multiplexor, " |
1031 | "mouse won't work.\n"); | 1032 | "mouse won't work.\n"); |
@@ -1167,7 +1168,7 @@ static void i8042_free_irqs(void) | |||
1167 | if (i8042_kbd_irq_registered) | 1168 | if (i8042_kbd_irq_registered) |
1168 | free_irq(I8042_KBD_IRQ, i8042_platform_device); | 1169 | free_irq(I8042_KBD_IRQ, i8042_platform_device); |
1169 | 1170 | ||
1170 | i8042_aux_irq_registered = i8042_kbd_irq_registered = 0; | 1171 | i8042_aux_irq_registered = i8042_kbd_irq_registered = false; |
1171 | } | 1172 | } |
1172 | 1173 | ||
1173 | static int __devinit i8042_setup_aux(void) | 1174 | static int __devinit i8042_setup_aux(void) |
@@ -1201,7 +1202,7 @@ static int __devinit i8042_setup_aux(void) | |||
1201 | if (aux_enable()) | 1202 | if (aux_enable()) |
1202 | goto err_free_irq; | 1203 | goto err_free_irq; |
1203 | 1204 | ||
1204 | i8042_aux_irq_registered = 1; | 1205 | i8042_aux_irq_registered = true; |
1205 | return 0; | 1206 | return 0; |
1206 | 1207 | ||
1207 | err_free_irq: | 1208 | err_free_irq: |
@@ -1228,7 +1229,7 @@ static int __devinit i8042_setup_kbd(void) | |||
1228 | if (error) | 1229 | if (error) |
1229 | goto err_free_irq; | 1230 | goto err_free_irq; |
1230 | 1231 | ||
1231 | i8042_kbd_irq_registered = 1; | 1232 | i8042_kbd_irq_registered = true; |
1232 | return 0; | 1233 | return 0; |
1233 | 1234 | ||
1234 | err_free_irq: | 1235 | err_free_irq: |