aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/input/joystick-parport.txt11
-rw-r--r--arch/alpha/kernel/setup.c18
-rw-r--r--arch/i386/kernel/setup.c18
-rw-r--r--arch/mips/Kconfig6
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/i8253.c28
-rw-r--r--arch/powerpc/kernel/setup-common.c24
-rw-r--r--drivers/Makefile4
-rw-r--r--drivers/char/keyboard.c118
-rw-r--r--drivers/input/evbug.c3
-rw-r--r--drivers/input/evdev.c6
-rw-r--r--drivers/input/gameport/gameport.c30
-rw-r--r--drivers/input/gameport/ns558.c13
-rw-r--r--drivers/input/input.c422
-rw-r--r--drivers/input/joydev.c6
-rw-r--r--drivers/input/joystick/amijoy.c11
-rw-r--r--drivers/input/joystick/db9.c13
-rw-r--r--drivers/input/joystick/gamecon.c96
-rw-r--r--drivers/input/joystick/iforce/iforce-ff.c24
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c2
-rw-r--r--drivers/input/joystick/iforce/iforce.h5
-rw-r--r--drivers/input/joystick/turbografx.c13
-rw-r--r--drivers/input/keyboard/Kconfig2
-rw-r--r--drivers/input/keyboard/atkbd.c24
-rw-r--r--drivers/input/keyboard/corgikbd.c35
-rw-r--r--drivers/input/keyboard/hil_kbd.c9
-rw-r--r--drivers/input/keyboard/spitzkbd.c10
-rw-r--r--drivers/input/misc/pcspkr.c27
-rw-r--r--drivers/input/misc/uinput.c14
-rw-r--r--drivers/input/mouse/hil_ptr.c7
-rw-r--r--drivers/input/mouse/psmouse-base.c38
-rw-r--r--drivers/input/mouse/synaptics.c18
-rw-r--r--drivers/input/mousedev.c6
-rw-r--r--drivers/input/power.c3
-rw-r--r--drivers/input/serio/hil_mlc.c3
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h26
-rw-r--r--drivers/input/serio/libps2.c10
-rw-r--r--drivers/input/serio/parkbd.c3
-rw-r--r--drivers/input/serio/rpckbd.c3
-rw-r--r--drivers/input/serio/serio.c48
-rw-r--r--drivers/input/serio/serio_raw.c29
-rw-r--r--drivers/input/tsdev.c6
-rw-r--r--drivers/usb/input/hid-input.c2
-rw-r--r--include/linux/gameport.h7
-rw-r--r--include/linux/input.h23
-rw-r--r--include/linux/kbd_kern.h2
-rw-r--r--include/linux/keyboard.h13
-rw-r--r--include/linux/libps2.h2
-rw-r--r--include/linux/serio.h9
-rw-r--r--include/linux/uinput.h4
50 files changed, 813 insertions, 443 deletions
diff --git a/Documentation/input/joystick-parport.txt b/Documentation/input/joystick-parport.txt
index 88a011c9f985..d537c48cc6d0 100644
--- a/Documentation/input/joystick-parport.txt
+++ b/Documentation/input/joystick-parport.txt
@@ -36,12 +36,12 @@ with them.
36 36
37 All NES and SNES use the same synchronous serial protocol, clocked from 37 All NES and SNES use the same synchronous serial protocol, clocked from
38the computer's side (and thus timing insensitive). To allow up to 5 NES 38the computer's side (and thus timing insensitive). To allow up to 5 NES
39and/or SNES gamepads connected to the parallel port at once, the output 39and/or SNES gamepads and/or SNES mice connected to the parallel port at once,
40lines of the parallel port are shared, while one of 5 available input lines 40the output lines of the parallel port are shared, while one of 5 available
41is assigned to each gamepad. 41input lines is assigned to each gamepad.
42 42
43 This protocol is handled by the gamecon.c driver, so that's the one 43 This protocol is handled by the gamecon.c driver, so that's the one
44you'll use for NES and SNES gamepads. 44you'll use for NES, SNES gamepads and SNES mice.
45 45
46 The main problem with PC parallel ports is that they don't have +5V power 46 The main problem with PC parallel ports is that they don't have +5V power
47source on any of their pins. So, if you want a reliable source of power 47source on any of their pins. So, if you want a reliable source of power
@@ -106,7 +106,7 @@ A, Turbo B, Select and Start, and is connected through 5 wires, then it is
106either a NES or NES clone and will work with this connection. SNES gamepads 106either a NES or NES clone and will work with this connection. SNES gamepads
107also use 5 wires, but have more buttons. They will work as well, of course. 107also use 5 wires, but have more buttons. They will work as well, of course.
108 108
109Pinout for NES gamepads Pinout for SNES gamepads 109Pinout for NES gamepads Pinout for SNES gamepads and mice
110 110
111 +----> Power +-----------------------\ 111 +----> Power +-----------------------\
112 | 7 | o o o o | x x o | 1 112 | 7 | o o o o | x x o | 1
@@ -454,6 +454,7 @@ uses the following kernel/module command line:
454 6 | N64 pad 454 6 | N64 pad
455 7 | Sony PSX controller 455 7 | Sony PSX controller
456 8 | Sony PSX DDR controller 456 8 | Sony PSX DDR controller
457 9 | SNES mouse
457 458
458 The exact type of the PSX controller type is autoprobed when used so 459 The exact type of the PSX controller type is autoprobed when used so
459hot swapping should work (but is not recomended). 460hot swapping should work (but is not recomended).
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index dd8769670596..a15e18a00258 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/ioport.h> 30#include <linux/ioport.h>
31#include <linux/platform_device.h>
31#include <linux/bootmem.h> 32#include <linux/bootmem.h>
32#include <linux/pci.h> 33#include <linux/pci.h>
33#include <linux/seq_file.h> 34#include <linux/seq_file.h>
@@ -1478,3 +1479,20 @@ alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1478#endif 1479#endif
1479 return NOTIFY_DONE; 1480 return NOTIFY_DONE;
1480} 1481}
1482
1483static __init int add_pcspkr(void)
1484{
1485 struct platform_device *pd;
1486 int ret;
1487
1488 pd = platform_device_alloc("pcspkr", -1);
1489 if (!pd)
1490 return -ENOMEM;
1491
1492 ret = platform_device_add(pd);
1493 if (ret)
1494 platform_device_put(pd);
1495
1496 return ret;
1497}
1498device_initcall(add_pcspkr);
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 8c08660b4e5d..eacc3f0a2ea4 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -34,6 +34,7 @@
34#include <linux/initrd.h> 34#include <linux/initrd.h>
35#include <linux/bootmem.h> 35#include <linux/bootmem.h>
36#include <linux/seq_file.h> 36#include <linux/seq_file.h>
37#include <linux/platform_device.h>
37#include <linux/console.h> 38#include <linux/console.h>
38#include <linux/mca.h> 39#include <linux/mca.h>
39#include <linux/root_dev.h> 40#include <linux/root_dev.h>
@@ -1547,6 +1548,23 @@ void __init setup_arch(char **cmdline_p)
1547#endif 1548#endif
1548} 1549}
1549 1550
1551static __init int add_pcspkr(void)
1552{
1553 struct platform_device *pd;
1554 int ret;
1555
1556 pd = platform_device_alloc("pcspkr", -1);
1557 if (!pd)
1558 return -ENOMEM;
1559
1560 ret = platform_device_add(pd);
1561 if (ret)
1562 platform_device_put(pd);
1563
1564 return ret;
1565}
1566device_initcall(add_pcspkr);
1567
1550#include "setup_arch_post.h" 1568#include "setup_arch_post.h"
1551/* 1569/*
1552 * Local Variables: 1570 * Local Variables:
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 5080ea1799a4..e15709ce8866 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -233,6 +233,7 @@ config MACH_JAZZ
233 select ARC32 233 select ARC32
234 select ARCH_MAY_HAVE_PC_FDC 234 select ARCH_MAY_HAVE_PC_FDC
235 select GENERIC_ISA_DMA 235 select GENERIC_ISA_DMA
236 select I8253
236 select I8259 237 select I8259
237 select ISA 238 select ISA
238 select SYS_HAS_CPU_R4X00 239 select SYS_HAS_CPU_R4X00
@@ -530,6 +531,7 @@ config QEMU
530 select DMA_COHERENT 531 select DMA_COHERENT
531 select GENERIC_ISA_DMA 532 select GENERIC_ISA_DMA
532 select HAVE_STD_PC_SERIAL_PORT 533 select HAVE_STD_PC_SERIAL_PORT
534 select I8253
533 select I8259 535 select I8259
534 select ISA 536 select ISA
535 select SWAP_IO_SPACE 537 select SWAP_IO_SPACE
@@ -714,6 +716,7 @@ config SNI_RM200_PCI
714 select HAVE_STD_PC_SERIAL_PORT 716 select HAVE_STD_PC_SERIAL_PORT
715 select HW_HAS_EISA 717 select HW_HAS_EISA
716 select HW_HAS_PCI 718 select HW_HAS_PCI
719 select I8253
717 select I8259 720 select I8259
718 select ISA 721 select ISA
719 select SYS_HAS_CPU_R4X00 722 select SYS_HAS_CPU_R4X00
@@ -1721,6 +1724,9 @@ config MMU
1721 bool 1724 bool
1722 default y 1725 default y
1723 1726
1727config I8253
1728 bool
1729
1724source "drivers/pcmcia/Kconfig" 1730source "drivers/pcmcia/Kconfig"
1725 1731
1726source "drivers/pci/hotplug/Kconfig" 1732source "drivers/pci/hotplug/Kconfig"
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index f36c4f20ee8a..309d54cceda3 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -59,6 +59,8 @@ obj-$(CONFIG_PROC_FS) += proc.o
59 59
60obj-$(CONFIG_64BIT) += cpu-bugs64.o 60obj-$(CONFIG_64BIT) += cpu-bugs64.o
61 61
62obj-$(CONFIG_I8253) += i8253.o
63
62CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) 64CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
63 65
64EXTRA_AFLAGS := $(CFLAGS) 66EXTRA_AFLAGS := $(CFLAGS)
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
new file mode 100644
index 000000000000..475df6904219
--- /dev/null
+++ b/arch/mips/kernel/i8253.c
@@ -0,0 +1,28 @@
1/*
2 * Copyright (C) 2006 IBM Corporation
3 *
4 * Implements device information for i8253 timer chip
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation
9 */
10
11#include <linux/platform_device.h>
12
13static __init int add_pcspkr(void)
14{
15 struct platform_device *pd;
16 int ret;
17
18 pd = platform_device_alloc("pcspkr", -1);
19 if (!pd)
20 return -ENOMEM;
21
22 ret = platform_device_add(pd);
23 if (ret)
24 platform_device_put(pd);
25
26 return ret;
27}
28device_initcall(add_pcspkr);
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index c607f3b9ca17..1d93e73a7003 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -21,6 +21,7 @@
21#include <linux/reboot.h> 21#include <linux/reboot.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/initrd.h> 23#include <linux/initrd.h>
24#include <linux/platform_device.h>
24#include <linux/ide.h> 25#include <linux/ide.h>
25#include <linux/seq_file.h> 26#include <linux/seq_file.h>
26#include <linux/ioport.h> 27#include <linux/ioport.h>
@@ -462,6 +463,29 @@ static int __init early_xmon(char *p)
462early_param("xmon", early_xmon); 463early_param("xmon", early_xmon);
463#endif 464#endif
464 465
466static __init int add_pcspkr(void)
467{
468 struct device_node *np;
469 struct platform_device *pd;
470 int ret;
471
472 np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
473 of_node_put(np);
474 if (!np)
475 return -ENODEV;
476
477 pd = platform_device_alloc("pcspkr", -1);
478 if (!pd)
479 return -ENOMEM;
480
481 ret = platform_device_add(pd);
482 if (ret)
483 platform_device_put(pd);
484
485 return ret;
486}
487device_initcall(add_pcspkr);
488
465void probe_machine(void) 489void probe_machine(void)
466{ 490{
467 extern struct machdep_calls __machine_desc_start; 491 extern struct machdep_calls __machine_desc_start;
diff --git a/drivers/Makefile b/drivers/Makefile
index d6e8ffbd8132..55205c8d2318 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -25,9 +25,6 @@ obj-$(CONFIG_CONNECTOR) += connector/
25obj-$(CONFIG_FB_I810) += video/i810/ 25obj-$(CONFIG_FB_I810) += video/i810/
26obj-$(CONFIG_FB_INTEL) += video/intelfb/ 26obj-$(CONFIG_FB_INTEL) += video/intelfb/
27 27
28# we also need input/serio early so serio bus is initialized by the time
29# serial drivers start registering their serio ports
30obj-$(CONFIG_SERIO) += input/serio/
31obj-y += serial/ 28obj-y += serial/
32obj-$(CONFIG_PARPORT) += parport/ 29obj-$(CONFIG_PARPORT) += parport/
33obj-y += base/ block/ misc/ mfd/ net/ media/ 30obj-y += base/ block/ misc/ mfd/ net/ media/
@@ -53,6 +50,7 @@ obj-$(CONFIG_TC) += tc/
53obj-$(CONFIG_USB) += usb/ 50obj-$(CONFIG_USB) += usb/
54obj-$(CONFIG_PCI) += usb/ 51obj-$(CONFIG_PCI) += usb/
55obj-$(CONFIG_USB_GADGET) += usb/gadget/ 52obj-$(CONFIG_USB_GADGET) += usb/gadget/
53obj-$(CONFIG_SERIO) += input/serio/
56obj-$(CONFIG_GAMEPORT) += input/gameport/ 54obj-$(CONFIG_GAMEPORT) += input/gameport/
57obj-$(CONFIG_INPUT) += input/ 55obj-$(CONFIG_INPUT) += input/
58obj-$(CONFIG_I2O) += message/ 56obj-$(CONFIG_I2O) += message/
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 8b603b2d1c42..935670a3cd98 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -74,7 +74,7 @@ void compute_shiftstate(void);
74 k_self, k_fn, k_spec, k_pad,\ 74 k_self, k_fn, k_spec, k_pad,\
75 k_dead, k_cons, k_cur, k_shift,\ 75 k_dead, k_cons, k_cur, k_shift,\
76 k_meta, k_ascii, k_lock, k_lowercase,\ 76 k_meta, k_ascii, k_lock, k_lowercase,\
77 k_slock, k_dead2, k_ignore, k_ignore 77 k_slock, k_dead2, k_brl, k_ignore
78 78
79typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, 79typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value,
80 char up_flag, struct pt_regs *regs); 80 char up_flag, struct pt_regs *regs);
@@ -100,7 +100,7 @@ static fn_handler_fn *fn_handler[] = { FN_HANDLERS };
100const int max_vals[] = { 100const int max_vals[] = {
101 255, ARRAY_SIZE(func_table) - 1, ARRAY_SIZE(fn_handler) - 1, NR_PAD - 1, 101 255, ARRAY_SIZE(func_table) - 1, ARRAY_SIZE(fn_handler) - 1, NR_PAD - 1,
102 NR_DEAD - 1, 255, 3, NR_SHIFT - 1, 255, NR_ASCII - 1, NR_LOCK - 1, 102 NR_DEAD - 1, 255, 3, NR_SHIFT - 1, 255, NR_ASCII - 1, NR_LOCK - 1,
103 255, NR_LOCK - 1, 255 103 255, NR_LOCK - 1, 255, NR_BRL - 1
104}; 104};
105 105
106const int NR_TYPES = ARRAY_SIZE(max_vals); 106const int NR_TYPES = ARRAY_SIZE(max_vals);
@@ -126,7 +126,7 @@ static unsigned long key_down[NBITS(KEY_MAX)]; /* keyboard key bitmap */
126static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ 126static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
127static int dead_key_next; 127static int dead_key_next;
128static int npadch = -1; /* -1 or number assembled on pad */ 128static int npadch = -1; /* -1 or number assembled on pad */
129static unsigned char diacr; 129static unsigned int diacr;
130static char rep; /* flag telling character repeat */ 130static char rep; /* flag telling character repeat */
131 131
132static unsigned char ledstate = 0xff; /* undefined */ 132static unsigned char ledstate = 0xff; /* undefined */
@@ -394,22 +394,30 @@ void compute_shiftstate(void)
394 * Otherwise, conclude that DIACR was not combining after all, 394 * Otherwise, conclude that DIACR was not combining after all,
395 * queue it and return CH. 395 * queue it and return CH.
396 */ 396 */
397static unsigned char handle_diacr(struct vc_data *vc, unsigned char ch) 397static unsigned int handle_diacr(struct vc_data *vc, unsigned int ch)
398{ 398{
399 int d = diacr; 399 unsigned int d = diacr;
400 unsigned int i; 400 unsigned int i;
401 401
402 diacr = 0; 402 diacr = 0;
403 403
404 for (i = 0; i < accent_table_size; i++) { 404 if ((d & ~0xff) == BRL_UC_ROW) {
405 if (accent_table[i].diacr == d && accent_table[i].base == ch) 405 if ((ch & ~0xff) == BRL_UC_ROW)
406 return accent_table[i].result; 406 return d | ch;
407 } else {
408 for (i = 0; i < accent_table_size; i++)
409 if (accent_table[i].diacr == d && accent_table[i].base == ch)
410 return accent_table[i].result;
407 } 411 }
408 412
409 if (ch == ' ' || ch == d) 413 if (ch == ' ' || ch == (BRL_UC_ROW|0) || ch == d)
410 return d; 414 return d;
411 415
412 put_queue(vc, d); 416 if (kbd->kbdmode == VC_UNICODE)
417 to_utf8(vc, d);
418 else if (d < 0x100)
419 put_queue(vc, d);
420
413 return ch; 421 return ch;
414} 422}
415 423
@@ -419,7 +427,10 @@ static unsigned char handle_diacr(struct vc_data *vc, unsigned char ch)
419static void fn_enter(struct vc_data *vc, struct pt_regs *regs) 427static void fn_enter(struct vc_data *vc, struct pt_regs *regs)
420{ 428{
421 if (diacr) { 429 if (diacr) {
422 put_queue(vc, diacr); 430 if (kbd->kbdmode == VC_UNICODE)
431 to_utf8(vc, diacr);
432 else if (diacr < 0x100)
433 put_queue(vc, diacr);
423 diacr = 0; 434 diacr = 0;
424 } 435 }
425 put_queue(vc, 13); 436 put_queue(vc, 13);
@@ -615,7 +626,7 @@ static void k_lowercase(struct vc_data *vc, unsigned char value, char up_flag, s
615 printk(KERN_ERR "keyboard.c: k_lowercase was called - impossible\n"); 626 printk(KERN_ERR "keyboard.c: k_lowercase was called - impossible\n");
616} 627}
617 628
618static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 629static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag, struct pt_regs *regs)
619{ 630{
620 if (up_flag) 631 if (up_flag)
621 return; /* no action, if this is a key release */ 632 return; /* no action, if this is a key release */
@@ -628,7 +639,10 @@ static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct
628 diacr = value; 639 diacr = value;
629 return; 640 return;
630 } 641 }
631 put_queue(vc, value); 642 if (kbd->kbdmode == VC_UNICODE)
643 to_utf8(vc, value);
644 else if (value < 0x100)
645 put_queue(vc, value);
632} 646}
633 647
634/* 648/*
@@ -636,13 +650,23 @@ static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct
636 * dead keys modifying the same character. Very useful 650 * dead keys modifying the same character. Very useful
637 * for Vietnamese. 651 * for Vietnamese.
638 */ 652 */
639static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 653static void k_deadunicode(struct vc_data *vc, unsigned int value, char up_flag, struct pt_regs *regs)
640{ 654{
641 if (up_flag) 655 if (up_flag)
642 return; 656 return;
643 diacr = (diacr ? handle_diacr(vc, value) : value); 657 diacr = (diacr ? handle_diacr(vc, value) : value);
644} 658}
645 659
660static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
661{
662 k_unicode(vc, value, up_flag, regs);
663}
664
665static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
666{
667 k_deadunicode(vc, value, up_flag, regs);
668}
669
646/* 670/*
647 * Obsolete - for backwards compatibility only 671 * Obsolete - for backwards compatibility only
648 */ 672 */
@@ -650,7 +674,7 @@ static void k_dead(struct vc_data *vc, unsigned char value, char up_flag, struct
650{ 674{
651 static unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; 675 static unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' };
652 value = ret_diacr[value]; 676 value = ret_diacr[value];
653 k_dead2(vc, value, up_flag, regs); 677 k_deadunicode(vc, value, up_flag, regs);
654} 678}
655 679
656static void k_cons(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 680static void k_cons(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
@@ -835,6 +859,62 @@ static void k_slock(struct vc_data *vc, unsigned char value, char up_flag, struc
835 } 859 }
836} 860}
837 861
862/* by default, 300ms interval for combination release */
863static long brl_timeout = 300;
864MODULE_PARM_DESC(brl_timeout, "Braille keys release delay in ms (0 for combination on first release, < 0 for dead characters)");
865module_param(brl_timeout, long, 0644);
866static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
867{
868 static unsigned pressed,committing;
869 static unsigned long releasestart;
870
871 if (kbd->kbdmode != VC_UNICODE) {
872 if (!up_flag)
873 printk("keyboard mode must be unicode for braille patterns\n");
874 return;
875 }
876
877 if (!value) {
878 k_unicode(vc, BRL_UC_ROW, up_flag, regs);
879 return;
880 }
881
882 if (value > 8)
883 return;
884
885 if (brl_timeout < 0) {
886 k_deadunicode(vc, BRL_UC_ROW | (1 << (value - 1)), up_flag, regs);
887 return;
888 }
889
890 if (up_flag) {
891 if (brl_timeout) {
892 if (!committing ||
893 jiffies - releasestart > (brl_timeout * HZ) / 1000) {
894 committing = pressed;
895 releasestart = jiffies;
896 }
897 pressed &= ~(1 << (value - 1));
898 if (!pressed) {
899 if (committing) {
900 k_unicode(vc, BRL_UC_ROW | committing, 0, regs);
901 committing = 0;
902 }
903 }
904 } else {
905 if (committing) {
906 k_unicode(vc, BRL_UC_ROW | committing, 0, regs);
907 committing = 0;
908 }
909 pressed &= ~(1 << (value - 1));
910 }
911 } else {
912 pressed |= 1 << (value - 1);
913 if (!brl_timeout)
914 committing = pressed;
915 }
916}
917
838/* 918/*
839 * The leds display either (i) the status of NumLock, CapsLock, ScrollLock, 919 * The leds display either (i) the status of NumLock, CapsLock, ScrollLock,
840 * or (ii) whatever pattern of lights people want to show using KDSETLED, 920 * or (ii) whatever pattern of lights people want to show using KDSETLED,
@@ -1125,9 +1205,13 @@ static void kbd_keycode(unsigned int keycode, int down,
1125 } 1205 }
1126 1206
1127 if (keycode > NR_KEYS) 1207 if (keycode > NR_KEYS)
1128 return; 1208 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)
1209 keysym = K(KT_BRL, keycode - KEY_BRL_DOT1 + 1);
1210 else
1211 return;
1212 else
1213 keysym = key_map[keycode];
1129 1214
1130 keysym = key_map[keycode];
1131 type = KTYP(keysym); 1215 type = KTYP(keysym);
1132 1216
1133 if (type < 0xf0) { 1217 if (type < 0xf0) {
diff --git a/drivers/input/evbug.c b/drivers/input/evbug.c
index d7828936fd8f..07358fb51b82 100644
--- a/drivers/input/evbug.c
+++ b/drivers/input/evbug.c
@@ -49,9 +49,8 @@ static struct input_handle *evbug_connect(struct input_handler *handler, struct
49{ 49{
50 struct input_handle *handle; 50 struct input_handle *handle;
51 51
52 if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) 52 if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
53 return NULL; 53 return NULL;
54 memset(handle, 0, sizeof(struct input_handle));
55 54
56 handle->dev = dev; 55 handle->dev = dev;
57 handle->handler = handler; 56 handle->handler = handler;
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 745979f33dc2..a34e3d91d9ed 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -130,9 +130,8 @@ static int evdev_open(struct inode * inode, struct file * file)
130 if ((accept_err = input_accept_process(&(evdev_table[i]->handle), file))) 130 if ((accept_err = input_accept_process(&(evdev_table[i]->handle), file)))
131 return accept_err; 131 return accept_err;
132 132
133 if (!(list = kmalloc(sizeof(struct evdev_list), GFP_KERNEL))) 133 if (!(list = kzalloc(sizeof(struct evdev_list), GFP_KERNEL)))
134 return -ENOMEM; 134 return -ENOMEM;
135 memset(list, 0, sizeof(struct evdev_list));
136 135
137 list->evdev = evdev_table[i]; 136 list->evdev = evdev_table[i];
138 list_add_tail(&list->node, &evdev_table[i]->list); 137 list_add_tail(&list->node, &evdev_table[i]->list);
@@ -609,9 +608,8 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
609 return NULL; 608 return NULL;
610 } 609 }
611 610
612 if (!(evdev = kmalloc(sizeof(struct evdev), GFP_KERNEL))) 611 if (!(evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL)))
613 return NULL; 612 return NULL;
614 memset(evdev, 0, sizeof(struct evdev));
615 613
616 INIT_LIST_HEAD(&evdev->list); 614 INIT_LIST_HEAD(&evdev->list);
617 init_waitqueue_head(&evdev->wait); 615 init_waitqueue_head(&evdev->wait);
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index b765a155c008..36644bff379d 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -22,6 +22,7 @@
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/sched.h> /* HZ */ 24#include <linux/sched.h> /* HZ */
25#include <linux/mutex.h>
25 26
26/*#include <asm/io.h>*/ 27/*#include <asm/io.h>*/
27 28
@@ -43,10 +44,10 @@ EXPORT_SYMBOL(gameport_start_polling);
43EXPORT_SYMBOL(gameport_stop_polling); 44EXPORT_SYMBOL(gameport_stop_polling);
44 45
45/* 46/*
46 * gameport_sem protects entire gameport subsystem and is taken 47 * gameport_mutex protects entire gameport subsystem and is taken
47 * every time gameport port or driver registrered or unregistered. 48 * every time gameport port or driver registrered or unregistered.
48 */ 49 */
49static DECLARE_MUTEX(gameport_sem); 50static DEFINE_MUTEX(gameport_mutex);
50 51
51static LIST_HEAD(gameport_list); 52static LIST_HEAD(gameport_list);
52 53
@@ -265,6 +266,7 @@ static void gameport_queue_event(void *object, struct module *owner,
265 if ((event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC))) { 266 if ((event = kmalloc(sizeof(struct gameport_event), GFP_ATOMIC))) {
266 if (!try_module_get(owner)) { 267 if (!try_module_get(owner)) {
267 printk(KERN_WARNING "gameport: Can't get module reference, dropping event %d\n", event_type); 268 printk(KERN_WARNING "gameport: Can't get module reference, dropping event %d\n", event_type);
269 kfree(event);
268 goto out; 270 goto out;
269 } 271 }
270 272
@@ -342,7 +344,7 @@ static void gameport_handle_event(void)
342 struct gameport_event *event; 344 struct gameport_event *event;
343 struct gameport_driver *gameport_drv; 345 struct gameport_driver *gameport_drv;
344 346
345 down(&gameport_sem); 347 mutex_lock(&gameport_mutex);
346 348
347 /* 349 /*
348 * Note that we handle only one event here to give swsusp 350 * Note that we handle only one event here to give swsusp
@@ -379,7 +381,7 @@ static void gameport_handle_event(void)
379 gameport_free_event(event); 381 gameport_free_event(event);
380 } 382 }
381 383
382 up(&gameport_sem); 384 mutex_unlock(&gameport_mutex);
383} 385}
384 386
385/* 387/*
@@ -464,7 +466,7 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
464 struct device_driver *drv; 466 struct device_driver *drv;
465 int retval; 467 int retval;
466 468
467 retval = down_interruptible(&gameport_sem); 469 retval = mutex_lock_interruptible(&gameport_mutex);
468 if (retval) 470 if (retval)
469 return retval; 471 return retval;
470 472
@@ -484,7 +486,7 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut
484 retval = -EINVAL; 486 retval = -EINVAL;
485 } 487 }
486 488
487 up(&gameport_sem); 489 mutex_unlock(&gameport_mutex);
488 490
489 return retval; 491 return retval;
490} 492}
@@ -521,7 +523,7 @@ static void gameport_init_port(struct gameport *gameport)
521 523
522 __module_get(THIS_MODULE); 524 __module_get(THIS_MODULE);
523 525
524 init_MUTEX(&gameport->drv_sem); 526 mutex_init(&gameport->drv_mutex);
525 device_initialize(&gameport->dev); 527 device_initialize(&gameport->dev);
526 snprintf(gameport->dev.bus_id, sizeof(gameport->dev.bus_id), 528 snprintf(gameport->dev.bus_id, sizeof(gameport->dev.bus_id),
527 "gameport%lu", (unsigned long)atomic_inc_return(&gameport_no) - 1); 529 "gameport%lu", (unsigned long)atomic_inc_return(&gameport_no) - 1);
@@ -661,10 +663,10 @@ void __gameport_register_port(struct gameport *gameport, struct module *owner)
661 */ 663 */
662void gameport_unregister_port(struct gameport *gameport) 664void gameport_unregister_port(struct gameport *gameport)
663{ 665{
664 down(&gameport_sem); 666 mutex_lock(&gameport_mutex);
665 gameport_disconnect_port(gameport); 667 gameport_disconnect_port(gameport);
666 gameport_destroy_port(gameport); 668 gameport_destroy_port(gameport);
667 up(&gameport_sem); 669 mutex_unlock(&gameport_mutex);
668} 670}
669 671
670 672
@@ -717,7 +719,7 @@ void gameport_unregister_driver(struct gameport_driver *drv)
717{ 719{
718 struct gameport *gameport; 720 struct gameport *gameport;
719 721
720 down(&gameport_sem); 722 mutex_lock(&gameport_mutex);
721 drv->ignore = 1; /* so gameport_find_driver ignores it */ 723 drv->ignore = 1; /* so gameport_find_driver ignores it */
722 724
723start_over: 725start_over:
@@ -731,7 +733,7 @@ start_over:
731 } 733 }
732 734
733 driver_unregister(&drv->driver); 735 driver_unregister(&drv->driver);
734 up(&gameport_sem); 736 mutex_unlock(&gameport_mutex);
735} 737}
736 738
737static int gameport_bus_match(struct device *dev, struct device_driver *drv) 739static int gameport_bus_match(struct device *dev, struct device_driver *drv)
@@ -743,9 +745,9 @@ static int gameport_bus_match(struct device *dev, struct device_driver *drv)
743 745
744static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv) 746static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv)
745{ 747{
746 down(&gameport->drv_sem); 748 mutex_lock(&gameport->drv_mutex);
747 gameport->drv = drv; 749 gameport->drv = drv;
748 up(&gameport->drv_sem); 750 mutex_unlock(&gameport->drv_mutex);
749} 751}
750 752
751int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode) 753int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode)
@@ -796,5 +798,5 @@ static void __exit gameport_exit(void)
796 kthread_stop(gameport_task); 798 kthread_stop(gameport_task);
797} 799}
798 800
799module_init(gameport_init); 801subsys_initcall(gameport_init);
800module_exit(gameport_exit); 802module_exit(gameport_exit);
diff --git a/drivers/input/gameport/ns558.c b/drivers/input/gameport/ns558.c
index d2e55dc956ba..3e2d28f263e9 100644
--- a/drivers/input/gameport/ns558.c
+++ b/drivers/input/gameport/ns558.c
@@ -252,14 +252,14 @@ static struct pnp_driver ns558_pnp_driver;
252 252
253#endif 253#endif
254 254
255static int pnp_registered = 0;
256
257static int __init ns558_init(void) 255static int __init ns558_init(void)
258{ 256{
259 int i = 0; 257 int i = 0;
258 int error;
260 259
261 if (pnp_register_driver(&ns558_pnp_driver) >= 0) 260 error = pnp_register_driver(&ns558_pnp_driver);
262 pnp_registered = 1; 261 if (error && error != -ENODEV) /* should be ENOSYS really */
262 return error;
263 263
264/* 264/*
265 * Probe ISA ports after PnP, so that PnP ports that are already 265 * Probe ISA ports after PnP, so that PnP ports that are already
@@ -270,7 +270,7 @@ static int __init ns558_init(void)
270 while (ns558_isa_portlist[i]) 270 while (ns558_isa_portlist[i])
271 ns558_isa_probe(ns558_isa_portlist[i++]); 271 ns558_isa_probe(ns558_isa_portlist[i++]);
272 272
273 return (list_empty(&ns558_list) && !pnp_registered) ? -ENODEV : 0; 273 return list_empty(&ns558_list) && error ? -ENODEV : 0;
274} 274}
275 275
276static void __exit ns558_exit(void) 276static void __exit ns558_exit(void)
@@ -283,8 +283,7 @@ static void __exit ns558_exit(void)
283 kfree(ns558); 283 kfree(ns558);
284 } 284 }
285 285
286 if (pnp_registered) 286 pnp_unregister_driver(&ns558_pnp_driver);
287 pnp_unregister_driver(&ns558_pnp_driver);
288} 287}
289 288
290module_init(ns558_init); 289module_init(ns558_init);
diff --git a/drivers/input/input.c b/drivers/input/input.c
index f8af0945964e..a935abeffffc 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -18,9 +18,11 @@
18#include <linux/random.h> 18#include <linux/random.h>
19#include <linux/major.h> 19#include <linux/major.h>
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/seq_file.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
22#include <linux/poll.h> 23#include <linux/poll.h>
23#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/mutex.h>
24 26
25MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 27MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>");
26MODULE_DESCRIPTION("Input core"); 28MODULE_DESCRIPTION("Input core");
@@ -224,7 +226,7 @@ int input_open_device(struct input_handle *handle)
224 struct input_dev *dev = handle->dev; 226 struct input_dev *dev = handle->dev;
225 int err; 227 int err;
226 228
227 err = down_interruptible(&dev->sem); 229 err = mutex_lock_interruptible(&dev->mutex);
228 if (err) 230 if (err)
229 return err; 231 return err;
230 232
@@ -236,7 +238,7 @@ int input_open_device(struct input_handle *handle)
236 if (err) 238 if (err)
237 handle->open--; 239 handle->open--;
238 240
239 up(&dev->sem); 241 mutex_unlock(&dev->mutex);
240 242
241 return err; 243 return err;
242} 244}
@@ -255,13 +257,13 @@ void input_close_device(struct input_handle *handle)
255 257
256 input_release_device(handle); 258 input_release_device(handle);
257 259
258 down(&dev->sem); 260 mutex_lock(&dev->mutex);
259 261
260 if (!--dev->users && dev->close) 262 if (!--dev->users && dev->close)
261 dev->close(dev); 263 dev->close(dev);
262 handle->open--; 264 handle->open--;
263 265
264 up(&dev->sem); 266 mutex_unlock(&dev->mutex);
265} 267}
266 268
267static void input_link_handle(struct input_handle *handle) 269static void input_link_handle(struct input_handle *handle)
@@ -315,21 +317,6 @@ static struct input_device_id *input_match_device(struct input_device_id *id, st
315 return NULL; 317 return NULL;
316} 318}
317 319
318static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap, int max)
319{
320 int i;
321 int len = 0;
322
323 for (i = NBITS(max) - 1; i > 0; i--)
324 if (bitmap[i])
325 break;
326
327 for (; i >= 0; i--)
328 len += snprintf(buf + len, max(buf_size - len, 0),
329 "%lx%s", bitmap[i], i > 0 ? " " : "");
330 return len;
331}
332
333#ifdef CONFIG_PROC_FS 320#ifdef CONFIG_PROC_FS
334 321
335static struct proc_dir_entry *proc_bus_input_dir; 322static struct proc_dir_entry *proc_bus_input_dir;
@@ -342,7 +329,7 @@ static inline void input_wakeup_procfs_readers(void)
342 wake_up(&input_devices_poll_wait); 329 wake_up(&input_devices_poll_wait);
343} 330}
344 331
345static unsigned int input_devices_poll(struct file *file, poll_table *wait) 332static unsigned int input_proc_devices_poll(struct file *file, poll_table *wait)
346{ 333{
347 int state = input_devices_state; 334 int state = input_devices_state;
348 poll_wait(file, &input_devices_poll_wait, wait); 335 poll_wait(file, &input_devices_poll_wait, wait);
@@ -351,115 +338,171 @@ static unsigned int input_devices_poll(struct file *file, poll_table *wait)
351 return 0; 338 return 0;
352} 339}
353 340
354#define SPRINTF_BIT(ev, bm) \ 341static struct list_head *list_get_nth_element(struct list_head *list, loff_t *pos)
355 do { \ 342{
356 len += sprintf(buf + len, "B: %s=", #ev); \ 343 struct list_head *node;
357 len += input_print_bitmap(buf + len, INT_MAX, \ 344 loff_t i = 0;
358 dev->bm##bit, ev##_MAX); \
359 len += sprintf(buf + len, "\n"); \
360 } while (0)
361 345
362#define TEST_AND_SPRINTF_BIT(ev, bm) \ 346 list_for_each(node, list)
363 do { \ 347 if (i++ == *pos)
364 if (test_bit(EV_##ev, dev->evbit)) \ 348 return node;
365 SPRINTF_BIT(ev, bm); \ 349
366 } while (0) 350 return NULL;
351}
367 352
368static int input_devices_read(char *buf, char **start, off_t pos, int count, int *eof, void *data) 353static struct list_head *list_get_next_element(struct list_head *list, struct list_head *element, loff_t *pos)
369{ 354{
370 struct input_dev *dev; 355 if (element->next == list)
371 struct input_handle *handle; 356 return NULL;
372 const char *path; 357
358 ++(*pos);
359 return element->next;
360}
361
362static void *input_devices_seq_start(struct seq_file *seq, loff_t *pos)
363{
364 /* acquire lock here ... Yes, we do need locking, I knowi, I know... */
365
366 return list_get_nth_element(&input_dev_list, pos);
367}
373 368
374 off_t at = 0; 369static void *input_devices_seq_next(struct seq_file *seq, void *v, loff_t *pos)
375 int len, cnt = 0; 370{
371 return list_get_next_element(&input_dev_list, v, pos);
372}
376 373
377 list_for_each_entry(dev, &input_dev_list, node) { 374static void input_devices_seq_stop(struct seq_file *seq, void *v)
375{
376 /* release lock here */
377}
378 378
379 path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL); 379static void input_seq_print_bitmap(struct seq_file *seq, const char *name,
380 unsigned long *bitmap, int max)
381{
382 int i;
380 383
381 len = sprintf(buf, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n", 384 for (i = NBITS(max) - 1; i > 0; i--)
382 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version); 385 if (bitmap[i])
386 break;
383 387
384 len += sprintf(buf + len, "N: Name=\"%s\"\n", dev->name ? dev->name : ""); 388 seq_printf(seq, "B: %s=", name);
385 len += sprintf(buf + len, "P: Phys=%s\n", dev->phys ? dev->phys : ""); 389 for (; i >= 0; i--)
386 len += sprintf(buf + len, "S: Sysfs=%s\n", path ? path : ""); 390 seq_printf(seq, "%lx%s", bitmap[i], i > 0 ? " " : "");
387 len += sprintf(buf + len, "H: Handlers="); 391 seq_putc(seq, '\n');
392}
388 393
389 list_for_each_entry(handle, &dev->h_list, d_node) 394static int input_devices_seq_show(struct seq_file *seq, void *v)
390 len += sprintf(buf + len, "%s ", handle->name); 395{
391 396 struct input_dev *dev = container_of(v, struct input_dev, node);
392 len += sprintf(buf + len, "\n"); 397 const char *path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
393 398 struct input_handle *handle;
394 SPRINTF_BIT(EV, ev);
395 TEST_AND_SPRINTF_BIT(KEY, key);
396 TEST_AND_SPRINTF_BIT(REL, rel);
397 TEST_AND_SPRINTF_BIT(ABS, abs);
398 TEST_AND_SPRINTF_BIT(MSC, msc);
399 TEST_AND_SPRINTF_BIT(LED, led);
400 TEST_AND_SPRINTF_BIT(SND, snd);
401 TEST_AND_SPRINTF_BIT(FF, ff);
402 TEST_AND_SPRINTF_BIT(SW, sw);
403
404 len += sprintf(buf + len, "\n");
405
406 at += len;
407
408 if (at >= pos) {
409 if (!*start) {
410 *start = buf + (pos - (at - len));
411 cnt = at - pos;
412 } else cnt += len;
413 buf += len;
414 if (cnt >= count)
415 break;
416 }
417 399
418 kfree(path); 400 seq_printf(seq, "I: Bus=%04x Vendor=%04x Product=%04x Version=%04x\n",
419 } 401 dev->id.bustype, dev->id.vendor, dev->id.product, dev->id.version);
420 402
421 if (&dev->node == &input_dev_list) 403 seq_printf(seq, "N: Name=\"%s\"\n", dev->name ? dev->name : "");
422 *eof = 1; 404 seq_printf(seq, "P: Phys=%s\n", dev->phys ? dev->phys : "");
405 seq_printf(seq, "S: Sysfs=%s\n", path ? path : "");
406 seq_printf(seq, "H: Handlers=");
423 407
424 return (count > cnt) ? cnt : count; 408 list_for_each_entry(handle, &dev->h_list, d_node)
409 seq_printf(seq, "%s ", handle->name);
410 seq_putc(seq, '\n');
411
412 input_seq_print_bitmap(seq, "EV", dev->evbit, EV_MAX);
413 if (test_bit(EV_KEY, dev->evbit))
414 input_seq_print_bitmap(seq, "KEY", dev->keybit, KEY_MAX);
415 if (test_bit(EV_REL, dev->evbit))
416 input_seq_print_bitmap(seq, "REL", dev->relbit, REL_MAX);
417 if (test_bit(EV_ABS, dev->evbit))
418 input_seq_print_bitmap(seq, "ABS", dev->absbit, ABS_MAX);
419 if (test_bit(EV_MSC, dev->evbit))
420 input_seq_print_bitmap(seq, "MSC", dev->mscbit, MSC_MAX);
421 if (test_bit(EV_LED, dev->evbit))
422 input_seq_print_bitmap(seq, "LED", dev->ledbit, LED_MAX);
423 if (test_bit(EV_SND, dev->evbit))
424 input_seq_print_bitmap(seq, "SND", dev->sndbit, SND_MAX);
425 if (test_bit(EV_FF, dev->evbit))
426 input_seq_print_bitmap(seq, "FF", dev->ffbit, FF_MAX);
427 if (test_bit(EV_SW, dev->evbit))
428 input_seq_print_bitmap(seq, "SW", dev->swbit, SW_MAX);
429
430 seq_putc(seq, '\n');
431
432 kfree(path);
433 return 0;
425} 434}
426 435
427static int input_handlers_read(char *buf, char **start, off_t pos, int count, int *eof, void *data) 436static struct seq_operations input_devices_seq_ops = {
437 .start = input_devices_seq_start,
438 .next = input_devices_seq_next,
439 .stop = input_devices_seq_stop,
440 .show = input_devices_seq_show,
441};
442
443static int input_proc_devices_open(struct inode *inode, struct file *file)
428{ 444{
429 struct input_handler *handler; 445 return seq_open(file, &input_devices_seq_ops);
446}
430 447
431 off_t at = 0; 448static struct file_operations input_devices_fileops = {
432 int len = 0, cnt = 0; 449 .owner = THIS_MODULE,
433 int i = 0; 450 .open = input_proc_devices_open,
451 .poll = input_proc_devices_poll,
452 .read = seq_read,
453 .llseek = seq_lseek,
454 .release = seq_release,
455};
434 456
435 list_for_each_entry(handler, &input_handler_list, node) { 457static void *input_handlers_seq_start(struct seq_file *seq, loff_t *pos)
458{
459 /* acquire lock here ... Yes, we do need locking, I knowi, I know... */
460 seq->private = (void *)(unsigned long)*pos;
461 return list_get_nth_element(&input_handler_list, pos);
462}
463
464static void *input_handlers_seq_next(struct seq_file *seq, void *v, loff_t *pos)
465{
466 seq->private = (void *)(unsigned long)(*pos + 1);
467 return list_get_next_element(&input_handler_list, v, pos);
468}
436 469
437 if (handler->fops) 470static void input_handlers_seq_stop(struct seq_file *seq, void *v)
438 len = sprintf(buf, "N: Number=%d Name=%s Minor=%d\n", 471{
439 i++, handler->name, handler->minor); 472 /* release lock here */
440 else 473}
441 len = sprintf(buf, "N: Number=%d Name=%s\n",
442 i++, handler->name);
443 474
444 at += len; 475static int input_handlers_seq_show(struct seq_file *seq, void *v)
476{
477 struct input_handler *handler = container_of(v, struct input_handler, node);
445 478
446 if (at >= pos) { 479 seq_printf(seq, "N: Number=%ld Name=%s",
447 if (!*start) { 480 (unsigned long)seq->private, handler->name);
448 *start = buf + (pos - (at - len)); 481 if (handler->fops)
449 cnt = at - pos; 482 seq_printf(seq, " Minor=%d", handler->minor);
450 } else cnt += len; 483 seq_putc(seq, '\n');
451 buf += len;
452 if (cnt >= count)
453 break;
454 }
455 }
456 if (&handler->node == &input_handler_list)
457 *eof = 1;
458 484
459 return (count > cnt) ? cnt : count; 485 return 0;
460} 486}
487static struct seq_operations input_handlers_seq_ops = {
488 .start = input_handlers_seq_start,
489 .next = input_handlers_seq_next,
490 .stop = input_handlers_seq_stop,
491 .show = input_handlers_seq_show,
492};
461 493
462static struct file_operations input_fileops; 494static int input_proc_handlers_open(struct inode *inode, struct file *file)
495{
496 return seq_open(file, &input_handlers_seq_ops);
497}
498
499static struct file_operations input_handlers_fileops = {
500 .owner = THIS_MODULE,
501 .open = input_proc_handlers_open,
502 .read = seq_read,
503 .llseek = seq_lseek,
504 .release = seq_release,
505};
463 506
464static int __init input_proc_init(void) 507static int __init input_proc_init(void)
465{ 508{
@@ -471,20 +514,19 @@ static int __init input_proc_init(void)
471 514
472 proc_bus_input_dir->owner = THIS_MODULE; 515 proc_bus_input_dir->owner = THIS_MODULE;
473 516
474 entry = create_proc_read_entry("devices", 0, proc_bus_input_dir, input_devices_read, NULL); 517 entry = create_proc_entry("devices", 0, proc_bus_input_dir);
475 if (!entry) 518 if (!entry)
476 goto fail1; 519 goto fail1;
477 520
478 entry->owner = THIS_MODULE; 521 entry->owner = THIS_MODULE;
479 input_fileops = *entry->proc_fops; 522 entry->proc_fops = &input_devices_fileops;
480 input_fileops.poll = input_devices_poll;
481 entry->proc_fops = &input_fileops;
482 523
483 entry = create_proc_read_entry("handlers", 0, proc_bus_input_dir, input_handlers_read, NULL); 524 entry = create_proc_entry("handlers", 0, proc_bus_input_dir);
484 if (!entry) 525 if (!entry)
485 goto fail2; 526 goto fail2;
486 527
487 entry->owner = THIS_MODULE; 528 entry->owner = THIS_MODULE;
529 entry->proc_fops = &input_handlers_fileops;
488 530
489 return 0; 531 return 0;
490 532
@@ -512,13 +554,14 @@ static ssize_t input_dev_show_##name(struct class_device *dev, char *buf) \
512 struct input_dev *input_dev = to_input_dev(dev); \ 554 struct input_dev *input_dev = to_input_dev(dev); \
513 int retval; \ 555 int retval; \
514 \ 556 \
515 retval = down_interruptible(&input_dev->sem); \ 557 retval = mutex_lock_interruptible(&input_dev->mutex); \
516 if (retval) \ 558 if (retval) \
517 return retval; \ 559 return retval; \
518 \ 560 \
519 retval = sprintf(buf, "%s\n", input_dev->name ? input_dev->name : ""); \ 561 retval = scnprintf(buf, PAGE_SIZE, \
562 "%s\n", input_dev->name ? input_dev->name : ""); \
520 \ 563 \
521 up(&input_dev->sem); \ 564 mutex_unlock(&input_dev->mutex); \
522 \ 565 \
523 return retval; \ 566 return retval; \
524} \ 567} \
@@ -528,46 +571,51 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
528INPUT_DEV_STRING_ATTR_SHOW(phys); 571INPUT_DEV_STRING_ATTR_SHOW(phys);
529INPUT_DEV_STRING_ATTR_SHOW(uniq); 572INPUT_DEV_STRING_ATTR_SHOW(uniq);
530 573
531static int print_modalias_bits(char *buf, int size, char prefix, unsigned long *arr, 574static int input_print_modalias_bits(char *buf, int size,
532 unsigned int min, unsigned int max) 575 char name, unsigned long *bm,
576 unsigned int min_bit, unsigned int max_bit)
533{ 577{
534 int len, i; 578 int len = 0, i;
535 579
536 len = snprintf(buf, size, "%c", prefix); 580 len += snprintf(buf, max(size, 0), "%c", name);
537 for (i = min; i < max; i++) 581 for (i = min_bit; i < max_bit; i++)
538 if (arr[LONG(i)] & BIT(i)) 582 if (bm[LONG(i)] & BIT(i))
539 len += snprintf(buf + len, size - len, "%X,", i); 583 len += snprintf(buf + len, max(size - len, 0), "%X,", i);
540 return len; 584 return len;
541} 585}
542 586
543static int print_modalias(char *buf, int size, struct input_dev *id) 587static int input_print_modalias(char *buf, int size, struct input_dev *id,
588 int add_cr)
544{ 589{
545 int len; 590 int len;
546 591
547 len = snprintf(buf, size, "input:b%04Xv%04Xp%04Xe%04X-", 592 len = snprintf(buf, max(size, 0),
548 id->id.bustype, 593 "input:b%04Xv%04Xp%04Xe%04X-",
549 id->id.vendor, 594 id->id.bustype, id->id.vendor,
550 id->id.product, 595 id->id.product, id->id.version);
551 id->id.version); 596
552 597 len += input_print_modalias_bits(buf + len, size - len,
553 len += print_modalias_bits(buf + len, size - len, 'e', id->evbit, 598 'e', id->evbit, 0, EV_MAX);
554 0, EV_MAX); 599 len += input_print_modalias_bits(buf + len, size - len,
555 len += print_modalias_bits(buf + len, size - len, 'k', id->keybit, 600 'k', id->keybit, KEY_MIN_INTERESTING, KEY_MAX);
556 KEY_MIN_INTERESTING, KEY_MAX); 601 len += input_print_modalias_bits(buf + len, size - len,
557 len += print_modalias_bits(buf + len, size - len, 'r', id->relbit, 602 'r', id->relbit, 0, REL_MAX);
558 0, REL_MAX); 603 len += input_print_modalias_bits(buf + len, size - len,
559 len += print_modalias_bits(buf + len, size - len, 'a', id->absbit, 604 'a', id->absbit, 0, ABS_MAX);
560 0, ABS_MAX); 605 len += input_print_modalias_bits(buf + len, size - len,
561 len += print_modalias_bits(buf + len, size - len, 'm', id->mscbit, 606 'm', id->mscbit, 0, MSC_MAX);
562 0, MSC_MAX); 607 len += input_print_modalias_bits(buf + len, size - len,
563 len += print_modalias_bits(buf + len, size - len, 'l', id->ledbit, 608 'l', id->ledbit, 0, LED_MAX);
564 0, LED_MAX); 609 len += input_print_modalias_bits(buf + len, size - len,
565 len += print_modalias_bits(buf + len, size - len, 's', id->sndbit, 610 's', id->sndbit, 0, SND_MAX);
566 0, SND_MAX); 611 len += input_print_modalias_bits(buf + len, size - len,
567 len += print_modalias_bits(buf + len, size - len, 'f', id->ffbit, 612 'f', id->ffbit, 0, FF_MAX);
568 0, FF_MAX); 613 len += input_print_modalias_bits(buf + len, size - len,
569 len += print_modalias_bits(buf + len, size - len, 'w', id->swbit, 614 'w', id->swbit, 0, SW_MAX);
570 0, SW_MAX); 615
616 if (add_cr)
617 len += snprintf(buf + len, max(size - len, 0), "\n");
618
571 return len; 619 return len;
572} 620}
573 621
@@ -576,9 +624,9 @@ static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
576 struct input_dev *id = to_input_dev(dev); 624 struct input_dev *id = to_input_dev(dev);
577 ssize_t len; 625 ssize_t len;
578 626
579 len = print_modalias(buf, PAGE_SIZE, id); 627 len = input_print_modalias(buf, PAGE_SIZE, id, 1);
580 len += snprintf(buf + len, PAGE_SIZE-len, "\n"); 628
581 return len; 629 return max_t(int, len, PAGE_SIZE);
582} 630}
583static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); 631static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
584 632
@@ -598,7 +646,7 @@ static struct attribute_group input_dev_attr_group = {
598static ssize_t input_dev_show_id_##name(struct class_device *dev, char *buf) \ 646static ssize_t input_dev_show_id_##name(struct class_device *dev, char *buf) \
599{ \ 647{ \
600 struct input_dev *input_dev = to_input_dev(dev); \ 648 struct input_dev *input_dev = to_input_dev(dev); \
601 return sprintf(buf, "%04x\n", input_dev->id.name); \ 649 return scnprintf(buf, PAGE_SIZE, "%04x\n", input_dev->id.name); \
602} \ 650} \
603static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_id_##name, NULL); 651static CLASS_DEVICE_ATTR(name, S_IRUGO, input_dev_show_id_##name, NULL);
604 652
@@ -620,11 +668,33 @@ static struct attribute_group input_dev_id_attr_group = {
620 .attrs = input_dev_id_attrs, 668 .attrs = input_dev_id_attrs,
621}; 669};
622 670
671static int input_print_bitmap(char *buf, int buf_size, unsigned long *bitmap,
672 int max, int add_cr)
673{
674 int i;
675 int len = 0;
676
677 for (i = NBITS(max) - 1; i > 0; i--)
678 if (bitmap[i])
679 break;
680
681 for (; i >= 0; i--)
682 len += snprintf(buf + len, max(buf_size - len, 0),
683 "%lx%s", bitmap[i], i > 0 ? " " : "");
684
685 if (add_cr)
686 len += snprintf(buf + len, max(buf_size - len, 0), "\n");
687
688 return len;
689}
690
623#define INPUT_DEV_CAP_ATTR(ev, bm) \ 691#define INPUT_DEV_CAP_ATTR(ev, bm) \
624static ssize_t input_dev_show_cap_##bm(struct class_device *dev, char *buf) \ 692static ssize_t input_dev_show_cap_##bm(struct class_device *dev, char *buf) \
625{ \ 693{ \
626 struct input_dev *input_dev = to_input_dev(dev); \ 694 struct input_dev *input_dev = to_input_dev(dev); \
627 return input_print_bitmap(buf, PAGE_SIZE, input_dev->bm##bit, ev##_MAX);\ 695 int len = input_print_bitmap(buf, PAGE_SIZE, \
696 input_dev->bm##bit, ev##_MAX, 1); \
697 return min_t(int, len, PAGE_SIZE); \
628} \ 698} \
629static CLASS_DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL); 699static CLASS_DEVICE_ATTR(bm, S_IRUGO, input_dev_show_cap_##bm, NULL);
630 700
@@ -669,8 +739,8 @@ static void input_dev_release(struct class_device *class_dev)
669 * device bitfields. 739 * device bitfields.
670 */ 740 */
671static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index, 741static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
672 char *buffer, int buffer_size, int *cur_len, 742 char *buffer, int buffer_size, int *cur_len,
673 const char *name, unsigned long *bitmap, int max) 743 const char *name, unsigned long *bitmap, int max)
674{ 744{
675 if (*cur_index >= num_envp - 1) 745 if (*cur_index >= num_envp - 1)
676 return -ENOMEM; 746 return -ENOMEM;
@@ -678,12 +748,36 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
678 envp[*cur_index] = buffer + *cur_len; 748 envp[*cur_index] = buffer + *cur_len;
679 749
680 *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0), name); 750 *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0), name);
681 if (*cur_len > buffer_size) 751 if (*cur_len >= buffer_size)
682 return -ENOMEM; 752 return -ENOMEM;
683 753
684 *cur_len += input_print_bitmap(buffer + *cur_len, 754 *cur_len += input_print_bitmap(buffer + *cur_len,
685 max(buffer_size - *cur_len, 0), 755 max(buffer_size - *cur_len, 0),
686 bitmap, max) + 1; 756 bitmap, max, 0) + 1;
757 if (*cur_len > buffer_size)
758 return -ENOMEM;
759
760 (*cur_index)++;
761 return 0;
762}
763
764static int input_add_uevent_modalias_var(char **envp, int num_envp, int *cur_index,
765 char *buffer, int buffer_size, int *cur_len,
766 struct input_dev *dev)
767{
768 if (*cur_index >= num_envp - 1)
769 return -ENOMEM;
770
771 envp[*cur_index] = buffer + *cur_len;
772
773 *cur_len += snprintf(buffer + *cur_len, max(buffer_size - *cur_len, 0),
774 "MODALIAS=");
775 if (*cur_len >= buffer_size)
776 return -ENOMEM;
777
778 *cur_len += input_print_modalias(buffer + *cur_len,
779 max(buffer_size - *cur_len, 0),
780 dev, 0) + 1;
687 if (*cur_len > buffer_size) 781 if (*cur_len > buffer_size)
688 return -ENOMEM; 782 return -ENOMEM;
689 783
@@ -693,7 +787,7 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
693 787
694#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \ 788#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
695 do { \ 789 do { \
696 int err = add_uevent_var(envp, num_envp, &i, \ 790 int err = add_uevent_var(envp, num_envp, &i, \
697 buffer, buffer_size, &len, \ 791 buffer, buffer_size, &len, \
698 fmt, val); \ 792 fmt, val); \
699 if (err) \ 793 if (err) \
@@ -709,6 +803,16 @@ static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
709 return err; \ 803 return err; \
710 } while (0) 804 } while (0)
711 805
806#define INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev) \
807 do { \
808 int err = input_add_uevent_modalias_var(envp, \
809 num_envp, &i, \
810 buffer, buffer_size, &len, \
811 dev); \
812 if (err) \
813 return err; \
814 } while (0)
815
712static int input_dev_uevent(struct class_device *cdev, char **envp, 816static int input_dev_uevent(struct class_device *cdev, char **envp,
713 int num_envp, char *buffer, int buffer_size) 817 int num_envp, char *buffer, int buffer_size)
714{ 818{
@@ -744,9 +848,7 @@ static int input_dev_uevent(struct class_device *cdev, char **envp,
744 if (test_bit(EV_SW, dev->evbit)) 848 if (test_bit(EV_SW, dev->evbit))
745 INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX); 849 INPUT_ADD_HOTPLUG_BM_VAR("SW=", dev->swbit, SW_MAX);
746 850
747 envp[i++] = buffer + len; 851 INPUT_ADD_HOTPLUG_MODALIAS_VAR(dev);
748 len += snprintf(buffer + len, buffer_size - len, "MODALIAS=");
749 len += print_modalias(buffer + len, buffer_size - len, dev) + 1;
750 852
751 envp[i] = NULL; 853 envp[i] = NULL;
752 return 0; 854 return 0;
@@ -790,7 +892,7 @@ int input_register_device(struct input_dev *dev)
790 return -EINVAL; 892 return -EINVAL;
791 } 893 }
792 894
793 init_MUTEX(&dev->sem); 895 mutex_init(&dev->mutex);
794 set_bit(EV_SYN, dev->evbit); 896 set_bit(EV_SYN, dev->evbit);
795 897
796 /* 898 /*
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 20e2972b9204..949bdcef8c2b 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -171,9 +171,8 @@ static int joydev_open(struct inode *inode, struct file *file)
171 if (i >= JOYDEV_MINORS || !joydev_table[i]) 171 if (i >= JOYDEV_MINORS || !joydev_table[i])
172 return -ENODEV; 172 return -ENODEV;
173 173
174 if (!(list = kmalloc(sizeof(struct joydev_list), GFP_KERNEL))) 174 if (!(list = kzalloc(sizeof(struct joydev_list), GFP_KERNEL)))
175 return -ENOMEM; 175 return -ENOMEM;
176 memset(list, 0, sizeof(struct joydev_list));
177 176
178 list->joydev = joydev_table[i]; 177 list->joydev = joydev_table[i];
179 list_add_tail(&list->node, &joydev_table[i]->list); 178 list_add_tail(&list->node, &joydev_table[i]->list);
@@ -457,9 +456,8 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
457 return NULL; 456 return NULL;
458 } 457 }
459 458
460 if (!(joydev = kmalloc(sizeof(struct joydev), GFP_KERNEL))) 459 if (!(joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL)))
461 return NULL; 460 return NULL;
462 memset(joydev, 0, sizeof(struct joydev));
463 461
464 INIT_LIST_HEAD(&joydev->list); 462 INIT_LIST_HEAD(&joydev->list);
465 init_waitqueue_head(&joydev->wait); 463 init_waitqueue_head(&joydev->wait);
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
index ec55a29fc861..7249d324297b 100644
--- a/drivers/input/joystick/amijoy.c
+++ b/drivers/input/joystick/amijoy.c
@@ -36,6 +36,7 @@
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/input.h> 37#include <linux/input.h>
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/mutex.h>
39 40
40#include <asm/system.h> 41#include <asm/system.h>
41#include <asm/amigahw.h> 42#include <asm/amigahw.h>
@@ -52,7 +53,7 @@ MODULE_PARM_DESC(map, "Map of attached joysticks in form of <a>,<b> (default is
52__obsolete_setup("amijoy="); 53__obsolete_setup("amijoy=");
53 54
54static int amijoy_used; 55static int amijoy_used;
55static DECLARE_MUTEX(amijoy_sem); 56static DEFINE_MUTEX(amijoy_mutex);
56static struct input_dev *amijoy_dev[2]; 57static struct input_dev *amijoy_dev[2];
57static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; 58static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" };
58 59
@@ -85,7 +86,7 @@ static int amijoy_open(struct input_dev *dev)
85{ 86{
86 int err; 87 int err;
87 88
88 err = down_interruptible(&amijoy_sem); 89 err = mutex_lock_interruptible(&amijoy_mutex);
89 if (err) 90 if (err)
90 return err; 91 return err;
91 92
@@ -97,16 +98,16 @@ static int amijoy_open(struct input_dev *dev)
97 98
98 amijoy_used++; 99 amijoy_used++;
99out: 100out:
100 up(&amijoy_sem); 101 mutex_unlock(&amijoy_mutex);
101 return err; 102 return err;
102} 103}
103 104
104static void amijoy_close(struct input_dev *dev) 105static void amijoy_close(struct input_dev *dev)
105{ 106{
106 down(&amijoy_sem); 107 mutex_lock(&amijoy_mutex);
107 if (!--amijoy_used) 108 if (!--amijoy_used)
108 free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt); 109 free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt);
109 up(&amijoy_sem); 110 mutex_unlock(&amijoy_mutex);
110} 111}
111 112
112static int __init amijoy_init(void) 113static int __init amijoy_init(void)
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index dcffc34f30c3..e61894685cb1 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -38,6 +38,7 @@
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/parport.h> 39#include <linux/parport.h>
40#include <linux/input.h> 40#include <linux/input.h>
41#include <linux/mutex.h>
41 42
42MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 43MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
43MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver"); 44MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver");
@@ -111,7 +112,7 @@ struct db9 {
111 struct pardevice *pd; 112 struct pardevice *pd;
112 int mode; 113 int mode;
113 int used; 114 int used;
114 struct semaphore sem; 115 struct mutex mutex;
115 char phys[DB9_MAX_DEVICES][32]; 116 char phys[DB9_MAX_DEVICES][32];
116}; 117};
117 118
@@ -525,7 +526,7 @@ static int db9_open(struct input_dev *dev)
525 struct parport *port = db9->pd->port; 526 struct parport *port = db9->pd->port;
526 int err; 527 int err;
527 528
528 err = down_interruptible(&db9->sem); 529 err = mutex_lock_interruptible(&db9->mutex);
529 if (err) 530 if (err)
530 return err; 531 return err;
531 532
@@ -539,7 +540,7 @@ static int db9_open(struct input_dev *dev)
539 mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME); 540 mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME);
540 } 541 }
541 542
542 up(&db9->sem); 543 mutex_unlock(&db9->mutex);
543 return 0; 544 return 0;
544} 545}
545 546
@@ -548,14 +549,14 @@ static void db9_close(struct input_dev *dev)
548 struct db9 *db9 = dev->private; 549 struct db9 *db9 = dev->private;
549 struct parport *port = db9->pd->port; 550 struct parport *port = db9->pd->port;
550 551
551 down(&db9->sem); 552 mutex_lock(&db9->mutex);
552 if (!--db9->used) { 553 if (!--db9->used) {
553 del_timer_sync(&db9->timer); 554 del_timer_sync(&db9->timer);
554 parport_write_control(port, 0x00); 555 parport_write_control(port, 0x00);
555 parport_data_forward(port); 556 parport_data_forward(port);
556 parport_release(db9->pd); 557 parport_release(db9->pd);
557 } 558 }
558 up(&db9->sem); 559 mutex_unlock(&db9->mutex);
559} 560}
560 561
561static struct db9 __init *db9_probe(int parport, int mode) 562static struct db9 __init *db9_probe(int parport, int mode)
@@ -603,7 +604,7 @@ static struct db9 __init *db9_probe(int parport, int mode)
603 goto err_unreg_pardev; 604 goto err_unreg_pardev;
604 } 605 }
605 606
606 init_MUTEX(&db9->sem); 607 mutex_init(&db9->mutex);
607 db9->pd = pd; 608 db9->pd = pd;
608 db9->mode = mode; 609 db9->mode = mode;
609 init_timer(&db9->timer); 610 init_timer(&db9->timer);
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index 900587acdb47..ecbdb6b9bbd6 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -7,6 +7,7 @@
7 * Based on the work of: 7 * Based on the work of:
8 * Andree Borrmann John Dahlstrom 8 * Andree Borrmann John Dahlstrom
9 * David Kuder Nathan Hand 9 * David Kuder Nathan Hand
10 * Raphael Assenat
10 */ 11 */
11 12
12/* 13/*
@@ -36,6 +37,7 @@
36#include <linux/init.h> 37#include <linux/init.h>
37#include <linux/parport.h> 38#include <linux/parport.h>
38#include <linux/input.h> 39#include <linux/input.h>
40#include <linux/mutex.h>
39 41
40MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 42MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
41MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); 43MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver");
@@ -72,8 +74,9 @@ __obsolete_setup("gc_3=");
72#define GC_N64 6 74#define GC_N64 6
73#define GC_PSX 7 75#define GC_PSX 7
74#define GC_DDR 8 76#define GC_DDR 8
77#define GC_SNESMOUSE 9
75 78
76#define GC_MAX 8 79#define GC_MAX 9
77 80
78#define GC_REFRESH_TIME HZ/100 81#define GC_REFRESH_TIME HZ/100
79 82
@@ -83,7 +86,7 @@ struct gc {
83 struct timer_list timer; 86 struct timer_list timer;
84 unsigned char pads[GC_MAX + 1]; 87 unsigned char pads[GC_MAX + 1];
85 int used; 88 int used;
86 struct semaphore sem; 89 struct mutex mutex;
87 char phys[GC_MAX_DEVICES][32]; 90 char phys[GC_MAX_DEVICES][32];
88}; 91};
89 92
@@ -93,7 +96,7 @@ static int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 };
93 96
94static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick", 97static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick",
95 "Multisystem 2-button joystick", "N64 controller", "PSX controller", 98 "Multisystem 2-button joystick", "N64 controller", "PSX controller",
96 "PSX DDR controller" }; 99 "PSX DDR controller", "SNES mouse" };
97/* 100/*
98 * N64 support. 101 * N64 support.
99 */ 102 */
@@ -205,9 +208,12 @@ static void gc_n64_process_packet(struct gc *gc)
205 * NES/SNES support. 208 * NES/SNES support.
206 */ 209 */
207 210
208#define GC_NES_DELAY 6 /* Delay between bits - 6us */ 211#define GC_NES_DELAY 6 /* Delay between bits - 6us */
209#define GC_NES_LENGTH 8 /* The NES pads use 8 bits of data */ 212#define GC_NES_LENGTH 8 /* The NES pads use 8 bits of data */
210#define GC_SNES_LENGTH 12 /* The SNES true length is 16, but the last 4 bits are unused */ 213#define GC_SNES_LENGTH 12 /* The SNES true length is 16, but the
214 last 4 bits are unused */
215#define GC_SNESMOUSE_LENGTH 32 /* The SNES mouse uses 32 bits, the first
216 16 bits are equivalent to a gamepad */
211 217
212#define GC_NES_POWER 0xfc 218#define GC_NES_POWER 0xfc
213#define GC_NES_CLOCK 0x01 219#define GC_NES_CLOCK 0x01
@@ -242,11 +248,15 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data)
242 248
243static void gc_nes_process_packet(struct gc *gc) 249static void gc_nes_process_packet(struct gc *gc)
244{ 250{
245 unsigned char data[GC_SNES_LENGTH]; 251 unsigned char data[GC_SNESMOUSE_LENGTH];
246 struct input_dev *dev; 252 struct input_dev *dev;
247 int i, j, s; 253 int i, j, s, len;
254 char x_rel, y_rel;
255
256 len = gc->pads[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH :
257 (gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH);
248 258
249 gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); 259 gc_nes_read_packet(gc, len, data);
250 260
251 for (i = 0; i < GC_MAX_DEVICES; i++) { 261 for (i = 0; i < GC_MAX_DEVICES; i++) {
252 262
@@ -269,6 +279,44 @@ static void gc_nes_process_packet(struct gc *gc)
269 for (j = 0; j < 8; j++) 279 for (j = 0; j < 8; j++)
270 input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); 280 input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]);
271 281
282 if (s & gc->pads[GC_SNESMOUSE]) {
283 /*
284 * The 4 unused bits from SNES controllers appear to be ID bits
285 * so use them to make sure iwe are dealing with a mouse.
286 * gamepad is connected. This is important since
287 * my SNES gamepad sends 1's for bits 16-31, which
288 * cause the mouse pointer to quickly move to the
289 * upper left corner of the screen.
290 */
291 if (!(s & data[12]) && !(s & data[13]) &&
292 !(s & data[14]) && (s & data[15])) {
293 input_report_key(dev, BTN_LEFT, s & data[9]);
294 input_report_key(dev, BTN_RIGHT, s & data[8]);
295
296 x_rel = y_rel = 0;
297 for (j = 0; j < 7; j++) {
298 x_rel <<= 1;
299 if (data[25 + j] & s)
300 x_rel |= 1;
301
302 y_rel <<= 1;
303 if (data[17 + j] & s)
304 y_rel |= 1;
305 }
306
307 if (x_rel) {
308 if (data[24] & s)
309 x_rel = -x_rel;
310 input_report_rel(dev, REL_X, x_rel);
311 }
312
313 if (y_rel) {
314 if (data[16] & s)
315 y_rel = -y_rel;
316 input_report_rel(dev, REL_Y, y_rel);
317 }
318 }
319 }
272 input_sync(dev); 320 input_sync(dev);
273 } 321 }
274} 322}
@@ -524,10 +572,10 @@ static void gc_timer(unsigned long private)
524 gc_n64_process_packet(gc); 572 gc_n64_process_packet(gc);
525 573
526/* 574/*
527 * NES and SNES pads 575 * NES and SNES pads or mouse
528 */ 576 */
529 577
530 if (gc->pads[GC_NES] || gc->pads[GC_SNES]) 578 if (gc->pads[GC_NES] || gc->pads[GC_SNES] || gc->pads[GC_SNESMOUSE])
531 gc_nes_process_packet(gc); 579 gc_nes_process_packet(gc);
532 580
533/* 581/*
@@ -552,7 +600,7 @@ static int gc_open(struct input_dev *dev)
552 struct gc *gc = dev->private; 600 struct gc *gc = dev->private;
553 int err; 601 int err;
554 602
555 err = down_interruptible(&gc->sem); 603 err = mutex_lock_interruptible(&gc->mutex);
556 if (err) 604 if (err)
557 return err; 605 return err;
558 606
@@ -562,7 +610,7 @@ static int gc_open(struct input_dev *dev)
562 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); 610 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
563 } 611 }
564 612
565 up(&gc->sem); 613 mutex_unlock(&gc->mutex);
566 return 0; 614 return 0;
567} 615}
568 616
@@ -570,13 +618,13 @@ static void gc_close(struct input_dev *dev)
570{ 618{
571 struct gc *gc = dev->private; 619 struct gc *gc = dev->private;
572 620
573 down(&gc->sem); 621 mutex_lock(&gc->mutex);
574 if (!--gc->used) { 622 if (!--gc->used) {
575 del_timer_sync(&gc->timer); 623 del_timer_sync(&gc->timer);
576 parport_write_control(gc->pd->port, 0x00); 624 parport_write_control(gc->pd->port, 0x00);
577 parport_release(gc->pd); 625 parport_release(gc->pd);
578 } 626 }
579 up(&gc->sem); 627 mutex_unlock(&gc->mutex);
580} 628}
581 629
582static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) 630static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
@@ -609,10 +657,13 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
609 input_dev->open = gc_open; 657 input_dev->open = gc_open;
610 input_dev->close = gc_close; 658 input_dev->close = gc_close;
611 659
612 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 660 if (pad_type != GC_SNESMOUSE) {
661 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
613 662
614 for (i = 0; i < 2; i++) 663 for (i = 0; i < 2; i++)
615 input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); 664 input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0);
665 } else
666 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
616 667
617 gc->pads[0] |= gc_status_bit[idx]; 668 gc->pads[0] |= gc_status_bit[idx];
618 gc->pads[pad_type] |= gc_status_bit[idx]; 669 gc->pads[pad_type] |= gc_status_bit[idx];
@@ -630,6 +681,13 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
630 681
631 break; 682 break;
632 683
684 case GC_SNESMOUSE:
685 set_bit(BTN_LEFT, input_dev->keybit);
686 set_bit(BTN_RIGHT, input_dev->keybit);
687 set_bit(REL_X, input_dev->relbit);
688 set_bit(REL_Y, input_dev->relbit);
689 break;
690
633 case GC_SNES: 691 case GC_SNES:
634 for (i = 4; i < 8; i++) 692 for (i = 4; i < 8; i++)
635 set_bit(gc_snes_btn[i], input_dev->keybit); 693 set_bit(gc_snes_btn[i], input_dev->keybit);
@@ -693,7 +751,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
693 goto err_unreg_pardev; 751 goto err_unreg_pardev;
694 } 752 }
695 753
696 init_MUTEX(&gc->sem); 754 mutex_init(&gc->mutex);
697 gc->pd = pd; 755 gc->pd = pd;
698 init_timer(&gc->timer); 756 init_timer(&gc->timer);
699 gc->timer.data = (long) gc; 757 gc->timer.data = (long) gc;
diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c
index 4678b6dab43b..2b8e8456c9fa 100644
--- a/drivers/input/joystick/iforce/iforce-ff.c
+++ b/drivers/input/joystick/iforce/iforce-ff.c
@@ -42,14 +42,14 @@ static int make_magnitude_modifier(struct iforce* iforce,
42 unsigned char data[3]; 42 unsigned char data[3];
43 43
44 if (!no_alloc) { 44 if (!no_alloc) {
45 down(&iforce->mem_mutex); 45 mutex_lock(&iforce->mem_mutex);
46 if (allocate_resource(&(iforce->device_memory), mod_chunk, 2, 46 if (allocate_resource(&(iforce->device_memory), mod_chunk, 2,
47 iforce->device_memory.start, iforce->device_memory.end, 2L, 47 iforce->device_memory.start, iforce->device_memory.end, 2L,
48 NULL, NULL)) { 48 NULL, NULL)) {
49 up(&iforce->mem_mutex); 49 mutex_unlock(&iforce->mem_mutex);
50 return -ENOMEM; 50 return -ENOMEM;
51 } 51 }
52 up(&iforce->mem_mutex); 52 mutex_unlock(&iforce->mem_mutex);
53 } 53 }
54 54
55 data[0] = LO(mod_chunk->start); 55 data[0] = LO(mod_chunk->start);
@@ -75,14 +75,14 @@ static int make_period_modifier(struct iforce* iforce,
75 period = TIME_SCALE(period); 75 period = TIME_SCALE(period);
76 76
77 if (!no_alloc) { 77 if (!no_alloc) {
78 down(&iforce->mem_mutex); 78 mutex_lock(&iforce->mem_mutex);
79 if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0c, 79 if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0c,
80 iforce->device_memory.start, iforce->device_memory.end, 2L, 80 iforce->device_memory.start, iforce->device_memory.end, 2L,
81 NULL, NULL)) { 81 NULL, NULL)) {
82 up(&iforce->mem_mutex); 82 mutex_unlock(&iforce->mem_mutex);
83 return -ENOMEM; 83 return -ENOMEM;
84 } 84 }
85 up(&iforce->mem_mutex); 85 mutex_unlock(&iforce->mem_mutex);
86 } 86 }
87 87
88 data[0] = LO(mod_chunk->start); 88 data[0] = LO(mod_chunk->start);
@@ -115,14 +115,14 @@ static int make_envelope_modifier(struct iforce* iforce,
115 fade_duration = TIME_SCALE(fade_duration); 115 fade_duration = TIME_SCALE(fade_duration);
116 116
117 if (!no_alloc) { 117 if (!no_alloc) {
118 down(&iforce->mem_mutex); 118 mutex_lock(&iforce->mem_mutex);
119 if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e, 119 if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e,
120 iforce->device_memory.start, iforce->device_memory.end, 2L, 120 iforce->device_memory.start, iforce->device_memory.end, 2L,
121 NULL, NULL)) { 121 NULL, NULL)) {
122 up(&iforce->mem_mutex); 122 mutex_unlock(&iforce->mem_mutex);
123 return -ENOMEM; 123 return -ENOMEM;
124 } 124 }
125 up(&iforce->mem_mutex); 125 mutex_unlock(&iforce->mem_mutex);
126 } 126 }
127 127
128 data[0] = LO(mod_chunk->start); 128 data[0] = LO(mod_chunk->start);
@@ -152,14 +152,14 @@ static int make_condition_modifier(struct iforce* iforce,
152 unsigned char data[10]; 152 unsigned char data[10];
153 153
154 if (!no_alloc) { 154 if (!no_alloc) {
155 down(&iforce->mem_mutex); 155 mutex_lock(&iforce->mem_mutex);
156 if (allocate_resource(&(iforce->device_memory), mod_chunk, 8, 156 if (allocate_resource(&(iforce->device_memory), mod_chunk, 8,
157 iforce->device_memory.start, iforce->device_memory.end, 2L, 157 iforce->device_memory.start, iforce->device_memory.end, 2L,
158 NULL, NULL)) { 158 NULL, NULL)) {
159 up(&iforce->mem_mutex); 159 mutex_unlock(&iforce->mem_mutex);
160 return -ENOMEM; 160 return -ENOMEM;
161 } 161 }
162 up(&iforce->mem_mutex); 162 mutex_unlock(&iforce->mem_mutex);
163 } 163 }
164 164
165 data[0] = LO(mod_chunk->start); 165 data[0] = LO(mod_chunk->start);
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index b6bc04998047..ab0a26b924ca 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -350,7 +350,7 @@ int iforce_init_device(struct iforce *iforce)
350 350
351 init_waitqueue_head(&iforce->wait); 351 init_waitqueue_head(&iforce->wait);
352 spin_lock_init(&iforce->xmit_lock); 352 spin_lock_init(&iforce->xmit_lock);
353 init_MUTEX(&iforce->mem_mutex); 353 mutex_init(&iforce->mem_mutex);
354 iforce->xmit.buf = iforce->xmit_data; 354 iforce->xmit.buf = iforce->xmit_data;
355 iforce->dev = input_dev; 355 iforce->dev = input_dev;
356 356
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h
index 146f406b8f8a..668f24535ba0 100644
--- a/drivers/input/joystick/iforce/iforce.h
+++ b/drivers/input/joystick/iforce/iforce.h
@@ -37,7 +37,7 @@
37#include <linux/serio.h> 37#include <linux/serio.h>
38#include <linux/config.h> 38#include <linux/config.h>
39#include <linux/circ_buf.h> 39#include <linux/circ_buf.h>
40#include <asm/semaphore.h> 40#include <linux/mutex.h>
41 41
42/* This module provides arbitrary resource management routines. 42/* This module provides arbitrary resource management routines.
43 * I use it to manage the device's memory. 43 * I use it to manage the device's memory.
@@ -45,6 +45,7 @@
45 */ 45 */
46#include <linux/ioport.h> 46#include <linux/ioport.h>
47 47
48
48#define IFORCE_MAX_LENGTH 16 49#define IFORCE_MAX_LENGTH 16
49 50
50/* iforce::bus */ 51/* iforce::bus */
@@ -146,7 +147,7 @@ struct iforce {
146 wait_queue_head_t wait; 147 wait_queue_head_t wait;
147 struct resource device_memory; 148 struct resource device_memory;
148 struct iforce_core_effect core_effects[FF_EFFECTS_MAX]; 149 struct iforce_core_effect core_effects[FF_EFFECTS_MAX];
149 struct semaphore mem_mutex; 150 struct mutex mem_mutex;
150}; 151};
151 152
152/* Get hi and low bytes of a 16-bits int */ 153/* Get hi and low bytes of a 16-bits int */
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index b154938e88a4..5570fd5487c7 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -37,6 +37,7 @@
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/mutex.h>
40 41
41MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 42MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
42MODULE_DESCRIPTION("TurboGraFX parallel port interface driver"); 43MODULE_DESCRIPTION("TurboGraFX parallel port interface driver");
@@ -86,7 +87,7 @@ static struct tgfx {
86 char phys[TGFX_MAX_DEVICES][32]; 87 char phys[TGFX_MAX_DEVICES][32];
87 int sticks; 88 int sticks;
88 int used; 89 int used;
89 struct semaphore sem; 90 struct mutex sem;
90} *tgfx_base[TGFX_MAX_PORTS]; 91} *tgfx_base[TGFX_MAX_PORTS];
91 92
92/* 93/*
@@ -128,7 +129,7 @@ static int tgfx_open(struct input_dev *dev)
128 struct tgfx *tgfx = dev->private; 129 struct tgfx *tgfx = dev->private;
129 int err; 130 int err;
130 131
131 err = down_interruptible(&tgfx->sem); 132 err = mutex_lock_interruptible(&tgfx->sem);
132 if (err) 133 if (err)
133 return err; 134 return err;
134 135
@@ -138,7 +139,7 @@ static int tgfx_open(struct input_dev *dev)
138 mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); 139 mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME);
139 } 140 }
140 141
141 up(&tgfx->sem); 142 mutex_unlock(&tgfx->sem);
142 return 0; 143 return 0;
143} 144}
144 145
@@ -146,13 +147,13 @@ static void tgfx_close(struct input_dev *dev)
146{ 147{
147 struct tgfx *tgfx = dev->private; 148 struct tgfx *tgfx = dev->private;
148 149
149 down(&tgfx->sem); 150 mutex_lock(&tgfx->sem);
150 if (!--tgfx->used) { 151 if (!--tgfx->used) {
151 del_timer_sync(&tgfx->timer); 152 del_timer_sync(&tgfx->timer);
152 parport_write_control(tgfx->pd->port, 0x00); 153 parport_write_control(tgfx->pd->port, 0x00);
153 parport_release(tgfx->pd); 154 parport_release(tgfx->pd);
154 } 155 }
155 up(&tgfx->sem); 156 mutex_unlock(&tgfx->sem);
156} 157}
157 158
158 159
@@ -191,7 +192,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
191 goto err_unreg_pardev; 192 goto err_unreg_pardev;
192 } 193 }
193 194
194 init_MUTEX(&tgfx->sem); 195 mutex_init(&tgfx->sem);
195 tgfx->pd = pd; 196 tgfx->pd = pd;
196 init_timer(&tgfx->timer); 197 init_timer(&tgfx->timer);
197 tgfx->timer.data = (long) tgfx; 198 tgfx->timer.data = (long) tgfx;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 3b0ac3b43c54..a9dda56f62c4 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -13,7 +13,7 @@ menuconfig INPUT_KEYBOARD
13if INPUT_KEYBOARD 13if INPUT_KEYBOARD
14 14
15config KEYBOARD_ATKBD 15config KEYBOARD_ATKBD
16 tristate "AT keyboard" if !X86_PC 16 tristate "AT keyboard" if EMBEDDED || !X86_PC
17 default y 17 default y
18 select SERIO 18 select SERIO
19 select SERIO_LIBPS2 19 select SERIO_LIBPS2
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ffacf6eca5f5..fad04b66d268 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -27,6 +27,7 @@
27#include <linux/serio.h> 27#include <linux/serio.h>
28#include <linux/workqueue.h> 28#include <linux/workqueue.h>
29#include <linux/libps2.h> 29#include <linux/libps2.h>
30#include <linux/mutex.h>
30 31
31#define DRIVER_DESC "AT and PS/2 keyboard driver" 32#define DRIVER_DESC "AT and PS/2 keyboard driver"
32 33
@@ -216,7 +217,7 @@ struct atkbd {
216 unsigned long time; 217 unsigned long time;
217 218
218 struct work_struct event_work; 219 struct work_struct event_work;
219 struct semaphore event_sem; 220 struct mutex event_mutex;
220 unsigned long event_mask; 221 unsigned long event_mask;
221}; 222};
222 223
@@ -302,19 +303,19 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
302 if (atkbd->translated) { 303 if (atkbd->translated) {
303 304
304 if (atkbd->emul || 305 if (atkbd->emul ||
305 !(code == ATKBD_RET_EMUL0 || code == ATKBD_RET_EMUL1 || 306 (code != ATKBD_RET_EMUL0 && code != ATKBD_RET_EMUL1 &&
306 code == ATKBD_RET_HANGUEL || code == ATKBD_RET_HANJA || 307 code != ATKBD_RET_HANGUEL && code != ATKBD_RET_HANJA &&
307 (code == ATKBD_RET_ERR && !atkbd->err_xl) || 308 (code != ATKBD_RET_ERR || atkbd->err_xl) &&
308 (code == ATKBD_RET_BAT && !atkbd->bat_xl))) { 309 (code != ATKBD_RET_BAT || atkbd->bat_xl))) {
309 atkbd->release = code >> 7; 310 atkbd->release = code >> 7;
310 code &= 0x7f; 311 code &= 0x7f;
311 } 312 }
312 313
313 if (!atkbd->emul) { 314 if (!atkbd->emul) {
314 if ((code & 0x7f) == (ATKBD_RET_BAT & 0x7f)) 315 if ((code & 0x7f) == (ATKBD_RET_BAT & 0x7f))
315 atkbd->bat_xl = !atkbd->release; 316 atkbd->bat_xl = !(data >> 7);
316 if ((code & 0x7f) == (ATKBD_RET_ERR & 0x7f)) 317 if ((code & 0x7f) == (ATKBD_RET_ERR & 0x7f))
317 atkbd->err_xl = !atkbd->release; 318 atkbd->err_xl = !(data >> 7);
318 } 319 }
319 } 320 }
320 321
@@ -449,7 +450,7 @@ static void atkbd_event_work(void *data)
449 unsigned char param[2]; 450 unsigned char param[2];
450 int i, j; 451 int i, j;
451 452
452 down(&atkbd->event_sem); 453 mutex_lock(&atkbd->event_mutex);
453 454
454 if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask)) { 455 if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask)) {
455 param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0) 456 param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0)
@@ -480,7 +481,7 @@ static void atkbd_event_work(void *data)
480 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP); 481 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP);
481 } 482 }
482 483
483 up(&atkbd->event_sem); 484 mutex_unlock(&atkbd->event_mutex);
484} 485}
485 486
486/* 487/*
@@ -846,7 +847,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
846 atkbd->dev = dev; 847 atkbd->dev = dev;
847 ps2_init(&atkbd->ps2dev, serio); 848 ps2_init(&atkbd->ps2dev, serio);
848 INIT_WORK(&atkbd->event_work, atkbd_event_work, atkbd); 849 INIT_WORK(&atkbd->event_work, atkbd_event_work, atkbd);
849 init_MUTEX(&atkbd->event_sem); 850 mutex_init(&atkbd->event_mutex);
850 851
851 switch (serio->id.type) { 852 switch (serio->id.type) {
852 853
@@ -862,9 +863,6 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
862 atkbd->softrepeat = atkbd_softrepeat; 863 atkbd->softrepeat = atkbd_softrepeat;
863 atkbd->scroll = atkbd_scroll; 864 atkbd->scroll = atkbd_scroll;
864 865
865 if (!atkbd->write)
866 atkbd->softrepeat = 1;
867
868 if (atkbd->softrepeat) 866 if (atkbd->softrepeat)
869 atkbd->softraw = 1; 867 atkbd->softraw = 1;
870 868
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index e301ee4ca264..96c6bf77248a 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -29,11 +29,11 @@
29#define KB_COLS 12 29#define KB_COLS 12
30#define KB_ROWMASK(r) (1 << (r)) 30#define KB_ROWMASK(r) (1 << (r))
31#define SCANCODE(r,c) ( ((r)<<4) + (c) + 1 ) 31#define SCANCODE(r,c) ( ((r)<<4) + (c) + 1 )
32/* zero code, 124 scancodes + 3 hinge combinations */ 32/* zero code, 124 scancodes */
33#define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 +3 ) 33#define NR_SCANCODES ( SCANCODE(KB_ROWS-1,KB_COLS-1) +1 +1 )
34#define SCAN_INTERVAL (HZ/10)
35 34
36#define HINGE_SCAN_INTERVAL (HZ/4) 35#define SCAN_INTERVAL (50) /* ms */
36#define HINGE_SCAN_INTERVAL (250) /* ms */
37 37
38#define CORGI_KEY_CALENDER KEY_F1 38#define CORGI_KEY_CALENDER KEY_F1
39#define CORGI_KEY_ADDRESS KEY_F2 39#define CORGI_KEY_ADDRESS KEY_F2
@@ -49,9 +49,6 @@
49#define CORGI_KEY_MAIL KEY_F10 49#define CORGI_KEY_MAIL KEY_F10
50#define CORGI_KEY_OK KEY_F11 50#define CORGI_KEY_OK KEY_F11
51#define CORGI_KEY_MENU KEY_F12 51#define CORGI_KEY_MENU KEY_F12
52#define CORGI_HINGE_0 KEY_KP0
53#define CORGI_HINGE_1 KEY_KP1
54#define CORGI_HINGE_2 KEY_KP2
55 52
56static unsigned char corgikbd_keycode[NR_SCANCODES] = { 53static unsigned char corgikbd_keycode[NR_SCANCODES] = {
57 0, /* 0 */ 54 0, /* 0 */
@@ -63,7 +60,6 @@ static unsigned char corgikbd_keycode[NR_SCANCODES] = {
63 CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */ 60 CORGI_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, 0, CORGI_KEY_FN, 0, 0, 0, 0, /* 81-96 */
64 KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */ 61 KEY_SYSRQ, CORGI_KEY_JAP1, CORGI_KEY_JAP2, CORGI_KEY_CANCEL, CORGI_KEY_OK, CORGI_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0, /* 97-112 */
65 CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */ 62 CORGI_KEY_OFF, CORGI_KEY_EXOK, CORGI_KEY_EXCANCEL, CORGI_KEY_EXJOGDOWN, CORGI_KEY_EXJOGUP, 0, 0, 0, 0, 0, 0, 0, /* 113-124 */
66 CORGI_HINGE_0, CORGI_HINGE_1, CORGI_HINGE_2 /* 125-127 */
67}; 63};
68 64
69 65
@@ -187,7 +183,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs
187 183
188 /* if any keys are pressed, enable the timer */ 184 /* if any keys are pressed, enable the timer */
189 if (num_pressed) 185 if (num_pressed)
190 mod_timer(&corgikbd_data->timer, jiffies + SCAN_INTERVAL); 186 mod_timer(&corgikbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL));
191 187
192 spin_unlock_irqrestore(&corgikbd_data->lock, flags); 188 spin_unlock_irqrestore(&corgikbd_data->lock, flags);
193} 189}
@@ -228,6 +224,7 @@ static void corgikbd_timer_callback(unsigned long data)
228 * 0x0c - Keyboard and Screen Closed 224 * 0x0c - Keyboard and Screen Closed
229 */ 225 */
230 226
227#define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x))
231#define HINGE_STABLE_COUNT 2 228#define HINGE_STABLE_COUNT 2
232static int sharpsl_hinge_state; 229static int sharpsl_hinge_state;
233static int hinge_count; 230static int hinge_count;
@@ -239,6 +236,7 @@ static void corgikbd_hinge_timer(unsigned long data)
239 unsigned long flags; 236 unsigned long flags;
240 237
241 gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB); 238 gprr = read_scoop_reg(&corgiscoop_device.dev, SCOOP_GPRR) & (CORGI_SCP_SWA | CORGI_SCP_SWB);
239 gprr |= (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0);
242 if (gprr != sharpsl_hinge_state) { 240 if (gprr != sharpsl_hinge_state) {
243 hinge_count = 0; 241 hinge_count = 0;
244 sharpsl_hinge_state = gprr; 242 sharpsl_hinge_state = gprr;
@@ -249,27 +247,38 @@ static void corgikbd_hinge_timer(unsigned long data)
249 247
250 input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); 248 input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0));
251 input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); 249 input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0));
250 input_report_switch(corgikbd_data->input, SW_2, (READ_GPIO_BIT(CORGI_GPIO_AK_INT) != 0));
252 input_sync(corgikbd_data->input); 251 input_sync(corgikbd_data->input);
253 252
254 spin_unlock_irqrestore(&corgikbd_data->lock, flags); 253 spin_unlock_irqrestore(&corgikbd_data->lock, flags);
255 } 254 }
256 } 255 }
257 mod_timer(&corgikbd_data->htimer, jiffies + HINGE_SCAN_INTERVAL); 256 mod_timer(&corgikbd_data->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
258} 257}
259 258
260#ifdef CONFIG_PM 259#ifdef CONFIG_PM
261static int corgikbd_suspend(struct platform_device *dev, pm_message_t state) 260static int corgikbd_suspend(struct platform_device *dev, pm_message_t state)
262{ 261{
262 int i;
263 struct corgikbd *corgikbd = platform_get_drvdata(dev); 263 struct corgikbd *corgikbd = platform_get_drvdata(dev);
264
264 corgikbd->suspended = 1; 265 corgikbd->suspended = 1;
266 /* strobe 0 is the power key so this can't be made an input for
267 powersaving therefore i = 1 */
268 for (i = 1; i < CORGI_KEY_STROBE_NUM; i++)
269 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_IN);
265 270
266 return 0; 271 return 0;
267} 272}
268 273
269static int corgikbd_resume(struct platform_device *dev) 274static int corgikbd_resume(struct platform_device *dev)
270{ 275{
276 int i;
271 struct corgikbd *corgikbd = platform_get_drvdata(dev); 277 struct corgikbd *corgikbd = platform_get_drvdata(dev);
272 278
279 for (i = 1; i < CORGI_KEY_STROBE_NUM; i++)
280 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
281
273 /* Upon resume, ignore the suspend key for a short while */ 282 /* Upon resume, ignore the suspend key for a short while */
274 corgikbd->suspend_jiffies=jiffies; 283 corgikbd->suspend_jiffies=jiffies;
275 corgikbd->suspended = 0; 284 corgikbd->suspended = 0;
@@ -333,10 +342,11 @@ static int __init corgikbd_probe(struct platform_device *pdev)
333 clear_bit(0, input_dev->keybit); 342 clear_bit(0, input_dev->keybit);
334 set_bit(SW_0, input_dev->swbit); 343 set_bit(SW_0, input_dev->swbit);
335 set_bit(SW_1, input_dev->swbit); 344 set_bit(SW_1, input_dev->swbit);
345 set_bit(SW_2, input_dev->swbit);
336 346
337 input_register_device(corgikbd->input); 347 input_register_device(corgikbd->input);
338 348
339 mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); 349 mod_timer(&corgikbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
340 350
341 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ 351 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
342 for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) { 352 for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) {
@@ -351,6 +361,9 @@ static int __init corgikbd_probe(struct platform_device *pdev)
351 for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) 361 for (i = 0; i < CORGI_KEY_STROBE_NUM; i++)
352 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); 362 pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH);
353 363
364 /* Setup the headphone jack as an input */
365 pxa_gpio_mode(CORGI_GPIO_AK_INT | GPIO_IN);
366
354 return 0; 367 return 0;
355} 368}
356 369
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
index 63f387e4b783..1dca3cf42a54 100644
--- a/drivers/input/keyboard/hil_kbd.c
+++ b/drivers/input/keyboard/hil_kbd.c
@@ -250,16 +250,19 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
250 struct hil_kbd *kbd; 250 struct hil_kbd *kbd;
251 uint8_t did, *idd; 251 uint8_t did, *idd;
252 int i; 252 int i;
253 253
254 kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); 254 kbd = kzalloc(sizeof(*kbd), GFP_KERNEL);
255 if (!kbd) 255 if (!kbd)
256 return -ENOMEM; 256 return -ENOMEM;
257 257
258 kbd->dev = input_allocate_device(); 258 kbd->dev = input_allocate_device();
259 if (!kbd->dev) goto bail1; 259 if (!kbd->dev)
260 goto bail0;
261
260 kbd->dev->private = kbd; 262 kbd->dev->private = kbd;
261 263
262 if (serio_open(serio, drv)) goto bail0; 264 if (serio_open(serio, drv))
265 goto bail1;
263 266
264 serio_set_drvdata(serio, kbd); 267 serio_set_drvdata(serio, kbd);
265 kbd->serio = serio; 268 kbd->serio = serio;
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 83999d583122..bc61cf8cfc65 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -30,6 +30,7 @@
30#define SCANCODE(r,c) (((r)<<4) + (c) + 1) 30#define SCANCODE(r,c) (((r)<<4) + (c) + 1)
31#define NR_SCANCODES ((KB_ROWS<<4) + 1) 31#define NR_SCANCODES ((KB_ROWS<<4) + 1)
32 32
33#define SCAN_INTERVAL (50) /* ms */
33#define HINGE_SCAN_INTERVAL (150) /* ms */ 34#define HINGE_SCAN_INTERVAL (150) /* ms */
34 35
35#define SPITZ_KEY_CALENDER KEY_F1 36#define SPITZ_KEY_CALENDER KEY_F1
@@ -230,7 +231,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs
230 231
231 /* if any keys are pressed, enable the timer */ 232 /* if any keys are pressed, enable the timer */
232 if (num_pressed) 233 if (num_pressed)
233 mod_timer(&spitzkbd_data->timer, jiffies + msecs_to_jiffies(100)); 234 mod_timer(&spitzkbd_data->timer, jiffies + msecs_to_jiffies(SCAN_INTERVAL));
234 235
235 spin_unlock_irqrestore(&spitzkbd_data->lock, flags); 236 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
236} 237}
@@ -287,6 +288,7 @@ static void spitzkbd_hinge_timer(unsigned long data)
287 unsigned long flags; 288 unsigned long flags;
288 289
289 state = GPLR(SPITZ_GPIO_SWA) & (GPIO_bit(SPITZ_GPIO_SWA)|GPIO_bit(SPITZ_GPIO_SWB)); 290 state = GPLR(SPITZ_GPIO_SWA) & (GPIO_bit(SPITZ_GPIO_SWA)|GPIO_bit(SPITZ_GPIO_SWB));
291 state |= (GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT));
290 if (state != sharpsl_hinge_state) { 292 if (state != sharpsl_hinge_state) {
291 hinge_count = 0; 293 hinge_count = 0;
292 sharpsl_hinge_state = state; 294 sharpsl_hinge_state = state;
@@ -299,6 +301,7 @@ static void spitzkbd_hinge_timer(unsigned long data)
299 301
300 input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); 302 input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
301 input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); 303 input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
304 input_report_switch(spitzkbd_data->input, SW_2, ((GPLR(SPITZ_GPIO_AK_INT) & GPIO_bit(SPITZ_GPIO_AK_INT)) != 0));
302 input_sync(spitzkbd_data->input); 305 input_sync(spitzkbd_data->input);
303 306
304 spin_unlock_irqrestore(&spitzkbd_data->lock, flags); 307 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
@@ -397,6 +400,7 @@ static int __init spitzkbd_probe(struct platform_device *dev)
397 clear_bit(0, input_dev->keybit); 400 clear_bit(0, input_dev->keybit);
398 set_bit(SW_0, input_dev->swbit); 401 set_bit(SW_0, input_dev->swbit);
399 set_bit(SW_1, input_dev->swbit); 402 set_bit(SW_1, input_dev->swbit);
403 set_bit(SW_2, input_dev->swbit);
400 404
401 input_register_device(input_dev); 405 input_register_device(input_dev);
402 406
@@ -432,6 +436,9 @@ static int __init spitzkbd_probe(struct platform_device *dev)
432 request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, 436 request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr,
433 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING, 437 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
434 "Spitzkbd SWB", spitzkbd); 438 "Spitzkbd SWB", spitzkbd);
439 request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr,
440 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
441 "Spitzkbd HP", spitzkbd);
435 442
436 printk(KERN_INFO "input: Spitz Keyboard Registered\n"); 443 printk(KERN_INFO "input: Spitz Keyboard Registered\n");
437 444
@@ -450,6 +457,7 @@ static int spitzkbd_remove(struct platform_device *dev)
450 free_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd); 457 free_irq(SPITZ_IRQ_GPIO_ON_KEY, spitzkbd);
451 free_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd); 458 free_irq(SPITZ_IRQ_GPIO_SWA, spitzkbd);
452 free_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd); 459 free_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd);
460 free_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd);
453 461
454 del_timer_sync(&spitzkbd->htimer); 462 del_timer_sync(&spitzkbd->htimer);
455 del_timer_sync(&spitzkbd->timer); 463 del_timer_sync(&spitzkbd->timer);
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c
index 1ef477f4469c..afd322185bbf 100644
--- a/drivers/input/misc/pcspkr.c
+++ b/drivers/input/misc/pcspkr.c
@@ -24,7 +24,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
24MODULE_DESCRIPTION("PC Speaker beeper driver"); 24MODULE_DESCRIPTION("PC Speaker beeper driver");
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26 26
27static struct platform_device *pcspkr_platform_device;
28static DEFINE_SPINLOCK(i8253_beep_lock); 27static DEFINE_SPINLOCK(i8253_beep_lock);
29 28
30static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 29static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
@@ -135,35 +134,11 @@ static struct platform_driver pcspkr_platform_driver = {
135 134
136static int __init pcspkr_init(void) 135static int __init pcspkr_init(void)
137{ 136{
138 int err; 137 return platform_driver_register(&pcspkr_platform_driver);
139
140 err = platform_driver_register(&pcspkr_platform_driver);
141 if (err)
142 return err;
143
144 pcspkr_platform_device = platform_device_alloc("pcspkr", -1);
145 if (!pcspkr_platform_device) {
146 err = -ENOMEM;
147 goto err_unregister_driver;
148 }
149
150 err = platform_device_add(pcspkr_platform_device);
151 if (err)
152 goto err_free_device;
153
154 return 0;
155
156 err_free_device:
157 platform_device_put(pcspkr_platform_device);
158 err_unregister_driver:
159 platform_driver_unregister(&pcspkr_platform_driver);
160
161 return err;
162} 138}
163 139
164static void __exit pcspkr_exit(void) 140static void __exit pcspkr_exit(void)
165{ 141{
166 platform_device_unregister(pcspkr_platform_device);
167 platform_driver_unregister(&pcspkr_platform_driver); 142 platform_driver_unregister(&pcspkr_platform_driver);
168} 143}
169 144
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 546ed9b4901d..d723e9ad7c41 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -194,7 +194,7 @@ static int uinput_open(struct inode *inode, struct file *file)
194 if (!newdev) 194 if (!newdev)
195 return -ENOMEM; 195 return -ENOMEM;
196 196
197 init_MUTEX(&newdev->sem); 197 mutex_init(&newdev->mutex);
198 spin_lock_init(&newdev->requests_lock); 198 spin_lock_init(&newdev->requests_lock);
199 init_waitqueue_head(&newdev->requests_waitq); 199 init_waitqueue_head(&newdev->requests_waitq);
200 init_waitqueue_head(&newdev->waitq); 200 init_waitqueue_head(&newdev->waitq);
@@ -340,7 +340,7 @@ static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t
340 struct uinput_device *udev = file->private_data; 340 struct uinput_device *udev = file->private_data;
341 int retval; 341 int retval;
342 342
343 retval = down_interruptible(&udev->sem); 343 retval = mutex_lock_interruptible(&udev->mutex);
344 if (retval) 344 if (retval)
345 return retval; 345 return retval;
346 346
@@ -348,7 +348,7 @@ static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t
348 uinput_inject_event(udev, buffer, count) : 348 uinput_inject_event(udev, buffer, count) :
349 uinput_setup_device(udev, buffer, count); 349 uinput_setup_device(udev, buffer, count);
350 350
351 up(&udev->sem); 351 mutex_unlock(&udev->mutex);
352 352
353 return retval; 353 return retval;
354} 354}
@@ -369,7 +369,7 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count,
369 if (retval) 369 if (retval)
370 return retval; 370 return retval;
371 371
372 retval = down_interruptible(&udev->sem); 372 retval = mutex_lock_interruptible(&udev->mutex);
373 if (retval) 373 if (retval)
374 return retval; 374 return retval;
375 375
@@ -388,7 +388,7 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count,
388 } 388 }
389 389
390 out: 390 out:
391 up(&udev->sem); 391 mutex_unlock(&udev->mutex);
392 392
393 return retval; 393 return retval;
394} 394}
@@ -439,7 +439,7 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
439 439
440 udev = file->private_data; 440 udev = file->private_data;
441 441
442 retval = down_interruptible(&udev->sem); 442 retval = mutex_lock_interruptible(&udev->mutex);
443 if (retval) 443 if (retval)
444 return retval; 444 return retval;
445 445
@@ -589,7 +589,7 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
589 } 589 }
590 590
591 out: 591 out:
592 up(&udev->sem); 592 mutex_unlock(&udev->mutex);
593 return retval; 593 return retval;
594} 594}
595 595
diff --git a/drivers/input/mouse/hil_ptr.c b/drivers/input/mouse/hil_ptr.c
index bfb564fd8fe2..69f02178c528 100644
--- a/drivers/input/mouse/hil_ptr.c
+++ b/drivers/input/mouse/hil_ptr.c
@@ -249,10 +249,13 @@ static int hil_ptr_connect(struct serio *serio, struct serio_driver *driver)
249 return -ENOMEM; 249 return -ENOMEM;
250 250
251 ptr->dev = input_allocate_device(); 251 ptr->dev = input_allocate_device();
252 if (!ptr->dev) goto bail0; 252 if (!ptr->dev)
253 goto bail0;
254
253 ptr->dev->private = ptr; 255 ptr->dev->private = ptr;
254 256
255 if (serio_open(serio, driver)) goto bail1; 257 if (serio_open(serio, driver))
258 goto bail1;
256 259
257 serio_set_drvdata(serio, ptr); 260 serio_set_drvdata(serio, ptr);
258 ptr->serio = serio; 261 ptr->serio = serio;
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index ad6217467676..32d70ed8f41d 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -20,6 +20,8 @@
20#include <linux/serio.h> 20#include <linux/serio.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/libps2.h> 22#include <linux/libps2.h>
23#include <linux/mutex.h>
24
23#include "psmouse.h" 25#include "psmouse.h"
24#include "synaptics.h" 26#include "synaptics.h"
25#include "logips2pp.h" 27#include "logips2pp.h"
@@ -98,13 +100,13 @@ __obsolete_setup("psmouse_resetafter=");
98__obsolete_setup("psmouse_rate="); 100__obsolete_setup("psmouse_rate=");
99 101
100/* 102/*
101 * psmouse_sem protects all operations changing state of mouse 103 * psmouse_mutex protects all operations changing state of mouse
102 * (connecting, disconnecting, changing rate or resolution via 104 * (connecting, disconnecting, changing rate or resolution via
103 * sysfs). We could use a per-device semaphore but since there 105 * sysfs). We could use a per-device semaphore but since there
104 * rarely more than one PS/2 mouse connected and since semaphore 106 * rarely more than one PS/2 mouse connected and since semaphore
105 * is taken in "slow" paths it is not worth it. 107 * is taken in "slow" paths it is not worth it.
106 */ 108 */
107static DECLARE_MUTEX(psmouse_sem); 109static DEFINE_MUTEX(psmouse_mutex);
108 110
109static struct workqueue_struct *kpsmoused_wq; 111static struct workqueue_struct *kpsmoused_wq;
110 112
@@ -868,7 +870,7 @@ static void psmouse_resync(void *p)
868 int failed = 0, enabled = 0; 870 int failed = 0, enabled = 0;
869 int i; 871 int i;
870 872
871 down(&psmouse_sem); 873 mutex_lock(&psmouse_mutex);
872 874
873 if (psmouse->state != PSMOUSE_RESYNCING) 875 if (psmouse->state != PSMOUSE_RESYNCING)
874 goto out; 876 goto out;
@@ -948,7 +950,7 @@ static void psmouse_resync(void *p)
948 if (parent) 950 if (parent)
949 psmouse_activate(parent); 951 psmouse_activate(parent);
950 out: 952 out:
951 up(&psmouse_sem); 953 mutex_unlock(&psmouse_mutex);
952} 954}
953 955
954/* 956/*
@@ -974,14 +976,14 @@ static void psmouse_disconnect(struct serio *serio)
974 976
975 sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group); 977 sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group);
976 978
977 down(&psmouse_sem); 979 mutex_lock(&psmouse_mutex);
978 980
979 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 981 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
980 982
981 /* make sure we don't have a resync in progress */ 983 /* make sure we don't have a resync in progress */
982 up(&psmouse_sem); 984 mutex_unlock(&psmouse_mutex);
983 flush_workqueue(kpsmoused_wq); 985 flush_workqueue(kpsmoused_wq);
984 down(&psmouse_sem); 986 mutex_lock(&psmouse_mutex);
985 987
986 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 988 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
987 parent = serio_get_drvdata(serio->parent); 989 parent = serio_get_drvdata(serio->parent);
@@ -1004,7 +1006,7 @@ static void psmouse_disconnect(struct serio *serio)
1004 if (parent) 1006 if (parent)
1005 psmouse_activate(parent); 1007 psmouse_activate(parent);
1006 1008
1007 up(&psmouse_sem); 1009 mutex_unlock(&psmouse_mutex);
1008} 1010}
1009 1011
1010static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto) 1012static int psmouse_switch_protocol(struct psmouse *psmouse, struct psmouse_protocol *proto)
@@ -1076,7 +1078,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1076 struct input_dev *input_dev; 1078 struct input_dev *input_dev;
1077 int retval = -ENOMEM; 1079 int retval = -ENOMEM;
1078 1080
1079 down(&psmouse_sem); 1081 mutex_lock(&psmouse_mutex);
1080 1082
1081 /* 1083 /*
1082 * If this is a pass-through port deactivate parent so the device 1084 * If this is a pass-through port deactivate parent so the device
@@ -1144,7 +1146,7 @@ out:
1144 if (parent) 1146 if (parent)
1145 psmouse_activate(parent); 1147 psmouse_activate(parent);
1146 1148
1147 up(&psmouse_sem); 1149 mutex_unlock(&psmouse_mutex);
1148 return retval; 1150 return retval;
1149} 1151}
1150 1152
@@ -1161,7 +1163,7 @@ static int psmouse_reconnect(struct serio *serio)
1161 return -1; 1163 return -1;
1162 } 1164 }
1163 1165
1164 down(&psmouse_sem); 1166 mutex_lock(&psmouse_mutex);
1165 1167
1166 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1168 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1167 parent = serio_get_drvdata(serio->parent); 1169 parent = serio_get_drvdata(serio->parent);
@@ -1195,7 +1197,7 @@ out:
1195 if (parent) 1197 if (parent)
1196 psmouse_activate(parent); 1198 psmouse_activate(parent);
1197 1199
1198 up(&psmouse_sem); 1200 mutex_unlock(&psmouse_mutex);
1199 return rc; 1201 return rc;
1200} 1202}
1201 1203
@@ -1273,7 +1275,7 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
1273 goto out_unpin; 1275 goto out_unpin;
1274 } 1276 }
1275 1277
1276 retval = down_interruptible(&psmouse_sem); 1278 retval = mutex_lock_interruptible(&psmouse_mutex);
1277 if (retval) 1279 if (retval)
1278 goto out_unpin; 1280 goto out_unpin;
1279 1281
@@ -1281,7 +1283,7 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
1281 1283
1282 if (psmouse->state == PSMOUSE_IGNORE) { 1284 if (psmouse->state == PSMOUSE_IGNORE) {
1283 retval = -ENODEV; 1285 retval = -ENODEV;
1284 goto out_up; 1286 goto out_unlock;
1285 } 1287 }
1286 1288
1287 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1289 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
@@ -1299,8 +1301,8 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
1299 if (parent) 1301 if (parent)
1300 psmouse_activate(parent); 1302 psmouse_activate(parent);
1301 1303
1302 out_up: 1304 out_unlock:
1303 up(&psmouse_sem); 1305 mutex_unlock(&psmouse_mutex);
1304 out_unpin: 1306 out_unpin:
1305 serio_unpin_driver(serio); 1307 serio_unpin_driver(serio);
1306 return retval; 1308 return retval;
@@ -1357,11 +1359,11 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1357 return -EIO; 1359 return -EIO;
1358 } 1360 }
1359 1361
1360 up(&psmouse_sem); 1362 mutex_unlock(&psmouse_mutex);
1361 serio_unpin_driver(serio); 1363 serio_unpin_driver(serio);
1362 serio_unregister_child_port(serio); 1364 serio_unregister_child_port(serio);
1363 serio_pin_driver_uninterruptible(serio); 1365 serio_pin_driver_uninterruptible(serio);
1364 down(&psmouse_sem); 1366 mutex_lock(&psmouse_mutex);
1365 1367
1366 if (serio->drv != &psmouse_drv) { 1368 if (serio->drv != &psmouse_drv) {
1367 input_free_device(new_dev); 1369 input_free_device(new_dev);
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 2051bec2c394..ad5d0a85e960 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -247,14 +247,12 @@ static void synaptics_pt_create(struct psmouse *psmouse)
247{ 247{
248 struct serio *serio; 248 struct serio *serio;
249 249
250 serio = kmalloc(sizeof(struct serio), GFP_KERNEL); 250 serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
251 if (!serio) { 251 if (!serio) {
252 printk(KERN_ERR "synaptics: not enough memory to allocate pass-through port\n"); 252 printk(KERN_ERR "synaptics: not enough memory to allocate pass-through port\n");
253 return; 253 return;
254 } 254 }
255 255
256 memset(serio, 0, sizeof(struct serio));
257
258 serio->id.type = SERIO_PS_PSTHRU; 256 serio->id.type = SERIO_PS_PSTHRU;
259 strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name)); 257 strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name));
260 strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name)); 258 strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name));
@@ -605,14 +603,21 @@ static struct dmi_system_id toshiba_dmi_table[] = {
605 .ident = "Toshiba Satellite", 603 .ident = "Toshiba Satellite",
606 .matches = { 604 .matches = {
607 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 605 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
608 DMI_MATCH(DMI_PRODUCT_NAME , "Satellite"), 606 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite"),
609 }, 607 },
610 }, 608 },
611 { 609 {
612 .ident = "Toshiba Dynabook", 610 .ident = "Toshiba Dynabook",
613 .matches = { 611 .matches = {
614 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 612 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
615 DMI_MATCH(DMI_PRODUCT_NAME , "dynabook"), 613 DMI_MATCH(DMI_PRODUCT_NAME, "dynabook"),
614 },
615 },
616 {
617 .ident = "Toshiba Portege M300",
618 .matches = {
619 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
620 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE M300"),
616 }, 621 },
617 }, 622 },
618 { } 623 { }
@@ -623,10 +628,9 @@ int synaptics_init(struct psmouse *psmouse)
623{ 628{
624 struct synaptics_data *priv; 629 struct synaptics_data *priv;
625 630
626 psmouse->private = priv = kmalloc(sizeof(struct synaptics_data), GFP_KERNEL); 631 psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL);
627 if (!priv) 632 if (!priv)
628 return -1; 633 return -1;
629 memset(priv, 0, sizeof(struct synaptics_data));
630 634
631 if (synaptics_query_hardware(psmouse)) { 635 if (synaptics_query_hardware(psmouse)) {
632 printk(KERN_ERR "Unable to query Synaptics hardware.\n"); 636 printk(KERN_ERR "Unable to query Synaptics hardware.\n");
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 9abed18d2ecf..b685a507955d 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -412,9 +412,8 @@ static int mousedev_open(struct inode * inode, struct file * file)
412 if (i >= MOUSEDEV_MINORS || !mousedev_table[i]) 412 if (i >= MOUSEDEV_MINORS || !mousedev_table[i])
413 return -ENODEV; 413 return -ENODEV;
414 414
415 if (!(list = kmalloc(sizeof(struct mousedev_list), GFP_KERNEL))) 415 if (!(list = kzalloc(sizeof(struct mousedev_list), GFP_KERNEL)))
416 return -ENOMEM; 416 return -ENOMEM;
417 memset(list, 0, sizeof(struct mousedev_list));
418 417
419 spin_lock_init(&list->packet_lock); 418 spin_lock_init(&list->packet_lock);
420 list->pos_x = xres / 2; 419 list->pos_x = xres / 2;
@@ -626,9 +625,8 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
626 return NULL; 625 return NULL;
627 } 626 }
628 627
629 if (!(mousedev = kmalloc(sizeof(struct mousedev), GFP_KERNEL))) 628 if (!(mousedev = kzalloc(sizeof(struct mousedev), GFP_KERNEL)))
630 return NULL; 629 return NULL;
631 memset(mousedev, 0, sizeof(struct mousedev));
632 630
633 INIT_LIST_HEAD(&mousedev->list); 631 INIT_LIST_HEAD(&mousedev->list);
634 init_waitqueue_head(&mousedev->wait); 632 init_waitqueue_head(&mousedev->wait);
diff --git a/drivers/input/power.c b/drivers/input/power.c
index bfc5c63ebffe..526e6070600c 100644
--- a/drivers/input/power.c
+++ b/drivers/input/power.c
@@ -103,9 +103,8 @@ static struct input_handle *power_connect(struct input_handler *handler,
103{ 103{
104 struct input_handle *handle; 104 struct input_handle *handle;
105 105
106 if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL))) 106 if (!(handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL)))
107 return NULL; 107 return NULL;
108 memset(handle, 0, sizeof(struct input_handle));
109 108
110 handle->dev = dev; 109 handle->dev = dev;
111 handle->handler = handler; 110 handle->handler = handler;
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index ea499783fb12..bbbe15e21904 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -872,9 +872,8 @@ int hil_mlc_register(hil_mlc *mlc) {
872 for (i = 0; i < HIL_MLC_DEVMEM; i++) { 872 for (i = 0; i < HIL_MLC_DEVMEM; i++) {
873 struct serio *mlc_serio; 873 struct serio *mlc_serio;
874 hil_mlc_copy_di_scratch(mlc, i); 874 hil_mlc_copy_di_scratch(mlc, i);
875 mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL); 875 mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL);
876 mlc->serio[i] = mlc_serio; 876 mlc->serio[i] = mlc_serio;
877 memset(mlc_serio, 0, sizeof(*mlc_serio));
878 mlc_serio->id = hil_mlc_serio_id; 877 mlc_serio->id = hil_mlc_serio_id;
879 mlc_serio->write = hil_mlc_serio_write; 878 mlc_serio->write = hil_mlc_serio_write;
880 mlc_serio->open = hil_mlc_serio_open; 879 mlc_serio->open = hil_mlc_serio_open;
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index a4c6f3522723..f606e96bc2f4 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -192,7 +192,9 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
192#include <linux/pnp.h> 192#include <linux/pnp.h>
193 193
194static int i8042_pnp_kbd_registered; 194static int i8042_pnp_kbd_registered;
195static unsigned int i8042_pnp_kbd_devices;
195static int i8042_pnp_aux_registered; 196static int i8042_pnp_aux_registered;
197static unsigned int i8042_pnp_aux_devices;
196 198
197static int i8042_pnp_command_reg; 199static int i8042_pnp_command_reg;
198static int i8042_pnp_data_reg; 200static int i8042_pnp_data_reg;
@@ -219,6 +221,7 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *
219 strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name)); 221 strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
220 } 222 }
221 223
224 i8042_pnp_kbd_devices++;
222 return 0; 225 return 0;
223} 226}
224 227
@@ -239,6 +242,7 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *
239 strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name)); 242 strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
240 } 243 }
241 244
245 i8042_pnp_aux_devices++;
242 return 0; 246 return 0;
243} 247}
244 248
@@ -287,21 +291,23 @@ static void i8042_pnp_exit(void)
287 291
288static int __init i8042_pnp_init(void) 292static int __init i8042_pnp_init(void)
289{ 293{
290 int result_kbd = 0, result_aux = 0;
291 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 }; 294 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
295 int err;
292 296
293 if (i8042_nopnp) { 297 if (i8042_nopnp) {
294 printk(KERN_INFO "i8042: PNP detection disabled\n"); 298 printk(KERN_INFO "i8042: PNP detection disabled\n");
295 return 0; 299 return 0;
296 } 300 }
297 301
298 if ((result_kbd = pnp_register_driver(&i8042_pnp_kbd_driver)) >= 0) 302 err = pnp_register_driver(&i8042_pnp_kbd_driver);
303 if (!err)
299 i8042_pnp_kbd_registered = 1; 304 i8042_pnp_kbd_registered = 1;
300 305
301 if ((result_aux = pnp_register_driver(&i8042_pnp_aux_driver)) >= 0) 306 err = pnp_register_driver(&i8042_pnp_aux_driver);
307 if (!err)
302 i8042_pnp_aux_registered = 1; 308 i8042_pnp_aux_registered = 1;
303 309
304 if (result_kbd <= 0 && result_aux <= 0) { 310 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
305 i8042_pnp_exit(); 311 i8042_pnp_exit();
306#if defined(__ia64__) 312#if defined(__ia64__)
307 return -ENODEV; 313 return -ENODEV;
@@ -311,24 +317,24 @@ static int __init i8042_pnp_init(void)
311#endif 317#endif
312 } 318 }
313 319
314 if (result_kbd > 0) 320 if (i8042_pnp_kbd_devices)
315 snprintf(kbd_irq_str, sizeof(kbd_irq_str), 321 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
316 "%d", i8042_pnp_kbd_irq); 322 "%d", i8042_pnp_kbd_irq);
317 if (result_aux > 0) 323 if (i8042_pnp_aux_devices)
318 snprintf(aux_irq_str, sizeof(aux_irq_str), 324 snprintf(aux_irq_str, sizeof(aux_irq_str),
319 "%d", i8042_pnp_aux_irq); 325 "%d", i8042_pnp_aux_irq);
320 326
321 printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n", 327 printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
322 i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", 328 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
323 i8042_pnp_aux_name, 329 i8042_pnp_aux_name,
324 i8042_pnp_data_reg, i8042_pnp_command_reg, 330 i8042_pnp_data_reg, i8042_pnp_command_reg,
325 kbd_irq_str, (result_kbd > 0 && result_aux > 0) ? "," : "", 331 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
326 aux_irq_str); 332 aux_irq_str);
327 333
328#if defined(__ia64__) 334#if defined(__ia64__)
329 if (result_kbd <= 0) 335 if (!i8042_pnp_kbd_devices)
330 i8042_nokbd = 1; 336 i8042_nokbd = 1;
331 if (result_aux <= 0) 337 if (!i8042_pnp_aux_devices)
332 i8042_noaux = 1; 338 i8042_noaux = 1;
333#endif 339#endif
334 340
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index d4c990f7c85e..79c97f94bcbd 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -84,7 +84,7 @@ void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout)
84 maxbytes = sizeof(ps2dev->cmdbuf); 84 maxbytes = sizeof(ps2dev->cmdbuf);
85 } 85 }
86 86
87 down(&ps2dev->cmd_sem); 87 mutex_lock(&ps2dev->cmd_mutex);
88 88
89 serio_pause_rx(ps2dev->serio); 89 serio_pause_rx(ps2dev->serio);
90 ps2dev->flags = PS2_FLAG_CMD; 90 ps2dev->flags = PS2_FLAG_CMD;
@@ -94,7 +94,7 @@ void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout)
94 wait_event_timeout(ps2dev->wait, 94 wait_event_timeout(ps2dev->wait,
95 !(ps2dev->flags & PS2_FLAG_CMD), 95 !(ps2dev->flags & PS2_FLAG_CMD),
96 msecs_to_jiffies(timeout)); 96 msecs_to_jiffies(timeout));
97 up(&ps2dev->cmd_sem); 97 mutex_unlock(&ps2dev->cmd_mutex);
98} 98}
99 99
100/* 100/*
@@ -177,7 +177,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
177 return -1; 177 return -1;
178 } 178 }
179 179
180 down(&ps2dev->cmd_sem); 180 mutex_lock(&ps2dev->cmd_mutex);
181 181
182 serio_pause_rx(ps2dev->serio); 182 serio_pause_rx(ps2dev->serio);
183 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0; 183 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;
@@ -229,7 +229,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
229 ps2dev->flags = 0; 229 ps2dev->flags = 0;
230 serio_continue_rx(ps2dev->serio); 230 serio_continue_rx(ps2dev->serio);
231 231
232 up(&ps2dev->cmd_sem); 232 mutex_unlock(&ps2dev->cmd_mutex);
233 return rc; 233 return rc;
234} 234}
235 235
@@ -281,7 +281,7 @@ int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int comman
281 281
282void ps2_init(struct ps2dev *ps2dev, struct serio *serio) 282void ps2_init(struct ps2dev *ps2dev, struct serio *serio)
283{ 283{
284 init_MUTEX(&ps2dev->cmd_sem); 284 mutex_init(&ps2dev->cmd_mutex);
285 init_waitqueue_head(&ps2dev->wait); 285 init_waitqueue_head(&ps2dev->wait);
286 ps2dev->serio = serio; 286 ps2dev->serio = serio;
287} 287}
diff --git a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
index 1d15c2819818..a5c1fb3a4a51 100644
--- a/drivers/input/serio/parkbd.c
+++ b/drivers/input/serio/parkbd.c
@@ -171,9 +171,8 @@ static struct serio * __init parkbd_allocate_serio(void)
171{ 171{
172 struct serio *serio; 172 struct serio *serio;
173 173
174 serio = kmalloc(sizeof(struct serio), GFP_KERNEL); 174 serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
175 if (serio) { 175 if (serio) {
176 memset(serio, 0, sizeof(struct serio));
177 serio->id.type = parkbd_mode; 176 serio->id.type = parkbd_mode;
178 serio->write = parkbd_write, 177 serio->write = parkbd_write,
179 strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name)); 178 strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name));
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
index a3bd11589bc3..513d37fc1acf 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -111,11 +111,10 @@ static int __devinit rpckbd_probe(struct platform_device *dev)
111{ 111{
112 struct serio *serio; 112 struct serio *serio;
113 113
114 serio = kmalloc(sizeof(struct serio), GFP_KERNEL); 114 serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
115 if (!serio) 115 if (!serio)
116 return -ENOMEM; 116 return -ENOMEM;
117 117
118 memset(serio, 0, sizeof(struct serio));
119 serio->id.type = SERIO_8042; 118 serio->id.type = SERIO_8042;
120 serio->write = rpckbd_write; 119 serio->write = rpckbd_write;
121 serio->open = rpckbd_open; 120 serio->open = rpckbd_open;
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 2f76813c3a64..6521034bc933 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -34,6 +34,7 @@
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/mutex.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");
@@ -52,10 +53,10 @@ EXPORT_SYMBOL(serio_rescan);
52EXPORT_SYMBOL(serio_reconnect); 53EXPORT_SYMBOL(serio_reconnect);
53 54
54/* 55/*
55 * serio_sem protects entire serio subsystem and is taken every time 56 * serio_mutex protects entire serio subsystem and is taken every time
56 * serio port or driver registrered or unregistered. 57 * serio port or driver registrered or unregistered.
57 */ 58 */
58static DECLARE_MUTEX(serio_sem); 59static DEFINE_MUTEX(serio_mutex);
59 60
60static LIST_HEAD(serio_list); 61static LIST_HEAD(serio_list);
61 62
@@ -70,9 +71,9 @@ static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
70{ 71{
71 int retval; 72 int retval;
72 73
73 down(&serio->drv_sem); 74 mutex_lock(&serio->drv_mutex);
74 retval = drv->connect(serio, drv); 75 retval = drv->connect(serio, drv);
75 up(&serio->drv_sem); 76 mutex_unlock(&serio->drv_mutex);
76 77
77 return retval; 78 return retval;
78} 79}
@@ -81,20 +82,20 @@ static int serio_reconnect_driver(struct serio *serio)
81{ 82{
82 int retval = -1; 83 int retval = -1;
83 84
84 down(&serio->drv_sem); 85 mutex_lock(&serio->drv_mutex);
85 if (serio->drv && serio->drv->reconnect) 86 if (serio->drv && serio->drv->reconnect)
86 retval = serio->drv->reconnect(serio); 87 retval = serio->drv->reconnect(serio);
87 up(&serio->drv_sem); 88 mutex_unlock(&serio->drv_mutex);
88 89
89 return retval; 90 return retval;
90} 91}
91 92
92static void serio_disconnect_driver(struct serio *serio) 93static void serio_disconnect_driver(struct serio *serio)
93{ 94{
94 down(&serio->drv_sem); 95 mutex_lock(&serio->drv_mutex);
95 if (serio->drv) 96 if (serio->drv)
96 serio->drv->disconnect(serio); 97 serio->drv->disconnect(serio);
97 up(&serio->drv_sem); 98 mutex_unlock(&serio->drv_mutex);
98} 99}
99 100
100static int serio_match_port(const struct serio_device_id *ids, struct serio *serio) 101static int serio_match_port(const struct serio_device_id *ids, struct serio *serio)
@@ -195,6 +196,7 @@ static void serio_queue_event(void *object, struct module *owner,
195 if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) { 196 if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) {
196 if (!try_module_get(owner)) { 197 if (!try_module_get(owner)) {
197 printk(KERN_WARNING "serio: Can't get module reference, dropping event %d\n", event_type); 198 printk(KERN_WARNING "serio: Can't get module reference, dropping event %d\n", event_type);
199 kfree(event);
198 goto out; 200 goto out;
199 } 201 }
200 202
@@ -272,7 +274,7 @@ static void serio_handle_event(void)
272 struct serio_event *event; 274 struct serio_event *event;
273 struct serio_driver *serio_drv; 275 struct serio_driver *serio_drv;
274 276
275 down(&serio_sem); 277 mutex_lock(&serio_mutex);
276 278
277 /* 279 /*
278 * Note that we handle only one event here to give swsusp 280 * Note that we handle only one event here to give swsusp
@@ -314,7 +316,7 @@ static void serio_handle_event(void)
314 serio_free_event(event); 316 serio_free_event(event);
315 } 317 }
316 318
317 up(&serio_sem); 319 mutex_unlock(&serio_mutex);
318} 320}
319 321
320/* 322/*
@@ -449,7 +451,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
449 struct device_driver *drv; 451 struct device_driver *drv;
450 int retval; 452 int retval;
451 453
452 retval = down_interruptible(&serio_sem); 454 retval = mutex_lock_interruptible(&serio_mutex);
453 if (retval) 455 if (retval)
454 return retval; 456 return retval;
455 457
@@ -469,7 +471,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
469 retval = -EINVAL; 471 retval = -EINVAL;
470 } 472 }
471 473
472 up(&serio_sem); 474 mutex_unlock(&serio_mutex);
473 475
474 return retval; 476 return retval;
475} 477}
@@ -524,7 +526,7 @@ static void serio_init_port(struct serio *serio)
524 __module_get(THIS_MODULE); 526 __module_get(THIS_MODULE);
525 527
526 spin_lock_init(&serio->lock); 528 spin_lock_init(&serio->lock);
527 init_MUTEX(&serio->drv_sem); 529 mutex_init(&serio->drv_mutex);
528 device_initialize(&serio->dev); 530 device_initialize(&serio->dev);
529 snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id), 531 snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id),
530 "serio%ld", (long)atomic_inc_return(&serio_no) - 1); 532 "serio%ld", (long)atomic_inc_return(&serio_no) - 1);
@@ -661,10 +663,10 @@ void __serio_register_port(struct serio *serio, struct module *owner)
661 */ 663 */
662void serio_unregister_port(struct serio *serio) 664void serio_unregister_port(struct serio *serio)
663{ 665{
664 down(&serio_sem); 666 mutex_lock(&serio_mutex);
665 serio_disconnect_port(serio); 667 serio_disconnect_port(serio);
666 serio_destroy_port(serio); 668 serio_destroy_port(serio);
667 up(&serio_sem); 669 mutex_unlock(&serio_mutex);
668} 670}
669 671
670/* 672/*
@@ -672,17 +674,17 @@ void serio_unregister_port(struct serio *serio)
672 */ 674 */
673void serio_unregister_child_port(struct serio *serio) 675void serio_unregister_child_port(struct serio *serio)
674{ 676{
675 down(&serio_sem); 677 mutex_lock(&serio_mutex);
676 if (serio->child) { 678 if (serio->child) {
677 serio_disconnect_port(serio->child); 679 serio_disconnect_port(serio->child);
678 serio_destroy_port(serio->child); 680 serio_destroy_port(serio->child);
679 } 681 }
680 up(&serio_sem); 682 mutex_unlock(&serio_mutex);
681} 683}
682 684
683/* 685/*
684 * Submits register request to kseriod for subsequent execution. 686 * Submits register request to kseriod for subsequent execution.
685 * Can be used when it is not obvious whether the serio_sem is 687 * Can be used when it is not obvious whether the serio_mutex is
686 * taken or not and when delayed execution is feasible. 688 * taken or not and when delayed execution is feasible.
687 */ 689 */
688void __serio_unregister_port_delayed(struct serio *serio, struct module *owner) 690void __serio_unregister_port_delayed(struct serio *serio, struct module *owner)
@@ -765,7 +767,7 @@ void serio_unregister_driver(struct serio_driver *drv)
765{ 767{
766 struct serio *serio; 768 struct serio *serio;
767 769
768 down(&serio_sem); 770 mutex_lock(&serio_mutex);
769 drv->manual_bind = 1; /* so serio_find_driver ignores it */ 771 drv->manual_bind = 1; /* so serio_find_driver ignores it */
770 772
771start_over: 773start_over:
@@ -779,7 +781,7 @@ start_over:
779 } 781 }
780 782
781 driver_unregister(&drv->driver); 783 driver_unregister(&drv->driver);
782 up(&serio_sem); 784 mutex_unlock(&serio_mutex);
783} 785}
784 786
785static void serio_set_drv(struct serio *serio, struct serio_driver *drv) 787static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
@@ -858,7 +860,7 @@ static int serio_resume(struct device *dev)
858 return 0; 860 return 0;
859} 861}
860 862
861/* called from serio_driver->connect/disconnect methods under serio_sem */ 863/* called from serio_driver->connect/disconnect methods under serio_mutex */
862int serio_open(struct serio *serio, struct serio_driver *drv) 864int serio_open(struct serio *serio, struct serio_driver *drv)
863{ 865{
864 serio_set_drv(serio, drv); 866 serio_set_drv(serio, drv);
@@ -870,7 +872,7 @@ int serio_open(struct serio *serio, struct serio_driver *drv)
870 return 0; 872 return 0;
871} 873}
872 874
873/* called from serio_driver->connect/disconnect methods under serio_sem */ 875/* called from serio_driver->connect/disconnect methods under serio_mutex */
874void serio_close(struct serio *serio) 876void serio_close(struct serio *serio)
875{ 877{
876 if (serio->close) 878 if (serio->close)
@@ -923,5 +925,5 @@ static void __exit serio_exit(void)
923 kthread_stop(serio_task); 925 kthread_stop(serio_task);
924} 926}
925 927
926module_init(serio_init); 928subsys_initcall(serio_init);
927module_exit(serio_exit); 929module_exit(serio_exit);
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 47e08de18d07..5a2703b536dc 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -19,6 +19,7 @@
19#include <linux/devfs_fs_kernel.h> 19#include <linux/devfs_fs_kernel.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/wait.h> 21#include <linux/wait.h>
22#include <linux/mutex.h>
22 23
23#define DRIVER_DESC "Raw serio driver" 24#define DRIVER_DESC "Raw serio driver"
24 25
@@ -46,7 +47,7 @@ struct serio_raw_list {
46 struct list_head node; 47 struct list_head node;
47}; 48};
48 49
49static DECLARE_MUTEX(serio_raw_sem); 50static DEFINE_MUTEX(serio_raw_mutex);
50static LIST_HEAD(serio_raw_list); 51static LIST_HEAD(serio_raw_list);
51static unsigned int serio_raw_no; 52static unsigned int serio_raw_no;
52 53
@@ -81,7 +82,7 @@ static int serio_raw_open(struct inode *inode, struct file *file)
81 struct serio_raw_list *list; 82 struct serio_raw_list *list;
82 int retval = 0; 83 int retval = 0;
83 84
84 retval = down_interruptible(&serio_raw_sem); 85 retval = mutex_lock_interruptible(&serio_raw_mutex);
85 if (retval) 86 if (retval)
86 return retval; 87 return retval;
87 88
@@ -95,12 +96,11 @@ static int serio_raw_open(struct inode *inode, struct file *file)
95 goto out; 96 goto out;
96 } 97 }
97 98
98 if (!(list = kmalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) { 99 if (!(list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) {
99 retval = -ENOMEM; 100 retval = -ENOMEM;
100 goto out; 101 goto out;
101 } 102 }
102 103
103 memset(list, 0, sizeof(struct serio_raw_list));
104 list->serio_raw = serio_raw; 104 list->serio_raw = serio_raw;
105 file->private_data = list; 105 file->private_data = list;
106 106
@@ -108,7 +108,7 @@ static int serio_raw_open(struct inode *inode, struct file *file)
108 list_add_tail(&list->node, &serio_raw->list); 108 list_add_tail(&list->node, &serio_raw->list);
109 109
110out: 110out:
111 up(&serio_raw_sem); 111 mutex_unlock(&serio_raw_mutex);
112 return retval; 112 return retval;
113} 113}
114 114
@@ -130,12 +130,12 @@ static int serio_raw_release(struct inode *inode, struct file *file)
130 struct serio_raw_list *list = file->private_data; 130 struct serio_raw_list *list = file->private_data;
131 struct serio_raw *serio_raw = list->serio_raw; 131 struct serio_raw *serio_raw = list->serio_raw;
132 132
133 down(&serio_raw_sem); 133 mutex_lock(&serio_raw_mutex);
134 134
135 serio_raw_fasync(-1, file, 0); 135 serio_raw_fasync(-1, file, 0);
136 serio_raw_cleanup(serio_raw); 136 serio_raw_cleanup(serio_raw);
137 137
138 up(&serio_raw_sem); 138 mutex_unlock(&serio_raw_mutex);
139 return 0; 139 return 0;
140} 140}
141 141
@@ -194,7 +194,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
194 int retval; 194 int retval;
195 unsigned char c; 195 unsigned char c;
196 196
197 retval = down_interruptible(&serio_raw_sem); 197 retval = mutex_lock_interruptible(&serio_raw_mutex);
198 if (retval) 198 if (retval)
199 return retval; 199 return retval;
200 200
@@ -219,7 +219,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
219 }; 219 };
220 220
221out: 221out:
222 up(&serio_raw_sem); 222 mutex_unlock(&serio_raw_mutex);
223 return written; 223 return written;
224} 224}
225 225
@@ -275,14 +275,13 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
275 struct serio_raw *serio_raw; 275 struct serio_raw *serio_raw;
276 int err; 276 int err;
277 277
278 if (!(serio_raw = kmalloc(sizeof(struct serio_raw), GFP_KERNEL))) { 278 if (!(serio_raw = kzalloc(sizeof(struct serio_raw), GFP_KERNEL))) {
279 printk(KERN_ERR "serio_raw.c: can't allocate memory for a device\n"); 279 printk(KERN_ERR "serio_raw.c: can't allocate memory for a device\n");
280 return -ENOMEM; 280 return -ENOMEM;
281 } 281 }
282 282
283 down(&serio_raw_sem); 283 mutex_lock(&serio_raw_mutex);
284 284
285 memset(serio_raw, 0, sizeof(struct serio_raw));
286 snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++); 285 snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++);
287 serio_raw->refcnt = 1; 286 serio_raw->refcnt = 1;
288 serio_raw->serio = serio; 287 serio_raw->serio = serio;
@@ -325,7 +324,7 @@ out_free:
325 serio_set_drvdata(serio, NULL); 324 serio_set_drvdata(serio, NULL);
326 kfree(serio_raw); 325 kfree(serio_raw);
327out: 326out:
328 up(&serio_raw_sem); 327 mutex_unlock(&serio_raw_mutex);
329 return err; 328 return err;
330} 329}
331 330
@@ -350,7 +349,7 @@ static void serio_raw_disconnect(struct serio *serio)
350{ 349{
351 struct serio_raw *serio_raw; 350 struct serio_raw *serio_raw;
352 351
353 down(&serio_raw_sem); 352 mutex_lock(&serio_raw_mutex);
354 353
355 serio_raw = serio_get_drvdata(serio); 354 serio_raw = serio_get_drvdata(serio);
356 355
@@ -361,7 +360,7 @@ static void serio_raw_disconnect(struct serio *serio)
361 if (!serio_raw_cleanup(serio_raw)) 360 if (!serio_raw_cleanup(serio_raw))
362 wake_up_interruptible(&serio_raw->wait); 361 wake_up_interruptible(&serio_raw->wait);
363 362
364 up(&serio_raw_sem); 363 mutex_unlock(&serio_raw_mutex);
365} 364}
366 365
367static struct serio_device_id serio_raw_serio_ids[] = { 366static struct serio_device_id serio_raw_serio_ids[] = {
diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c
index ca1547929d62..d678d144bbf8 100644
--- a/drivers/input/tsdev.c
+++ b/drivers/input/tsdev.c
@@ -157,9 +157,8 @@ static int tsdev_open(struct inode *inode, struct file *file)
157 if (i >= TSDEV_MINORS || !tsdev_table[i & TSDEV_MINOR_MASK]) 157 if (i >= TSDEV_MINORS || !tsdev_table[i & TSDEV_MINOR_MASK])
158 return -ENODEV; 158 return -ENODEV;
159 159
160 if (!(list = kmalloc(sizeof(struct tsdev_list), GFP_KERNEL))) 160 if (!(list = kzalloc(sizeof(struct tsdev_list), GFP_KERNEL)))
161 return -ENOMEM; 161 return -ENOMEM;
162 memset(list, 0, sizeof(struct tsdev_list));
163 162
164 list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0; 163 list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0;
165 164
@@ -379,9 +378,8 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
379 return NULL; 378 return NULL;
380 } 379 }
381 380
382 if (!(tsdev = kmalloc(sizeof(struct tsdev), GFP_KERNEL))) 381 if (!(tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL)))
383 return NULL; 382 return NULL;
384 memset(tsdev, 0, sizeof(struct tsdev));
385 383
386 INIT_LIST_HEAD(&tsdev->list); 384 INIT_LIST_HEAD(&tsdev->list);
387 init_waitqueue_head(&tsdev->wait); 385 init_waitqueue_head(&tsdev->wait);
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index cb0d80f49252..25bc85f8ce39 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -510,7 +510,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
510 case 0x025: map_key_clear(KEY_TV); break; 510 case 0x025: map_key_clear(KEY_TV); break;
511 case 0x026: map_key_clear(KEY_MENU); break; 511 case 0x026: map_key_clear(KEY_MENU); break;
512 case 0x031: map_key_clear(KEY_AUDIO); break; 512 case 0x031: map_key_clear(KEY_AUDIO); break;
513 case 0x032: map_key_clear(KEY_SUBTITLE); break; 513 case 0x032: map_key_clear(KEY_TEXT); break;
514 case 0x033: map_key_clear(KEY_LAST); break; 514 case 0x033: map_key_clear(KEY_LAST); break;
515 case 0x047: map_key_clear(KEY_MP3); break; 515 case 0x047: map_key_clear(KEY_MP3); break;
516 case 0x048: map_key_clear(KEY_DVD); break; 516 case 0x048: map_key_clear(KEY_DVD); break;
diff --git a/include/linux/gameport.h b/include/linux/gameport.h
index 9c8e6da2393b..71e7b2847cb3 100644
--- a/include/linux/gameport.h
+++ b/include/linux/gameport.h
@@ -11,6 +11,7 @@
11 11
12#include <asm/io.h> 12#include <asm/io.h>
13#include <linux/list.h> 13#include <linux/list.h>
14#include <linux/mutex.h>
14#include <linux/device.h> 15#include <linux/device.h>
15#include <linux/timer.h> 16#include <linux/timer.h>
16 17
@@ -40,7 +41,7 @@ struct gameport {
40 struct gameport *parent, *child; 41 struct gameport *parent, *child;
41 42
42 struct gameport_driver *drv; 43 struct gameport_driver *drv;
43 struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */ 44 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
44 45
45 struct device dev; 46 struct device dev;
46 unsigned int registered; /* port has been fully registered with driver core */ 47 unsigned int registered; /* port has been fully registered with driver core */
@@ -137,12 +138,12 @@ static inline void gameport_set_drvdata(struct gameport *gameport, void *data)
137 */ 138 */
138static inline int gameport_pin_driver(struct gameport *gameport) 139static inline int gameport_pin_driver(struct gameport *gameport)
139{ 140{
140 return down_interruptible(&gameport->drv_sem); 141 return mutex_lock_interruptible(&gameport->drv_mutex);
141} 142}
142 143
143static inline void gameport_unpin_driver(struct gameport *gameport) 144static inline void gameport_unpin_driver(struct gameport *gameport)
144{ 145{
145 up(&gameport->drv_sem); 146 mutex_unlock(&gameport->drv_mutex);
146} 147}
147 148
148void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); 149void __gameport_register_driver(struct gameport_driver *drv, struct module *owner);
diff --git a/include/linux/input.h b/include/linux/input.h
index 1d4e341b72e6..b0e612dda0cf 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -421,7 +421,7 @@ struct input_absinfo {
421#define BTN_GEAR_UP 0x151 421#define BTN_GEAR_UP 0x151
422 422
423#define KEY_OK 0x160 423#define KEY_OK 0x160
424#define KEY_SELECT 0x161 424#define KEY_SELECT 0x161
425#define KEY_GOTO 0x162 425#define KEY_GOTO 0x162
426#define KEY_CLEAR 0x163 426#define KEY_CLEAR 0x163
427#define KEY_POWER2 0x164 427#define KEY_POWER2 0x164
@@ -512,6 +512,15 @@ struct input_absinfo {
512#define KEY_FN_S 0x1e3 512#define KEY_FN_S 0x1e3
513#define KEY_FN_B 0x1e4 513#define KEY_FN_B 0x1e4
514 514
515#define KEY_BRL_DOT1 0x1f1
516#define KEY_BRL_DOT2 0x1f2
517#define KEY_BRL_DOT3 0x1f3
518#define KEY_BRL_DOT4 0x1f4
519#define KEY_BRL_DOT5 0x1f5
520#define KEY_BRL_DOT6 0x1f6
521#define KEY_BRL_DOT7 0x1f7
522#define KEY_BRL_DOT8 0x1f8
523
515/* We avoid low common keys in module aliases so they don't get huge. */ 524/* We avoid low common keys in module aliases so they don't get huge. */
516#define KEY_MIN_INTERESTING KEY_MUTE 525#define KEY_MIN_INTERESTING KEY_MUTE
517#define KEY_MAX 0x1ff 526#define KEY_MAX 0x1ff
@@ -929,7 +938,7 @@ struct input_dev {
929 938
930 struct input_handle *grab; 939 struct input_handle *grab;
931 940
932 struct semaphore sem; /* serializes open and close operations */ 941 struct mutex mutex; /* serializes open and close operations */
933 unsigned int users; 942 unsigned int users;
934 943
935 struct class_device cdev; 944 struct class_device cdev;
@@ -995,11 +1004,6 @@ static inline void init_input_dev(struct input_dev *dev)
995 1004
996struct input_dev *input_allocate_device(void); 1005struct input_dev *input_allocate_device(void);
997 1006
998static inline void input_free_device(struct input_dev *dev)
999{
1000 kfree(dev);
1001}
1002
1003static inline struct input_dev *input_get_device(struct input_dev *dev) 1007static inline struct input_dev *input_get_device(struct input_dev *dev)
1004{ 1008{
1005 return to_input_dev(class_device_get(&dev->cdev)); 1009 return to_input_dev(class_device_get(&dev->cdev));
@@ -1010,6 +1014,11 @@ static inline void input_put_device(struct input_dev *dev)
1010 class_device_put(&dev->cdev); 1014 class_device_put(&dev->cdev);
1011} 1015}
1012 1016
1017static inline void input_free_device(struct input_dev *dev)
1018{
1019 input_put_device(dev);
1020}
1021
1013int input_register_device(struct input_dev *); 1022int input_register_device(struct input_dev *);
1014void input_unregister_device(struct input_dev *); 1023void input_unregister_device(struct input_dev *);
1015 1024
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
index e87c32a5c86a..4eb851ece080 100644
--- a/include/linux/kbd_kern.h
+++ b/include/linux/kbd_kern.h
@@ -135,6 +135,8 @@ static inline void chg_vc_kbd_led(struct kbd_struct * kbd, int flag)
135 135
136#define U(x) ((x) ^ 0xf000) 136#define U(x) ((x) ^ 0xf000)
137 137
138#define BRL_UC_ROW 0x2800
139
138/* keyboard.c */ 140/* keyboard.c */
139 141
140struct console; 142struct console;
diff --git a/include/linux/keyboard.h b/include/linux/keyboard.h
index 08488042d74a..de76843bbe8a 100644
--- a/include/linux/keyboard.h
+++ b/include/linux/keyboard.h
@@ -44,6 +44,7 @@ extern unsigned short plain_map[NR_KEYS];
44#define KT_ASCII 9 44#define KT_ASCII 9
45#define KT_LOCK 10 45#define KT_LOCK 10
46#define KT_SLOCK 12 46#define KT_SLOCK 12
47#define KT_BRL 14
47 48
48#define K(t,v) (((t)<<8)|(v)) 49#define K(t,v) (((t)<<8)|(v))
49#define KTYP(x) ((x) >> 8) 50#define KTYP(x) ((x) >> 8)
@@ -427,5 +428,17 @@ extern unsigned short plain_map[NR_KEYS];
427 428
428#define NR_LOCK 8 429#define NR_LOCK 8
429 430
431#define K_BRL_BLANK K(KT_BRL, 0)
432#define K_BRL_DOT1 K(KT_BRL, 1)
433#define K_BRL_DOT2 K(KT_BRL, 2)
434#define K_BRL_DOT3 K(KT_BRL, 3)
435#define K_BRL_DOT4 K(KT_BRL, 4)
436#define K_BRL_DOT5 K(KT_BRL, 5)
437#define K_BRL_DOT6 K(KT_BRL, 6)
438#define K_BRL_DOT7 K(KT_BRL, 7)
439#define K_BRL_DOT8 K(KT_BRL, 8)
440
441#define NR_BRL 9
442
430#define MAX_DIACR 256 443#define MAX_DIACR 256
431#endif 444#endif
diff --git a/include/linux/libps2.h b/include/linux/libps2.h
index a710bddda4eb..08a450a9dbf7 100644
--- a/include/linux/libps2.h
+++ b/include/linux/libps2.h
@@ -28,7 +28,7 @@ struct ps2dev {
28 struct serio *serio; 28 struct serio *serio;
29 29
30 /* Ensures that only one command is executing at a time */ 30 /* Ensures that only one command is executing at a time */
31 struct semaphore cmd_sem; 31 struct mutex cmd_mutex;
32 32
33 /* Used to signal completion from interrupt handler */ 33 /* Used to signal completion from interrupt handler */
34 wait_queue_head_t wait; 34 wait_queue_head_t wait;
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 690aabca8ed0..6348e8330897 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -18,6 +18,7 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/list.h> 19#include <linux/list.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/mutex.h>
21#include <linux/device.h> 22#include <linux/device.h>
22#include <linux/mod_devicetable.h> 23#include <linux/mod_devicetable.h>
23 24
@@ -42,7 +43,7 @@ struct serio {
42 struct serio *parent, *child; 43 struct serio *parent, *child;
43 44
44 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */ 45 struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
45 struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */ 46 struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */
46 47
47 struct device dev; 48 struct device dev;
48 unsigned int registered; /* port has been fully registered with driver core */ 49 unsigned int registered; /* port has been fully registered with driver core */
@@ -151,17 +152,17 @@ static inline void serio_continue_rx(struct serio *serio)
151 */ 152 */
152static inline int serio_pin_driver(struct serio *serio) 153static inline int serio_pin_driver(struct serio *serio)
153{ 154{
154 return down_interruptible(&serio->drv_sem); 155 return mutex_lock_interruptible(&serio->drv_mutex);
155} 156}
156 157
157static inline void serio_pin_driver_uninterruptible(struct serio *serio) 158static inline void serio_pin_driver_uninterruptible(struct serio *serio)
158{ 159{
159 down(&serio->drv_sem); 160 mutex_lock(&serio->drv_mutex);
160} 161}
161 162
162static inline void serio_unpin_driver(struct serio *serio) 163static inline void serio_unpin_driver(struct serio *serio)
163{ 164{
164 up(&serio->drv_sem); 165 mutex_unlock(&serio->drv_mutex);
165} 166}
166 167
167 168
diff --git a/include/linux/uinput.h b/include/linux/uinput.h
index 0ff7ca68e5c5..7168302f9844 100644
--- a/include/linux/uinput.h
+++ b/include/linux/uinput.h
@@ -20,7 +20,7 @@
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * 21 *
22 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> 22 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
23 * 23 *
24 * Changes/Revisions: 24 * Changes/Revisions:
25 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) 25 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>)
26 * - added force feedback support 26 * - added force feedback support
@@ -51,7 +51,7 @@ struct uinput_request {
51 51
52struct uinput_device { 52struct uinput_device {
53 struct input_dev *dev; 53 struct input_dev *dev;
54 struct semaphore sem; 54 struct mutex mutex;
55 enum uinput_state state; 55 enum uinput_state state;
56 wait_queue_head_t waitq; 56 wait_queue_head_t waitq;
57 unsigned char ready; 57 unsigned char ready;