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