Merge master.kernel.org:/pub/scm/linux/kernel/git/dtor/input

* master.kernel.org:/pub/scm/linux/kernel/git/dtor/input: (26 commits)
Input: add support for Braille devices
Input: synaptics - limit rate to 40pps on Toshiba Protege M300
Input: gamecon - add SNES mouse support
Input: make modalias code respect allowed buffer size
Input: convert /proc handling to seq_file
Input: limit attributes' output to PAGE_SIZE
Input: gameport - fix memory leak
Input: serio - fix memory leak
Input: zaurus keyboard driver updates
Input: i8042 - fix logic around pnp_register_driver()
Input: ns558 - fix logic around pnp_register_driver()
Input: pcspkr - separate device and driver registration
Input: atkbd - allow disabling on X86_PC (if EMBEDDED)
Input: atkbd - disable softrepeat for dumb keyboards
Input: atkbd - fix complaints about 'releasing unknown key 0x7f'
Input: HID - fix duplicate key mapping for Logitech UltraX remote
Input: use kzalloc() throughout the code
Input: fix input_free_device() implementation
Input: initialize serio and gameport at subsystem level
Input: uinput - semaphore to mutex conversion
...

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