Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 25 Oct 2010 14:59:01 +0000 (07:59 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 25 Oct 2010 14:59:01 +0000 (07:59 -0700)
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (75 commits)
  Input: wacom - specify Cinitq supported tools
  Input: ab8500-ponkey - fix IRQ freeing in error path
  Input: adp5588-keys - use more obvious i2c_device_id name string
  Input: ad7877 - switch to using threaded IRQ
  Input: ad7877 - use attribute group to control visibility of attributes
  Input: serio - add support for PS2Mult multiplexer protocol
  Input: wacom - properly enable runtime PM
  Input: ad7877 - filter events where pressure is beyond the maximum
  Input: ad7877 - implement EV_KEY:BTN_TOUCH reporting
  Input: ad7877 - implement specified chip select behavior
  Input: hp680_ts_input - use cancel_delayed_work_sync()
  Input: mousedev - correct lockdep annotation
  Input: ads7846 - switch to using threaded IRQ
  Input: serio - support multiple child devices per single parent
  Input: synaptics - simplify pass-through port handling
  Input: add ROHM BU21013 touch panel controller support
  Input: omap4-keypad - wake-up on events & long presses
  Input: omap4-keypad - fix interrupt line configuration
  Input: omap4-keypad - SYSCONFIG register configuration
  Input: omap4-keypad - use platform device helpers
  ...

16 files changed:
1  2 
arch/arm/mach-ux500/board-mop500.c
arch/arm/mach-ux500/devices-db8500.c
arch/arm/mach-ux500/include/mach/devices.h
arch/arm/mach-ux500/pins-db8500.h
drivers/char/sysrq.c
drivers/hid/hid-core.c
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/input/evdev.c
drivers/input/input.c
drivers/input/keyboard/Kconfig
drivers/input/mousedev.c
drivers/media/IR/ir-keytable.c
drivers/staging/Kconfig
drivers/staging/Makefile
include/linux/input.h

  #include <linux/amba/pl022.h>
  #include <linux/spi/spi.h>
  #include <linux/mfd/ab8500.h>
+ #include <linux/input/matrix_keypad.h>
  
  #include <asm/mach-types.h>
  #include <asm/mach/arch.h>
  
  #include <plat/pincfg.h>
  #include <plat/i2c.h>
+ #include <plat/ske.h>
  
  #include <mach/hardware.h>
  #include <mach/setup.h>
  #include <mach/devices.h>
 +#include <mach/irqs.h>
  
  #include "pins-db8500.h"
 +#include "board-mop500.h"
  
  static pin_cfg_t mop500_pins[] = {
        /* SSP0 */
        GPIO11_I2C2_SCL,
        GPIO229_I2C3_SDA,
        GPIO230_I2C3_SCL,
+       /* SKE keypad */
+       GPIO153_KP_I7,
+       GPIO154_KP_I6,
+       GPIO155_KP_I5,
+       GPIO156_KP_I4,
+       GPIO157_KP_O7,
+       GPIO158_KP_O6,
+       GPIO159_KP_O5,
+       GPIO160_KP_O4,
+       GPIO161_KP_I3,
+       GPIO162_KP_I2,
+       GPIO163_KP_I1,
+       GPIO164_KP_I0,
+       GPIO165_KP_O3,
+       GPIO166_KP_O2,
+       GPIO167_KP_O1,
+       GPIO168_KP_O0,
  };
  
  static void ab4500_spi_cs_control(u32 command)
  }
  
  struct pl022_config_chip ab4500_chip_info = {
 -      .lbm = LOOPBACK_DISABLED,
        .com_mode = INTERRUPT_TRANSFER,
        .iface = SSP_INTERFACE_MOTOROLA_SPI,
        /* we can act as master only */
        .hierarchy = SSP_MASTER,
        .slave_tx_disable = 0,
 -      .endian_rx = SSP_RX_MSB,
 -      .endian_tx = SSP_TX_MSB,
 -      .data_size = SSP_DATA_BITS_24,
        .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
        .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
 -      .clk_phase = SSP_CLK_SECOND_EDGE,
 -      .clk_pol = SSP_CLK_POL_IDLE_HIGH,
        .cs_control = ab4500_spi_cs_control,
  };
  
@@@ -71,33 -95,15 +91,33 @@@ static struct ab8500_platform_data ab85
        .irq_base       = MOP500_AB8500_IRQ_BASE,
  };
  
 -static struct spi_board_info u8500_spi_devices[] = {
 +static struct resource ab8500_resources[] = {
 +      [0] = {
 +              .start = IRQ_AB8500,
 +              .end = IRQ_AB8500,
 +              .flags = IORESOURCE_IRQ
 +      }
 +};
 +
 +struct platform_device ab8500_device = {
 +      .name = "ab8500-i2c",
 +      .id = 0,
 +      .dev = {
 +              .platform_data = &ab8500_platdata,
 +      },
 +      .num_resources = 1,
 +      .resource = ab8500_resources,
 +};
 +
 +static struct spi_board_info ab8500_spi_devices[] = {
        {
 -              .modalias = "ab8500",
 +              .modalias = "ab8500-spi",
                .controller_data = &ab4500_chip_info,
                .platform_data = &ab8500_platdata,
                .max_speed_hz = 12000000,
                .bus_num = 0,
                .chip_select = 0,
 -              .mode = SPI_MODE_0,
 +              .mode = SPI_MODE_3,
                .irq = IRQ_DB8500_AB8500,
        },
  };
@@@ -148,12 -154,120 +168,120 @@@ static struct amba_device *amba_devs[] 
        &u8500_ssp0_device,
  };
  
+ static const unsigned int ux500_keymap[] = {
+       KEY(2, 5, KEY_END),
+       KEY(4, 1, KEY_POWER),
+       KEY(3, 5, KEY_VOLUMEDOWN),
+       KEY(1, 3, KEY_3),
+       KEY(5, 2, KEY_RIGHT),
+       KEY(5, 0, KEY_9),
+       KEY(0, 5, KEY_MENU),
+       KEY(7, 6, KEY_ENTER),
+       KEY(4, 5, KEY_0),
+       KEY(6, 7, KEY_2),
+       KEY(3, 4, KEY_UP),
+       KEY(3, 3, KEY_DOWN),
+       KEY(6, 4, KEY_SEND),
+       KEY(6, 2, KEY_BACK),
+       KEY(4, 2, KEY_VOLUMEUP),
+       KEY(5, 5, KEY_1),
+       KEY(4, 3, KEY_LEFT),
+       KEY(3, 2, KEY_7),
+ };
+ static const struct matrix_keymap_data ux500_keymap_data = {
+       .keymap         = ux500_keymap,
+       .keymap_size    = ARRAY_SIZE(ux500_keymap),
+ };
+ /*
+  * Nomadik SKE keypad
+  */
+ #define ROW_PIN_I0      164
+ #define ROW_PIN_I1      163
+ #define ROW_PIN_I2      162
+ #define ROW_PIN_I3      161
+ #define ROW_PIN_I4      156
+ #define ROW_PIN_I5      155
+ #define ROW_PIN_I6      154
+ #define ROW_PIN_I7      153
+ #define COL_PIN_O0      168
+ #define COL_PIN_O1      167
+ #define COL_PIN_O2      166
+ #define COL_PIN_O3      165
+ #define COL_PIN_O4      160
+ #define COL_PIN_O5      159
+ #define COL_PIN_O6      158
+ #define COL_PIN_O7      157
+ #define SKE_KPD_MAX_ROWS        8
+ #define SKE_KPD_MAX_COLS        8
+ static int ske_kp_rows[] = {
+       ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3,
+       ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7,
+ };
+ /*
+  * ske_set_gpio_row: request and set gpio rows
+  */
+ static int ske_set_gpio_row(int gpio)
+ {
+       int ret;
+       ret = gpio_request(gpio, "ske-kp");
+       if (ret < 0) {
+               pr_err("ske_set_gpio_row: gpio request failed\n");
+               return ret;
+       }
+       ret = gpio_direction_output(gpio, 1);
+       if (ret < 0) {
+               pr_err("ske_set_gpio_row: gpio direction failed\n");
+               gpio_free(gpio);
+       }
+       return ret;
+ }
+ /*
+  * ske_kp_init - enable the gpio configuration
+  */
+ static int ske_kp_init(void)
+ {
+       int ret, i;
+       for (i = 0; i < SKE_KPD_MAX_ROWS; i++) {
+               ret = ske_set_gpio_row(ske_kp_rows[i]);
+               if (ret < 0) {
+                       pr_err("ske_kp_init: failed init\n");
+                       return ret;
+               }
+       }
+       return 0;
+ }
+ static struct ske_keypad_platform_data ske_keypad_board = {
+       .init           = ske_kp_init,
+       .keymap_data    = &ux500_keymap_data,
+       .no_autorepeat  = true,
+       .krow           = SKE_KPD_MAX_ROWS,     /* 8x8 matrix */
+       .kcol           = SKE_KPD_MAX_COLS,
+       .debounce_ms    = 40,                   /* in millsecs */
+ };
  /* add any platform devices here - TODO */
  static struct platform_device *platform_devs[] __initdata = {
        &u8500_i2c0_device,
        &ux500_i2c1_device,
        &ux500_i2c2_device,
        &ux500_i2c3_device,
+       &ux500_ske_keypad_device,
  };
  
  static void __init u8500_init_machine(void)
        ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
        ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
        ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
+       ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board;
  
        u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
  
  
        platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
  
 -      spi_register_board_info(u8500_spi_devices,
 -                      ARRAY_SIZE(u8500_spi_devices));
 +      mop500_sdi_init();
 +
 +      /* If HW is early drop (ED) or V1.0 then use SPI to access AB8500 */
 +      if (cpu_is_u8500ed() || cpu_is_u8500v10())
 +              spi_register_board_info(ab8500_spi_devices,
 +                      ARRAY_SIZE(ab8500_spi_devices));
 +      else /* If HW is v.1.1 or later use I2C to access AB8500 */
 +              platform_device_register(&ab8500_device);
  }
  
  MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
        /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
 -      .phys_io        = U8500_UART2_BASE,
 -      .io_pg_offst    = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
        .boot_params    = 0x100,
        .map_io         = u8500_map_io,
        .init_irq       = ux500_init_irq,
@@@ -110,82 -110,6 +110,82 @@@ struct platform_device u8500_i2c4_devic
        .num_resources  = ARRAY_SIZE(u8500_i2c4_resources),
  };
  
 +/*
 + * SD/MMC
 + */
 +
 +struct amba_device u8500_sdi0_device = {
 +      .dev            = {
 +              .init_name = "sdi0",
 +      },
 +      .res            = {
 +              .start  = U8500_SDI0_BASE,
 +              .end    = U8500_SDI0_BASE + SZ_4K - 1,
 +              .flags  = IORESOURCE_MEM,
 +      },
 +      .irq            = {IRQ_DB8500_SDMMC0, NO_IRQ},
 +};
 +
 +struct amba_device u8500_sdi1_device = {
 +      .dev            = {
 +              .init_name = "sdi1",
 +      },
 +      .res            = {
 +              .start  = U8500_SDI1_BASE,
 +              .end    = U8500_SDI1_BASE + SZ_4K - 1,
 +              .flags  = IORESOURCE_MEM,
 +      },
 +      .irq            = {IRQ_DB8500_SDMMC1, NO_IRQ},
 +};
 +
 +struct amba_device u8500_sdi2_device = {
 +      .dev            = {
 +              .init_name = "sdi2",
 +      },
 +      .res            = {
 +              .start  = U8500_SDI2_BASE,
 +              .end    = U8500_SDI2_BASE + SZ_4K - 1,
 +              .flags  = IORESOURCE_MEM,
 +      },
 +      .irq            = {IRQ_DB8500_SDMMC2, NO_IRQ},
 +};
 +
 +struct amba_device u8500_sdi3_device = {
 +      .dev            = {
 +              .init_name = "sdi3",
 +      },
 +      .res            = {
 +              .start  = U8500_SDI3_BASE,
 +              .end    = U8500_SDI3_BASE + SZ_4K - 1,
 +              .flags  = IORESOURCE_MEM,
 +      },
 +      .irq            = {IRQ_DB8500_SDMMC3, NO_IRQ},
 +};
 +
 +struct amba_device u8500_sdi4_device = {
 +      .dev            = {
 +              .init_name = "sdi4",
 +      },
 +      .res            = {
 +              .start  = U8500_SDI4_BASE,
 +              .end    = U8500_SDI4_BASE + SZ_4K - 1,
 +              .flags  = IORESOURCE_MEM,
 +      },
 +      .irq            = {IRQ_DB8500_SDMMC4, NO_IRQ},
 +};
 +
 +struct amba_device u8500_sdi5_device = {
 +      .dev            = {
 +              .init_name = "sdi5",
 +      },
 +      .res            = {
 +              .start  = U8500_SDI5_BASE,
 +              .end    = U8500_SDI5_BASE + SZ_4K - 1,
 +              .flags  = IORESOURCE_MEM,
 +      },
 +      .irq            = {IRQ_DB8500_SDMMC5, NO_IRQ},
 +};
 +
  static struct resource dma40_resources[] = {
        [0] = {
                .start = U8500_DMA_BASE,
@@@ -246,23 -170,23 +246,23 @@@ struct stedma40_chan_cfg dma40_memcpy_c
   * Mapping between destination event lines and physical device address.
   * The event line is tied to a device and therefor the address is constant.
   */
 -static const dma_addr_t dma40_tx_map[STEDMA40_NR_DEV];
 +static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV];
  
  /* Mapping between source event lines and physical device address */
 -static const dma_addr_t dma40_rx_map[STEDMA40_NR_DEV];
 +static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV];
  
  /* Reserved event lines for memcpy only */
  static int dma40_memcpy_event[] = {
 -      STEDMA40_MEMCPY_TX_0,
 -      STEDMA40_MEMCPY_TX_1,
 -      STEDMA40_MEMCPY_TX_2,
 -      STEDMA40_MEMCPY_TX_3,
 -      STEDMA40_MEMCPY_TX_4,
 -      STEDMA40_MEMCPY_TX_5,
 +      DB8500_DMA_MEMCPY_TX_0,
 +      DB8500_DMA_MEMCPY_TX_1,
 +      DB8500_DMA_MEMCPY_TX_2,
 +      DB8500_DMA_MEMCPY_TX_3,
 +      DB8500_DMA_MEMCPY_TX_4,
 +      DB8500_DMA_MEMCPY_TX_5,
  };
  
  static struct stedma40_platform_data dma40_plat_data = {
 -      .dev_len = STEDMA40_NR_DEV,
 +      .dev_len = DB8500_DMA_NR_DEV,
        .dev_rx = dma40_rx_map,
        .dev_tx = dma40_tx_map,
        .memcpy = dma40_memcpy_event,
@@@ -292,3 -216,23 +292,23 @@@ void dma40_u8500ed_fixup(void
        dma40_resources[1].start = U8500_DMA_LCPA_BASE_ED;
        dma40_resources[1].end = U8500_DMA_LCPA_BASE_ED + 2 * SZ_1K - 1;
  }
+ struct resource keypad_resources[] = {
+       [0] = {
+               .start = U8500_SKE_BASE,
+               .end = U8500_SKE_BASE + SZ_4K - 1,
+               .flags = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start = IRQ_DB8500_KB,
+               .end = IRQ_DB8500_KB,
+               .flags = IORESOURCE_IRQ,
+       },
+ };
+ struct platform_device ux500_ske_keypad_device = {
+       .name = "nmk-ske-keypad",
+       .id = -1,
+       .num_resources = ARRAY_SIZE(keypad_resources),
+       .resource = keypad_resources,
+ };
@@@ -26,14 -26,8 +26,15 @@@ extern struct platform_device ux500_i2c
  extern struct platform_device u8500_i2c0_device;
  extern struct platform_device u8500_i2c4_device;
  extern struct platform_device u8500_dma40_device;
+ extern struct platform_device ux500_ske_keypad_device;
  
 +extern struct amba_device u8500_sdi0_device;
 +extern struct amba_device u8500_sdi1_device;
 +extern struct amba_device u8500_sdi2_device;
 +extern struct amba_device u8500_sdi3_device;
 +extern struct amba_device u8500_sdi4_device;
 +extern struct amba_device u8500_sdi5_device;
 +
  void dma40_u8500ed_fixup(void);
  
  #endif
  #define GPIO17_SLIM0_CLK      PIN_CFG(17, ALT_C)
  
  #define GPIO18_GPIO           PIN_CFG(18, GPIO)
 -#define GPIO18_MC0_CMDDIR     PIN_CFG(18, ALT_A)
 +#define GPIO18_MC0_CMDDIR     PIN_CFG_PULL(18, ALT_A, UP)
  #define GPIO18_U2_RXD         PIN_CFG(18, ALT_B)
  #define GPIO18_MS_IEP         PIN_CFG(18, ALT_C)
  
  #define GPIO19_GPIO           PIN_CFG(19, GPIO)
 -#define GPIO19_MC0_DAT0DIR    PIN_CFG(19, ALT_A)
 +#define GPIO19_MC0_DAT0DIR    PIN_CFG_PULL(19, ALT_A, UP)
  #define GPIO19_U2_TXD         PIN_CFG(19, ALT_B)
  #define GPIO19_MS_DAT0DIR     PIN_CFG(19, ALT_C)
  
  #define GPIO20_GPIO           PIN_CFG(20, GPIO)
 -#define GPIO20_MC0_DAT2DIR    PIN_CFG(20, ALT_A)
 +#define GPIO20_MC0_DAT2DIR    PIN_CFG_PULL(20, ALT_A, UP)
  #define GPIO20_UARTMOD_TXD    PIN_CFG(20, ALT_B)
  #define GPIO20_IP_TRIGOUT     PIN_CFG(20, ALT_C)
  
  #define GPIO21_GPIO           PIN_CFG(21, GPIO)
 -#define GPIO21_MC0_DAT31DIR   PIN_CFG(21, ALT_A)
 +#define GPIO21_MC0_DAT31DIR   PIN_CFG_PULL(21, ALT_A, UP)
  #define GPIO21_MSP0_SCK               PIN_CFG(21, ALT_B)
  #define GPIO21_MS_DAT31DIR    PIN_CFG(21, ALT_C)
  
  #define GPIO22_GPIO           PIN_CFG(22, GPIO)
 -#define GPIO22_MC0_FBCLK      PIN_CFG(22, ALT_A)
 +#define GPIO22_MC0_FBCLK      PIN_CFG_PULL(22, ALT_A, UP)
  #define GPIO22_UARTMOD_RXD    PIN_CFG(22, ALT_B)
  #define GPIO22_MS_FBCLK               PIN_CFG(22, ALT_C)
  
  #define GPIO23_GPIO           PIN_CFG(23, GPIO)
 -#define GPIO23_MC0_CLK                PIN_CFG(23, ALT_A)
 +#define GPIO23_MC0_CLK                PIN_CFG_PULL(23, ALT_A, UP)
  #define GPIO23_STMMOD_CLK     PIN_CFG(23, ALT_B)
  #define GPIO23_MS_CLK         PIN_CFG(23, ALT_C)
  
  #define GPIO24_GPIO           PIN_CFG(24, GPIO)
 -#define GPIO24_MC0_CMD                PIN_CFG(24, ALT_A)
 +#define GPIO24_MC0_CMD                PIN_CFG_PULL(24, ALT_A, UP)
  #define GPIO24_UARTMOD_RXD    PIN_CFG(24, ALT_B)
  #define GPIO24_MS_BS          PIN_CFG(24, ALT_C)
  
  #define GPIO25_GPIO           PIN_CFG(25, GPIO)
 -#define GPIO25_MC0_DAT0               PIN_CFG(25, ALT_A)
 +#define GPIO25_MC0_DAT0               PIN_CFG_PULL(25, ALT_A, UP)
  #define GPIO25_STMMOD_DAT0    PIN_CFG(25, ALT_B)
  #define GPIO25_MS_DAT0                PIN_CFG(25, ALT_C)
  
  #define GPIO26_GPIO           PIN_CFG(26, GPIO)
 -#define GPIO26_MC0_DAT1               PIN_CFG(26, ALT_A)
 +#define GPIO26_MC0_DAT1               PIN_CFG_PULL(26, ALT_A, UP)
  #define GPIO26_STMMOD_DAT1    PIN_CFG(26, ALT_B)
  #define GPIO26_MS_DAT1                PIN_CFG(26, ALT_C)
  
  #define GPIO27_GPIO           PIN_CFG(27, GPIO)
 -#define GPIO27_MC0_DAT2               PIN_CFG(27, ALT_A)
 +#define GPIO27_MC0_DAT2               PIN_CFG_PULL(27, ALT_A, UP)
  #define GPIO27_STMMOD_DAT2    PIN_CFG(27, ALT_B)
  #define GPIO27_MS_DAT2                PIN_CFG(27, ALT_C)
  
  #define GPIO28_GPIO           PIN_CFG(28, GPIO)
 -#define GPIO28_MC0_DAT3               PIN_CFG(28, ALT_A)
 +#define GPIO28_MC0_DAT3               PIN_CFG_PULL(28, ALT_A, UP)
  #define GPIO28_STMMOD_DAT3    PIN_CFG(28, ALT_B)
  #define GPIO28_MS_DAT3                PIN_CFG(28, ALT_C)
  
  #define GPIO97_MC5_DAT7               PIN_CFG(97, ALT_C)
  
  #define GPIO128_GPIO          PIN_CFG(128, GPIO)
 -#define GPIO128_MC2_CLK               PIN_CFG(128, ALT_A)
 +#define GPIO128_MC2_CLK               PIN_CFG_PULL(128, ALT_A, UP)
  #define GPIO128_SM_CKO                PIN_CFG(128, ALT_B)
  
  #define GPIO129_GPIO          PIN_CFG(129, GPIO)
 -#define GPIO129_MC2_CMD               PIN_CFG(129, ALT_A)
 +#define GPIO129_MC2_CMD               PIN_CFG_PULL(129, ALT_A, UP)
  #define GPIO129_SM_WAIT0n     PIN_CFG(129, ALT_B)
  
  #define GPIO130_GPIO          PIN_CFG(130, GPIO)
 -#define GPIO130_MC2_FBCLK     PIN_CFG(130, ALT_A)
 +#define GPIO130_MC2_FBCLK     PIN_CFG_PULL(130, ALT_A, UP)
  #define GPIO130_SM_FBCLK      PIN_CFG(130, ALT_B)
  #define GPIO130_MC2_RSTN      PIN_CFG(130, ALT_C)
  
  #define GPIO131_GPIO          PIN_CFG(131, GPIO)
 -#define GPIO131_MC2_DAT0      PIN_CFG(131, ALT_A)
 +#define GPIO131_MC2_DAT0      PIN_CFG_PULL(131, ALT_A, UP)
  #define GPIO131_SM_ADQ8               PIN_CFG(131, ALT_B)
  
  #define GPIO132_GPIO          PIN_CFG(132, GPIO)
 -#define GPIO132_MC2_DAT1      PIN_CFG(132, ALT_A)
 +#define GPIO132_MC2_DAT1      PIN_CFG_PULL(132, ALT_A, UP)
  #define GPIO132_SM_ADQ9               PIN_CFG(132, ALT_B)
  
  #define GPIO133_GPIO          PIN_CFG(133, GPIO)
 -#define GPIO133_MC2_DAT2      PIN_CFG(133, ALT_A)
 +#define GPIO133_MC2_DAT2      PIN_CFG_PULL(133, ALT_A, UP)
  #define GPIO133_SM_ADQ10      PIN_CFG(133, ALT_B)
  
  #define GPIO134_GPIO          PIN_CFG(134, GPIO)
 -#define GPIO134_MC2_DAT3      PIN_CFG(134, ALT_A)
 +#define GPIO134_MC2_DAT3      PIN_CFG_PULL(134, ALT_A, UP)
  #define GPIO134_SM_ADQ11      PIN_CFG(134, ALT_B)
  
  #define GPIO135_GPIO          PIN_CFG(135, GPIO)
 -#define GPIO135_MC2_DAT4      PIN_CFG(135, ALT_A)
 +#define GPIO135_MC2_DAT4      PIN_CFG_PULL(135, ALT_A, UP)
  #define GPIO135_SM_ADQ12      PIN_CFG(135, ALT_B)
  
  #define GPIO136_GPIO          PIN_CFG(136, GPIO)
 -#define GPIO136_MC2_DAT5      PIN_CFG(136, ALT_A)
 +#define GPIO136_MC2_DAT5      PIN_CFG_PULL(136, ALT_A, UP)
  #define GPIO136_SM_ADQ13      PIN_CFG(136, ALT_B)
  
  #define GPIO137_GPIO          PIN_CFG(137, GPIO)
 -#define GPIO137_MC2_DAT6      PIN_CFG(137, ALT_A)
 +#define GPIO137_MC2_DAT6      PIN_CFG_PULL(137, ALT_A, UP)
  #define GPIO137_SM_ADQ14      PIN_CFG(137, ALT_B)
  
  #define GPIO138_GPIO          PIN_CFG(138, GPIO)
 -#define GPIO138_MC2_DAT7      PIN_CFG(138, ALT_A)
 +#define GPIO138_MC2_DAT7      PIN_CFG_PULL(138, ALT_A, UP)
  #define GPIO138_SM_ADQ15      PIN_CFG(138, ALT_B)
  
  #define GPIO139_GPIO          PIN_CFG(139, GPIO)
  #define GPIO152_KP_O9         PIN_CFG(152, ALT_C)
  
  #define GPIO153_GPIO          PIN_CFG(153, GPIO)
- #define GPIO153_KP_I7         PIN_CFG(153, ALT_A)
+ #define GPIO153_KP_I7         PIN_CFG_PULL(153, ALT_A, DOWN)
  #define GPIO153_LCD_D24               PIN_CFG(153, ALT_B)
  #define GPIO153_U2_RXD                PIN_CFG(153, ALT_C)
  
  #define GPIO154_GPIO          PIN_CFG(154, GPIO)
- #define GPIO154_KP_I6         PIN_CFG(154, ALT_A)
+ #define GPIO154_KP_I6         PIN_CFG_PULL(154, ALT_A, DOWN)
  #define GPIO154_LCD_D25               PIN_CFG(154, ALT_B)
  #define GPIO154_U2_TXD                PIN_CFG(154, ALT_C)
  
  #define GPIO155_GPIO          PIN_CFG(155, GPIO)
- #define GPIO155_KP_I5         PIN_CFG(155, ALT_A)
+ #define GPIO155_KP_I5         PIN_CFG_PULL(155, ALT_A, DOWN)
  #define GPIO155_LCD_D26               PIN_CFG(155, ALT_B)
  #define GPIO155_STMAPE_CLK    PIN_CFG(155, ALT_C)
  
  #define GPIO156_GPIO          PIN_CFG(156, GPIO)
- #define GPIO156_KP_I4         PIN_CFG(156, ALT_A)
+ #define GPIO156_KP_I4         PIN_CFG_PULL(156, ALT_A, DOWN)
  #define GPIO156_LCD_D27               PIN_CFG(156, ALT_B)
  #define GPIO156_STMAPE_DAT3   PIN_CFG(156, ALT_C)
  
  #define GPIO157_GPIO          PIN_CFG(157, GPIO)
- #define GPIO157_KP_O7         PIN_CFG(157, ALT_A)
+ #define GPIO157_KP_O7         PIN_CFG_PULL(157, ALT_A, UP)
  #define GPIO157_LCD_D28               PIN_CFG(157, ALT_B)
  #define GPIO157_STMAPE_DAT2   PIN_CFG(157, ALT_C)
  
  #define GPIO158_GPIO          PIN_CFG(158, GPIO)
- #define GPIO158_KP_O6         PIN_CFG(158, ALT_A)
+ #define GPIO158_KP_O6         PIN_CFG_PULL(158, ALT_A, UP)
  #define GPIO158_LCD_D29               PIN_CFG(158, ALT_B)
  #define GPIO158_STMAPE_DAT1   PIN_CFG(158, ALT_C)
  
  #define GPIO159_GPIO          PIN_CFG(159, GPIO)
- #define GPIO159_KP_O5         PIN_CFG(159, ALT_A)
+ #define GPIO159_KP_O5         PIN_CFG_PULL(159, ALT_A, UP)
  #define GPIO159_LCD_D30               PIN_CFG(159, ALT_B)
  #define GPIO159_STMAPE_DAT0   PIN_CFG(159, ALT_C)
  
  #define GPIO160_GPIO          PIN_CFG(160, GPIO)
- #define GPIO160_KP_O4         PIN_CFG(160, ALT_A)
+ #define GPIO160_KP_O4         PIN_CFG_PULL(160, ALT_A, UP)
  #define GPIO160_LCD_D31               PIN_CFG(160, ALT_B)
  #define GPIO160_NONE          PIN_CFG(160, ALT_C)
  
  #define GPIO161_GPIO          PIN_CFG(161, GPIO)
- #define GPIO161_KP_I3         PIN_CFG(161, ALT_A)
+ #define GPIO161_KP_I3         PIN_CFG_PULL(161, ALT_A, DOWN)
  #define GPIO161_LCD_D32               PIN_CFG(161, ALT_B)
  #define GPIO161_UARTMOD_RXD   PIN_CFG(161, ALT_C)
  
  #define GPIO162_GPIO          PIN_CFG(162, GPIO)
- #define GPIO162_KP_I2         PIN_CFG(162, ALT_A)
+ #define GPIO162_KP_I2         PIN_CFG_PULL(162, ALT_A, DOWN)
  #define GPIO162_LCD_D33               PIN_CFG(162, ALT_B)
  #define GPIO162_UARTMOD_TXD   PIN_CFG(162, ALT_C)
  
  #define GPIO163_GPIO          PIN_CFG(163, GPIO)
- #define GPIO163_KP_I1         PIN_CFG(163, ALT_A)
+ #define GPIO163_KP_I1         PIN_CFG_PULL(163, ALT_A, DOWN)
  #define GPIO163_LCD_D34               PIN_CFG(163, ALT_B)
  #define GPIO163_STMMOD_CLK    PIN_CFG(163, ALT_C)
  
  #define GPIO164_GPIO          PIN_CFG(164, GPIO)
- #define GPIO164_KP_I0         PIN_CFG(164, ALT_A)
+ #define GPIO164_KP_I0         PIN_CFG_PULL(164, ALT_A, UP)
  #define GPIO164_LCD_D35               PIN_CFG(164, ALT_B)
  #define GPIO164_STMMOD_DAT3   PIN_CFG(164, ALT_C)
  
  #define GPIO165_GPIO          PIN_CFG(165, GPIO)
- #define GPIO165_KP_O3         PIN_CFG(165, ALT_A)
+ #define GPIO165_KP_O3         PIN_CFG_PULL(165, ALT_A, UP)
  #define GPIO165_LCD_D36               PIN_CFG(165, ALT_B)
  #define GPIO165_STMMOD_DAT2   PIN_CFG(165, ALT_C)
  
  #define GPIO166_GPIO          PIN_CFG(166, GPIO)
- #define GPIO166_KP_O2         PIN_CFG(166, ALT_A)
+ #define GPIO166_KP_O2         PIN_CFG_PULL(166, ALT_A, UP)
  #define GPIO166_LCD_D37               PIN_CFG(166, ALT_B)
  #define GPIO166_STMMOD_DAT1   PIN_CFG(166, ALT_C)
  
  #define GPIO167_GPIO          PIN_CFG(167, GPIO)
- #define GPIO167_KP_O1         PIN_CFG(167, ALT_A)
+ #define GPIO167_KP_O1         PIN_CFG_PULL(167, ALT_A, UP)
  #define GPIO167_LCD_D38               PIN_CFG(167, ALT_B)
  #define GPIO167_STMMOD_DAT0   PIN_CFG(167, ALT_C)
  
  #define GPIO168_GPIO          PIN_CFG(168, GPIO)
- #define GPIO168_KP_O0         PIN_CFG(168, ALT_A)
+ #define GPIO168_KP_O0         PIN_CFG_PULL(168, ALT_A, UP)
  #define GPIO168_LCD_D39               PIN_CFG(168, ALT_B)
  #define GPIO168_NONE          PIN_CFG(168, ALT_C)
  
  #define GPIO196_MSP2_RXD      PIN_CFG(196, ALT_A)
  
  #define GPIO197_GPIO          PIN_CFG(197, GPIO)
 -#define GPIO197_MC4_DAT3      PIN_CFG(197, ALT_A)
 +#define GPIO197_MC4_DAT3      PIN_CFG_PULL(197, ALT_A, UP)
  
  #define GPIO198_GPIO          PIN_CFG(198, GPIO)
 -#define GPIO198_MC4_DAT2      PIN_CFG(198, ALT_A)
 +#define GPIO198_MC4_DAT2      PIN_CFG_PULL(198, ALT_A, UP)
  
  #define GPIO199_GPIO          PIN_CFG(199, GPIO)
 -#define GPIO199_MC4_DAT1      PIN_CFG(199, ALT_A)
 +#define GPIO199_MC4_DAT1      PIN_CFG_PULL(199, ALT_A, UP)
  
  #define GPIO200_GPIO          PIN_CFG(200, GPIO)
 -#define GPIO200_MC4_DAT0      PIN_CFG(200, ALT_A)
 +#define GPIO200_MC4_DAT0      PIN_CFG_PULL(200, ALT_A, UP)
  
  #define GPIO201_GPIO          PIN_CFG(201, GPIO)
 -#define GPIO201_MC4_CMD               PIN_CFG(201, ALT_A)
 +#define GPIO201_MC4_CMD               PIN_CFG_PULL(201, ALT_A, UP)
  
  #define GPIO202_GPIO          PIN_CFG(202, GPIO)
 -#define GPIO202_MC4_FBCLK     PIN_CFG(202, ALT_A)
 +#define GPIO202_MC4_FBCLK     PIN_CFG_PULL(202, ALT_A, UP)
  #define GPIO202_PWL           PIN_CFG(202, ALT_B)
  #define GPIO202_MC4_RSTN      PIN_CFG(202, ALT_C)
  
  #define GPIO203_GPIO          PIN_CFG(203, GPIO)
 -#define GPIO203_MC4_CLK               PIN_CFG(203, ALT_A)
 +#define GPIO203_MC4_CLK               PIN_CFG_PULL(203, ALT_A, UP)
  
  #define GPIO204_GPIO          PIN_CFG(204, GPIO)
 -#define GPIO204_MC4_DAT7      PIN_CFG(204, ALT_A)
 +#define GPIO204_MC4_DAT7      PIN_CFG_PULL(204, ALT_A, UP)
  
  #define GPIO205_GPIO          PIN_CFG(205, GPIO)
 -#define GPIO205_MC4_DAT6      PIN_CFG(205, ALT_A)
 +#define GPIO205_MC4_DAT6      PIN_CFG_PULL(205, ALT_A, UP)
  
  #define GPIO206_GPIO          PIN_CFG(206, GPIO)
 -#define GPIO206_MC4_DAT5      PIN_CFG(206, ALT_A)
 +#define GPIO206_MC4_DAT5      PIN_CFG_PULL(206, ALT_A, UP)
  
  #define GPIO207_GPIO          PIN_CFG(207, GPIO)
 -#define GPIO207_MC4_DAT4      PIN_CFG(207, ALT_A)
 +#define GPIO207_MC4_DAT4      PIN_CFG_PULL(207, ALT_A, UP)
  
  #define GPIO208_GPIO          PIN_CFG(208, GPIO)
  #define GPIO208_MC1_CLK               PIN_CFG(208, ALT_A)
diff --combined drivers/char/sysrq.c
@@@ -566,10 -566,16 +566,16 @@@ static const unsigned char sysrq_xlate[
  static bool sysrq_down;
  static int sysrq_alt_use;
  static int sysrq_alt;
+ static DEFINE_SPINLOCK(sysrq_event_lock);
  
  static bool sysrq_filter(struct input_handle *handle, unsigned int type,
                         unsigned int code, int value)
  {
+       bool suppress;
+       /* We are called with interrupts disabled, just take the lock */
+       spin_lock(&sysrq_event_lock);
        if (type != EV_KEY)
                goto out;
  
        }
  
  out:
-       return sysrq_down;
+       suppress = sysrq_down;
+       spin_unlock(&sysrq_event_lock);
+       return suppress;
  }
  
  static int sysrq_connect(struct input_handler *handler,
@@@ -652,8 -661,8 +661,8 @@@ static void sysrq_disconnect(struct inp
  }
  
  /*
-  * We are matching on KEY_LEFTALT insteard of KEY_SYSRQ because not all
-  * keyboards have SysRq ikey predefined and so user may add it to keymap
+  * We are matching on KEY_LEFTALT instead of KEY_SYSRQ because not all
+  * keyboards have SysRq key predefined and so user may add it to keymap
   * later, but we expect all such keyboards to have left alt.
   */
  static const struct input_device_id sysrq_ids[] = {
@@@ -772,7 -781,6 +781,7 @@@ static ssize_t write_sysrq_trigger(stru
  
  static const struct file_operations proc_sysrq_trigger_operations = {
        .write          = write_sysrq_trigger,
 +      .llseek         = noop_llseek,
  };
  
  static void sysrq_init_procfs(void)
diff --combined drivers/hid/hid-core.c
@@@ -388,6 -388,12 +388,6 @@@ static int hid_parser_local(struct hid_
        __u32 data;
        unsigned n;
  
 -      /* Local delimiter could have value 0, which allows size to be 0 */
 -      if (item->size == 0 && item->tag != HID_LOCAL_ITEM_TAG_DELIMITER) {
 -              dbg_hid("item data expected for local item\n");
 -              return -1;
 -      }
 -
        data = item_udata(item);
  
        switch (item->tag) {
@@@ -645,7 -651,7 +645,7 @@@ int hid_parse_report(struct hid_device 
        };
  
        if (device->driver->report_fixup)
 -              device->driver->report_fixup(device, start, size);
 +              start = device->driver->report_fixup(device, start, &size);
  
        device->rdesc = kmemdup(start, size, GFP_KERNEL);
        if (device->rdesc == NULL)
@@@ -1235,7 -1241,6 +1235,7 @@@ static const struct hid_device_id hid_b
        { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) },
        { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) },
        { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) },
  #if defined(CONFIG_HID_ACRUX_FF) || defined(CONFIG_HID_ACRUX_FF_MODULE)
        { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) },
  #endif
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
 +      { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
        { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO) },
        { HID_USB_DEVICE(USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM) },
        { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_CANDO, USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) },
        { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
        { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
        { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACETRAVELLER) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_SPACENAVIGATOR) },
        { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
        { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
        { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) },
        { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) },
        { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED, USB_DEVICE_ID_TOPSEED_CYBERLINK) },
        { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) },
        { HID_USB_DEVICE(USB_VENDOR_ID_TWINHAN, USB_DEVICE_ID_TWINHAN_IR_REMOTE) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_PF1209) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U) },
        { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
@@@ -1591,6 -1577,7 +1591,6 @@@ static const struct hid_device_id hid_i
        { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) },
        { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) },
 -      { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_T91MT)},
        { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)},
        { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)},
        { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) },
        { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
        { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
        { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_YUREX) },
        { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
        { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
        { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) },
@@@ -1780,6 -1766,11 +1780,11 @@@ static bool hid_ignore(struct hid_devic
                    hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST)
                        return true;
                break;
+       case USB_VENDOR_ID_HANWANG:
+               if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST &&
+                   hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST)
+                       return true;
+               break;
        }
  
        if (hdev->type == HID_TYPE_USBMOUSE &&
diff --combined drivers/hid/hid-ids.h
@@@ -25,7 -25,6 +25,7 @@@
  #define USB_VENDOR_ID_A4TECH          0x09da
  #define USB_DEVICE_ID_A4TECH_WCP32PU  0x0006
  #define USB_DEVICE_ID_A4TECH_X5_005D  0x000a
 +#define USB_DEVICE_ID_A4TECH_RP_649   0x001a
  
  #define USB_VENDOR_ID_AASHIMA         0x06d6
  #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025
@@@ -64,7 -63,6 +64,7 @@@
  #define USB_VENDOR_ID_APPLE           0x05ac
  #define USB_DEVICE_ID_APPLE_MIGHTYMOUSE       0x0304
  #define USB_DEVICE_ID_APPLE_MAGICMOUSE        0x030d
 +#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD     0x030e
  #define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI     0x020e
  #define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO      0x020f
  #define USB_DEVICE_ID_APPLE_GEYSER_ANSI       0x0214
  
  #define USB_VENDOR_ID_ASUS            0x0486
  #define USB_DEVICE_ID_ASUS_T91MT      0x0185
 +#define USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO  0x0186
  
  #define USB_VENDOR_ID_ASUSTEK         0x0b05
  #define USB_DEVICE_ID_ASUSTEK_LCM     0x1726
  
  #define USB_VENDOR_ID_BTC             0x046e
  #define USB_DEVICE_ID_BTC_EMPREX_REMOTE       0x5578
 +#define USB_DEVICE_ID_BTC_EMPREX_REMOTE_2     0x5577
  
  #define USB_VENDOR_ID_CANDO           0x2087
  #define USB_DEVICE_ID_CANDO_MULTI_TOUCH       0x0a01
  #define USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6 0x0b03
 +#define USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6 0x0f01
  
  #define USB_VENDOR_ID_CH              0x068e
  #define USB_DEVICE_ID_CH_PRO_PEDALS   0x00f2
  #define USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE       0x0051
  #define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE      0x00ff
  #define USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK  0x00d3
 +#define USB_DEVICE_ID_CH_AXIS_295     0x001c
  
  #define USB_VENDOR_ID_CHERRY          0x046a
  #define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023
  
  #define USB_VENDOR_ID_CHICONY         0x04f2
  #define USB_DEVICE_ID_CHICONY_TACTICAL_PAD    0x0418
 +#define USB_DEVICE_ID_CHICONY_MULTI_TOUCH     0xb19d
  
  #define USB_VENDOR_ID_CIDC            0x1677
  
  #define USB_VENDOR_ID_DWAV            0x0eef
  #define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER  0x0001
  #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH  0x480d
 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1 0x720c
  
  #define USB_VENDOR_ID_ELECOM          0x056e
  #define USB_DEVICE_ID_ELECOM_BM084    0x0061
  #define USB_DEVICE_ID_GYRATION_REMOTE_2 0x0003
  #define USB_DEVICE_ID_GYRATION_REMOTE_3 0x0008
  
+ #define USB_VENDOR_ID_HANWANG         0x0b57
+ #define USB_DEVICE_ID_HANWANG_TABLET_FIRST    0x5000
+ #define USB_DEVICE_ID_HANWANG_TABLET_LAST     0x8fff
  #define USB_VENDOR_ID_HAPP            0x078b
  #define USB_DEVICE_ID_UGCI_DRIVING    0x0010
  #define USB_DEVICE_ID_UGCI_FLYING     0x0020
  #define USB_VENDOR_ID_IMATION         0x0718
  #define USB_DEVICE_ID_DISC_STAKKA     0xd000
  
 +#define USB_VENDOR_ID_JESS            0x0c45
 +#define USB_DEVICE_ID_JESS_YUREX      0x1010
 +
  #define USB_VENDOR_ID_KBGEAR          0x084e
  #define USB_DEVICE_ID_KBGEAR_JAMSTUDIO        0x1001
  
  #define USB_DEVICE_ID_LOGITECH_RECEIVER       0xc101
  #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST  0xc110
  #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
 +#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD 0xc20a
  #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD      0xc211
  #define USB_DEVICE_ID_LOGITECH_EXTREME_3D     0xc215
  #define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2     0xc218
  #define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG    0xc293
  #define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL     0xc295
  #define USB_DEVICE_ID_LOGITECH_G25_WHEEL      0xc299
 +#define USB_DEVICE_ID_LOGITECH_WII_WHEEL      0xc29c
  #define USB_DEVICE_ID_LOGITECH_ELITE_KBD      0xc30a
  #define USB_DEVICE_ID_S510_RECEIVER   0xc50c
  #define USB_DEVICE_ID_S510_RECEIVER_2 0xc517
  
  #define USB_VENDOR_ID_ROCCAT          0x1e7d
  #define USB_DEVICE_ID_ROCCAT_KONE     0x2ced
 +#define USB_DEVICE_ID_ROCCAT_PYRA_WIRED       0x2c24
 +#define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS    0x2cf6
  
  #define USB_VENDOR_ID_SAITEK          0x06a3
  #define USB_DEVICE_ID_SAITEK_RUMBLEPAD        0xff17
  #define USB_VENDOR_ID_STANTUM         0x1f87
  #define USB_DEVICE_ID_MTP             0x0002
  
 +#define USB_VENDOR_ID_STANTUM_STM             0x0483
 +#define USB_DEVICE_ID_MTP_STM         0x3261
 +
 +#define USB_VENDOR_ID_STANTUM_SITRONIX                0x1403
 +#define USB_DEVICE_ID_MTP_SITRONIX            0x5001
 +
  #define USB_VENDOR_ID_SUN             0x0430
  #define USB_DEVICE_ID_RARITAN_KVM_DONGLE      0xcdab
  
  
  #define USB_VENDOR_ID_TURBOX          0x062a
  #define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
 +#define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART       0x7100
  
  #define USB_VENDOR_ID_TWINHAN         0x6253
  #define USB_DEVICE_ID_TWINHAN_IR_REMOTE       0x0100
  
  #define USB_VENDOR_ID_UCLOGIC         0x5543
  #define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209   0x0042
 +#define USB_DEVICE_ID_UCLOGIC_TABLET_KNA5     0x6001
  #define USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U  0x0003
 +#define USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U  0x0004
 +#define USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U  0x0005
  
  #define USB_VENDOR_ID_VERNIER         0x08f7
  #define USB_DEVICE_ID_VERNIER_LABPRO  0x0001
  #define USB_VENDOR_ID_WACOM           0x056a
  #define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH        0x81
  
 +#define USB_VENDOR_ID_WALTOP                          0x172f
 +#define USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH     0x0032
 +#define USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH    0x0034
 +#define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH   0x0501
 +#define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH   0x0500
 +
  #define USB_VENDOR_ID_WISEGROUP               0x0925
  #define USB_DEVICE_ID_SMARTJOY_PLUS   0x0005
  #define USB_DEVICE_ID_1_PHIDGETSERVO_20       0x8101
diff --combined drivers/hid/hid-input.c
@@@ -68,39 -68,52 +68,52 @@@ static const struct 
  #define map_key_clear(c)      hid_map_usage_clear(hidinput, usage, &bit, \
                &max, EV_KEY, (c))
  
- static inline int match_scancode(unsigned int code, unsigned int scancode)
+ static bool match_scancode(struct hid_usage *usage,
+                          unsigned int cur_idx, unsigned int scancode)
  {
-       if (scancode == 0)
-               return 1;
-       return (code & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
+       return (usage->hid & (HID_USAGE_PAGE | HID_USAGE)) == scancode;
  }
  
- static inline int match_keycode(unsigned int code, unsigned int keycode)
+ static bool match_keycode(struct hid_usage *usage,
+                         unsigned int cur_idx, unsigned int keycode)
  {
-       if (keycode == 0)
-               return 1;
+       /*
+        * We should exclude unmapped usages when doing lookup by keycode.
+        */
+       return (usage->type == EV_KEY && usage->code == keycode);
+ }
  
-       return code == keycode;
+ static bool match_index(struct hid_usage *usage,
+                       unsigned int cur_idx, unsigned int idx)
+ {
+       return cur_idx == idx;
  }
  
+ typedef bool (*hid_usage_cmp_t)(struct hid_usage *usage,
+                               unsigned int cur_idx, unsigned int val);
  static struct hid_usage *hidinput_find_key(struct hid_device *hid,
-                                          unsigned int scancode,
-                                          unsigned int keycode)
+                                          hid_usage_cmp_t match,
+                                          unsigned int value,
+                                          unsigned int *usage_idx)
  {
-       int i, j, k;
+       unsigned int i, j, k, cur_idx = 0;
        struct hid_report *report;
        struct hid_usage *usage;
  
        for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
                list_for_each_entry(report, &hid->report_enum[k].report_list, list) {
                        for (i = 0; i < report->maxfield; i++) {
-                               for ( j = 0; j < report->field[i]->maxusage; j++) {
+                               for (j = 0; j < report->field[i]->maxusage; j++) {
                                        usage = report->field[i]->usage + j;
-                                       if (usage->type == EV_KEY &&
-                                               match_scancode(usage->hid, scancode) &&
-                                               match_keycode(usage->code, keycode))
-                                               return usage;
+                                       if (usage->type == EV_KEY || usage->type == 0) {
+                                               if (match(usage, cur_idx, value)) {
+                                                       if (usage_idx)
+                                                               *usage_idx = cur_idx;
+                                                       return usage;
+                                               }
+                                               cur_idx++;
+                                       }
                                }
                        }
                }
        return NULL;
  }
  
+ static struct hid_usage *hidinput_locate_usage(struct hid_device *hid,
+                                       const struct input_keymap_entry *ke,
+                                       unsigned int *index)
+ {
+       struct hid_usage *usage;
+       unsigned int scancode;
+       if (ke->flags & INPUT_KEYMAP_BY_INDEX)
+               usage = hidinput_find_key(hid, match_index, ke->index, index);
+       else if (input_scancode_to_scalar(ke, &scancode) == 0)
+               usage = hidinput_find_key(hid, match_scancode, scancode, index);
+       else
+               usage = NULL;
+       return usage;
+ }
  static int hidinput_getkeycode(struct input_dev *dev,
-                              unsigned int scancode, unsigned int *keycode)
+                              struct input_keymap_entry *ke)
  {
        struct hid_device *hid = input_get_drvdata(dev);
        struct hid_usage *usage;
+       unsigned int scancode, index;
  
-       usage = hidinput_find_key(hid, scancode, 0);
+       usage = hidinput_locate_usage(hid, ke, &index);
        if (usage) {
-               *keycode = usage->code;
+               ke->keycode = usage->type == EV_KEY ?
+                               usage->code : KEY_RESERVED;
+               ke->index = index;
+               scancode = usage->hid & (HID_USAGE_PAGE | HID_USAGE);
+               ke->len = sizeof(scancode);
+               memcpy(ke->scancode, &scancode, sizeof(scancode));
                return 0;
        }
        return -EINVAL;
  }
  
  static int hidinput_setkeycode(struct input_dev *dev,
-                              unsigned int scancode, unsigned int keycode)
+                              const struct input_keymap_entry *ke,
+                              unsigned int *old_keycode)
  {
        struct hid_device *hid = input_get_drvdata(dev);
        struct hid_usage *usage;
-       int old_keycode;
  
-       usage = hidinput_find_key(hid, scancode, 0);
+       usage = hidinput_locate_usage(hid, ke, NULL);
        if (usage) {
-               old_keycode = usage->code;
-               usage->code = keycode;
+               *old_keycode = usage->type == EV_KEY ?
+                               usage->code : KEY_RESERVED;
+               usage->code = ke->keycode;
  
-               clear_bit(old_keycode, dev->keybit);
+               clear_bit(*old_keycode, dev->keybit);
                set_bit(usage->code, dev->keybit);
-               dbg_hid(KERN_DEBUG "Assigned keycode %d to HID usage code %x\n", keycode, scancode);
-               /* Set the keybit for the old keycode if the old keycode is used
-                * by another key */
-               if (hidinput_find_key (hid, 0, old_keycode))
-                       set_bit(old_keycode, dev->keybit);
+               dbg_hid(KERN_DEBUG "Assigned keycode %d to HID usage code %x\n",
+                       usage->code, usage->hid);
+               /*
+                * Set the keybit for the old keycode if the old keycode is used
+                * by another key
+                */
+               if (hidinput_find_key(hid, match_keycode, *old_keycode, NULL))
+                       set_bit(*old_keycode, dev->keybit);
  
                return 0;
        }
  }
  
  
 +/**
 + * hidinput_calc_abs_res - calculate an absolute axis resolution
 + * @field: the HID report field to calculate resolution for
 + * @code: axis code
 + *
 + * The formula is:
 + *                         (logical_maximum - logical_minimum)
 + * resolution = ----------------------------------------------------------
 + *              (physical_maximum - physical_minimum) * 10 ^ unit_exponent
 + *
 + * as seen in the HID specification v1.11 6.2.2.7 Global Items.
 + *
 + * Only exponent 1 length units are processed. Centimeters are converted to
 + * inches. Degrees are converted to radians.
 + */
 +static __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code)
 +{
 +      __s32 unit_exponent = field->unit_exponent;
 +      __s32 logical_extents = field->logical_maximum -
 +                                      field->logical_minimum;
 +      __s32 physical_extents = field->physical_maximum -
 +                                      field->physical_minimum;
 +      __s32 prev;
 +
 +      /* Check if the extents are sane */
 +      if (logical_extents <= 0 || physical_extents <= 0)
 +              return 0;
 +
 +      /*
 +       * Verify and convert units.
 +       * See HID specification v1.11 6.2.2.7 Global Items for unit decoding
 +       */
 +      if (code == ABS_X || code == ABS_Y || code == ABS_Z) {
 +              if (field->unit == 0x11) {              /* If centimeters */
 +                      /* Convert to inches */
 +                      prev = logical_extents;
 +                      logical_extents *= 254;
 +                      if (logical_extents < prev)
 +                              return 0;
 +                      unit_exponent += 2;
 +              } else if (field->unit != 0x13) {       /* If not inches */
 +                      return 0;
 +              }
 +      } else if (code == ABS_RX || code == ABS_RY || code == ABS_RZ) {
 +              if (field->unit == 0x14) {              /* If degrees */
 +                      /* Convert to radians */
 +                      prev = logical_extents;
 +                      logical_extents *= 573;
 +                      if (logical_extents < prev)
 +                              return 0;
 +                      unit_exponent += 1;
 +              } else if (field->unit != 0x12) {       /* If not radians */
 +                      return 0;
 +              }
 +      } else {
 +              return 0;
 +      }
 +
 +      /* Apply negative unit exponent */
 +      for (; unit_exponent < 0; unit_exponent++) {
 +              prev = logical_extents;
 +              logical_extents *= 10;
 +              if (logical_extents < prev)
 +                      return 0;
 +      }
 +      /* Apply positive unit exponent */
 +      for (; unit_exponent > 0; unit_exponent--) {
 +              prev = physical_extents;
 +              physical_extents *= 10;
 +              if (physical_extents < prev)
 +                      return 0;
 +      }
 +
 +      /* Calculate resolution */
 +      return logical_extents / physical_extents;
 +}
 +
  static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field,
                                     struct hid_usage *usage)
  {
                        map_key_clear(BTN_STYLUS);
                        break;
  
 +              case 0x46: /* TabletPick */
 +                      map_key_clear(BTN_STYLUS2);
 +                      break;
 +
                default:  goto unknown;
                }
                break;
@@@ -618,9 -579,6 +660,9 @@@ mapped
                        input_set_abs_params(input, usage->code, a, b, (b - a) >> 8, (b - a) >> 4);
                else    input_set_abs_params(input, usage->code, a, b, 0, 0);
  
 +              input_abs_set_res(input, usage->code,
 +                                hidinput_calc_abs_res(field, usage->code));
 +
                /* use a larger default input buffer for MT devices */
                if (usage->code == ABS_MT_POSITION_X && input->hint_events_per_packet == 0)
                        input_set_events_per_packet(input, 60);
@@@ -743,9 -701,6 +785,9 @@@ void hidinput_report_event(struct hid_d
  {
        struct hid_input *hidinput;
  
 +      if (hid->quirks & HID_QUIRK_NO_INPUT_SYNC)
 +              return;
 +
        list_for_each_entry(hidinput, &hid->inputs, list)
                input_sync(hidinput->input);
  }
@@@ -835,8 -790,8 +877,8 @@@ int hidinput_connect(struct hid_device 
                                        hid->ll_driver->hidinput_input_event;
                                input_dev->open = hidinput_open;
                                input_dev->close = hidinput_close;
-                               input_dev->setkeycode = hidinput_setkeycode;
-                               input_dev->getkeycode = hidinput_getkeycode;
+                               input_dev->setkeycode_new = hidinput_setkeycode;
+                               input_dev->getkeycode_new = hidinput_getkeycode;
  
                                input_dev->name = hid->name;
                                input_dev->phys = hid->phys;
diff --combined drivers/input/evdev.c
@@@ -28,7 -28,7 +28,7 @@@ struct evdev 
        int minor;
        struct input_handle handle;
        wait_queue_head_t wait;
 -      struct evdev_client *grab;
 +      struct evdev_client __rcu *grab;
        struct list_head client_list;
        spinlock_t client_lock; /* protects client_list */
        struct mutex mutex;
@@@ -534,6 -534,80 +534,80 @@@ static int handle_eviocgbit(struct inpu
  }
  #undef OLD_KEY_MAX
  
+ static int evdev_handle_get_keycode(struct input_dev *dev,
+                                   void __user *p, size_t size)
+ {
+       struct input_keymap_entry ke;
+       int error;
+       memset(&ke, 0, sizeof(ke));
+       if (size == sizeof(unsigned int[2])) {
+               /* legacy case */
+               int __user *ip = (int __user *)p;
+               if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
+                       return -EFAULT;
+               ke.len = sizeof(unsigned int);
+               ke.flags = 0;
+               error = input_get_keycode(dev, &ke);
+               if (error)
+                       return error;
+               if (put_user(ke.keycode, ip + 1))
+                       return -EFAULT;
+       } else {
+               size = min(size, sizeof(ke));
+               if (copy_from_user(&ke, p, size))
+                       return -EFAULT;
+               error = input_get_keycode(dev, &ke);
+               if (error)
+                       return error;
+               if (copy_to_user(p, &ke, size))
+                       return -EFAULT;
+       }
+       return 0;
+ }
+ static int evdev_handle_set_keycode(struct input_dev *dev,
+                                   void __user *p, size_t size)
+ {
+       struct input_keymap_entry ke;
+       memset(&ke, 0, sizeof(ke));
+       if (size == sizeof(unsigned int[2])) {
+               /* legacy case */
+               int __user *ip = (int __user *)p;
+               if (copy_from_user(ke.scancode, p, sizeof(unsigned int)))
+                       return -EFAULT;
+               if (get_user(ke.keycode, ip + 1))
+                       return -EFAULT;
+               ke.len = sizeof(unsigned int);
+               ke.flags = 0;
+       } else {
+               size = min(size, sizeof(ke));
+               if (copy_from_user(&ke, p, size))
+                       return -EFAULT;
+               if (ke.len > sizeof(ke.scancode))
+                       return -EINVAL;
+       }
+       return input_set_keycode(dev, &ke);
+ }
  static long evdev_do_ioctl(struct file *file, unsigned int cmd,
                           void __user *p, int compat_mode)
  {
  
                return 0;
  
-       case EVIOCGKEYCODE:
-               if (get_user(t, ip))
-                       return -EFAULT;
-               error = input_get_keycode(dev, t, &v);
-               if (error)
-                       return error;
-               if (put_user(v, ip + 1))
-                       return -EFAULT;
-               return 0;
-       case EVIOCSKEYCODE:
-               if (get_user(t, ip) || get_user(v, ip + 1))
-                       return -EFAULT;
-               return input_set_keycode(dev, t, v);
        case EVIOCRMFF:
                return input_ff_erase(dev, (int)(unsigned long) p, file);
  
  
        /* Now check variable-length commands */
  #define EVIOC_MASK_SIZE(nr)   ((nr) & ~(_IOC_SIZEMASK << _IOC_SIZESHIFT))
        switch (EVIOC_MASK_SIZE(cmd)) {
  
        case EVIOCGKEY(0):
                        return -EFAULT;
  
                return error;
+       case EVIOC_MASK_SIZE(EVIOCGKEYCODE):
+               return evdev_handle_get_keycode(dev, p, size);
+       case EVIOC_MASK_SIZE(EVIOCSKEYCODE):
+               return evdev_handle_set_keycode(dev, p, size);
        }
  
        /* Multi-number variable-length handlers */
@@@ -767,8 -827,7 +827,8 @@@ static const struct file_operations evd
        .compat_ioctl   = evdev_ioctl_compat,
  #endif
        .fasync         = evdev_fasync,
 -      .flush          = evdev_flush
 +      .flush          = evdev_flush,
 +      .llseek         = no_llseek,
  };
  
  static int evdev_install_chrdev(struct evdev *evdev)
diff --combined drivers/input/input.c
@@@ -171,7 -171,7 +171,7 @@@ static int input_handle_abs_event(struc
        if (code == ABS_MT_SLOT) {
                /*
                 * "Stage" the event; we'll flush it later, when we
-                * get actiual touch data.
+                * get actual touch data.
                 */
                if (*pval >= 0 && *pval < dev->mtsize)
                        dev->slot = *pval;
                pold = &mtslot->abs[code - ABS_MT_FIRST];
        } else {
                /*
-                * Bypass filtering for multitouch events when
+                * Bypass filtering for multi-touch events when
                 * not employing slots.
                 */
                pold = NULL;
@@@ -634,78 -634,141 +634,141 @@@ static void input_disconnect_device(str
        spin_unlock_irq(&dev->event_lock);
  }
  
- static int input_fetch_keycode(struct input_dev *dev, int scancode)
+ /**
+  * input_scancode_to_scalar() - converts scancode in &struct input_keymap_entry
+  * @ke: keymap entry containing scancode to be converted.
+  * @scancode: pointer to the location where converted scancode should
+  *    be stored.
+  *
+  * This function is used to convert scancode stored in &struct keymap_entry
+  * into scalar form understood by legacy keymap handling methods. These
+  * methods expect scancodes to be represented as 'unsigned int'.
+  */
+ int input_scancode_to_scalar(const struct input_keymap_entry *ke,
+                            unsigned int *scancode)
+ {
+       switch (ke->len) {
+       case 1:
+               *scancode = *((u8 *)ke->scancode);
+               break;
+       case 2:
+               *scancode = *((u16 *)ke->scancode);
+               break;
+       case 4:
+               *scancode = *((u32 *)ke->scancode);
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+ }
+ EXPORT_SYMBOL(input_scancode_to_scalar);
+ /*
+  * Those routines handle the default case where no [gs]etkeycode() is
+  * defined. In this case, an array indexed by the scancode is used.
+  */
+ static unsigned int input_fetch_keycode(struct input_dev *dev,
+                                       unsigned int index)
  {
        switch (dev->keycodesize) {
-               case 1:
-                       return ((u8 *)dev->keycode)[scancode];
+       case 1:
+               return ((u8 *)dev->keycode)[index];
  
-               case 2:
-                       return ((u16 *)dev->keycode)[scancode];
+       case 2:
+               return ((u16 *)dev->keycode)[index];
  
-               default:
-                       return ((u32 *)dev->keycode)[scancode];
+       default:
+               return ((u32 *)dev->keycode)[index];
        }
  }
  
  static int input_default_getkeycode(struct input_dev *dev,
-                                   unsigned int scancode,
-                                   unsigned int *keycode)
+                                   struct input_keymap_entry *ke)
  {
+       unsigned int index;
+       int error;
        if (!dev->keycodesize)
                return -EINVAL;
  
-       if (scancode >= dev->keycodemax)
+       if (ke->flags & INPUT_KEYMAP_BY_INDEX)
+               index = ke->index;
+       else {
+               error = input_scancode_to_scalar(ke, &index);
+               if (error)
+                       return error;
+       }
+       if (index >= dev->keycodemax)
                return -EINVAL;
  
-       *keycode = input_fetch_keycode(dev, scancode);
+       ke->keycode = input_fetch_keycode(dev, index);
+       ke->index = index;
+       ke->len = sizeof(index);
+       memcpy(ke->scancode, &index, sizeof(index));
  
        return 0;
  }
  
  static int input_default_setkeycode(struct input_dev *dev,
-                                   unsigned int scancode,
-                                   unsigned int keycode)
+                                   const struct input_keymap_entry *ke,
+                                   unsigned int *old_keycode)
  {
-       int old_keycode;
+       unsigned int index;
+       int error;
        int i;
  
-       if (scancode >= dev->keycodemax)
+       if (!dev->keycodesize)
                return -EINVAL;
  
-       if (!dev->keycodesize)
+       if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+               index = ke->index;
+       } else {
+               error = input_scancode_to_scalar(ke, &index);
+               if (error)
+                       return error;
+       }
+       if (index >= dev->keycodemax)
                return -EINVAL;
  
-       if (dev->keycodesize < sizeof(keycode) && (keycode >> (dev->keycodesize * 8)))
+       if (dev->keycodesize < sizeof(dev->keycode) &&
+                       (ke->keycode >> (dev->keycodesize * 8)))
                return -EINVAL;
  
        switch (dev->keycodesize) {
                case 1: {
                        u8 *k = (u8 *)dev->keycode;
-                       old_keycode = k[scancode];
-                       k[scancode] = keycode;
+                       *old_keycode = k[index];
+                       k[index] = ke->keycode;
                        break;
                }
                case 2: {
                        u16 *k = (u16 *)dev->keycode;
-                       old_keycode = k[scancode];
-                       k[scancode] = keycode;
+                       *old_keycode = k[index];
+                       k[index] = ke->keycode;
                        break;
                }
                default: {
                        u32 *k = (u32 *)dev->keycode;
-                       old_keycode = k[scancode];
-                       k[scancode] = keycode;
+                       *old_keycode = k[index];
+                       k[index] = ke->keycode;
                        break;
                }
        }
  
-       __clear_bit(old_keycode, dev->keybit);
-       __set_bit(keycode, dev->keybit);
+       __clear_bit(*old_keycode, dev->keybit);
+       __set_bit(ke->keycode, dev->keybit);
  
        for (i = 0; i < dev->keycodemax; i++) {
-               if (input_fetch_keycode(dev, i) == old_keycode) {
-                       __set_bit(old_keycode, dev->keybit);
+               if (input_fetch_keycode(dev, i) == *old_keycode) {
+                       __set_bit(*old_keycode, dev->keybit);
                        break; /* Setting the bit twice is useless, so break */
                }
        }
  /**
   * input_get_keycode - retrieve keycode currently mapped to a given scancode
   * @dev: input device which keymap is being queried
-  * @scancode: scancode (or its equivalent for device in question) for which
-  *    keycode is needed
-  * @keycode: result
+  * @ke: keymap entry
   *
   * This function should be called by anyone interested in retrieving current
-  * keymap. Presently keyboard and evdev handlers use it.
+  * keymap. Presently evdev handlers use it.
   */
- int input_get_keycode(struct input_dev *dev,
-                     unsigned int scancode, unsigned int *keycode)
+ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke)
  {
        unsigned long flags;
        int retval;
  
        spin_lock_irqsave(&dev->event_lock, flags);
-       retval = dev->getkeycode(dev, scancode, keycode);
-       spin_unlock_irqrestore(&dev->event_lock, flags);
  
+       if (dev->getkeycode) {
+               /*
+                * Support for legacy drivers, that don't implement the new
+                * ioctls
+                */
+               u32 scancode = ke->index;
+               memcpy(ke->scancode, &scancode, sizeof(scancode));
+               ke->len = sizeof(scancode);
+               retval = dev->getkeycode(dev, scancode, &ke->keycode);
+       } else {
+               retval = dev->getkeycode_new(dev, ke);
+       }
+       spin_unlock_irqrestore(&dev->event_lock, flags);
        return retval;
  }
  EXPORT_SYMBOL(input_get_keycode);
  
  /**
-  * input_get_keycode - assign new keycode to a given scancode
+  * input_set_keycode - attribute a keycode to a given scancode
   * @dev: input device which keymap is being updated
-  * @scancode: scancode (or its equivalent for device in question)
-  * @keycode: new keycode to be assigned to the scancode
+  * @ke: new keymap entry
   *
   * This function should be called by anyone needing to update current
   * keymap. Presently keyboard and evdev handlers use it.
   */
  int input_set_keycode(struct input_dev *dev,
-                     unsigned int scancode, unsigned int keycode)
+                     const struct input_keymap_entry *ke)
  {
        unsigned long flags;
        unsigned int old_keycode;
        int retval;
  
-       if (keycode > KEY_MAX)
+       if (ke->keycode > KEY_MAX)
                return -EINVAL;
  
        spin_lock_irqsave(&dev->event_lock, flags);
  
-       retval = dev->getkeycode(dev, scancode, &old_keycode);
-       if (retval)
-               goto out;
+       if (dev->setkeycode) {
+               /*
+                * Support for legacy drivers, that don't implement the new
+                * ioctls
+                */
+               unsigned int scancode;
+               retval = input_scancode_to_scalar(ke, &scancode);
+               if (retval)
+                       goto out;
+               /*
+                * We need to know the old scancode, in order to generate a
+                * keyup effect, if the set operation happens successfully
+                */
+               if (!dev->getkeycode) {
+                       retval = -EINVAL;
+                       goto out;
+               }
+               retval = dev->getkeycode(dev, scancode, &old_keycode);
+               if (retval)
+                       goto out;
+               retval = dev->setkeycode(dev, scancode, ke->keycode);
+       } else {
+               retval = dev->setkeycode_new(dev, ke, &old_keycode);
+       }
  
-       retval = dev->setkeycode(dev, scancode, keycode);
        if (retval)
                goto out;
  
@@@ -1601,7 -1697,7 +1697,7 @@@ EXPORT_SYMBOL(input_free_device)
   *
   * This function allocates all necessary memory for MT slot handling in the
   * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
-  * are initially marked as unused iby setting ABS_MT_TRACKING_ID to -1.
+  * are initially marked as unused by setting ABS_MT_TRACKING_ID to -1.
   */
  int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
  {
@@@ -1759,11 -1855,11 +1855,11 @@@ int input_register_device(struct input_
                dev->rep[REP_PERIOD] = 33;
        }
  
-       if (!dev->getkeycode)
-               dev->getkeycode = input_default_getkeycode;
+       if (!dev->getkeycode && !dev->getkeycode_new)
+               dev->getkeycode_new = input_default_getkeycode;
  
-       if (!dev->setkeycode)
-               dev->setkeycode = input_default_setkeycode;
+       if (!dev->setkeycode && !dev->setkeycode_new)
+               dev->setkeycode_new = input_default_setkeycode;
  
        dev_set_name(&dev->dev, "input%ld",
                     (unsigned long) atomic_inc_return(&input_no) - 1);
@@@ -2047,7 -2143,6 +2143,7 @@@ out
  static const struct file_operations input_fops = {
        .owner = THIS_MODULE,
        .open = input_open_file,
 +      .llseek = noop_llseek,
  };
  
  static int __init input_init(void)
@@@ -327,6 -327,16 +327,16 @@@ config KEYBOARD_NEWTO
          To compile this driver as a module, choose M here: the
          module will be called newtonkbd.
  
+ config KEYBOARD_NOMADIK
+       tristate "ST-Ericsson Nomadik SKE keyboard"
+       depends on PLAT_NOMADIK
+       help
+         Say Y here if you want to use a keypad provided on the SKE controller
+         used on the Ux500 and Nomadik platforms
+         To compile this driver as a module, choose M here: the
+         module will be called nmk-ske-keypad.
  config KEYBOARD_OPENCORES
        tristate "OpenCores Keyboard Controller"
        help
  
  config KEYBOARD_PXA27x
        tristate "PXA27x/PXA3xx keypad support"
 -      depends on PXA27x || PXA3xx
 +      depends on PXA27x || PXA3xx || ARCH_MMP
        help
          Enable support for PXA27x/PXA3xx keypad controller.
  
@@@ -424,6 -434,15 +434,15 @@@ config KEYBOARD_OMA
          To compile this driver as a module, choose M here: the
          module will be called omap-keypad.
  
+ config KEYBOARD_OMAP4
+       tristate "TI OMAP4 keypad support"
+       depends on ARCH_OMAP4
+       help
+         Say Y here if you want to use the OMAP4 keypad.
+         To compile this driver as a module, choose M here: the
+         module will be called omap4-keypad.
  config KEYBOARD_TWL4030
        tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
        depends on TWL4030_CORE
diff --combined drivers/input/mousedev.c
@@@ -792,7 -792,6 +792,7 @@@ static const struct file_operations mou
        .open =         mousedev_open,
        .release =      mousedev_release,
        .fasync =       mousedev_fasync,
 +      .llseek = noop_llseek,
  };
  
  static int mousedev_install_chrdev(struct mousedev *mousedev)
@@@ -867,7 -866,7 +867,7 @@@ static struct mousedev *mousedev_create
        spin_lock_init(&mousedev->client_lock);
        mutex_init(&mousedev->mutex);
        lockdep_set_subclass(&mousedev->mutex,
-                            minor == MOUSEDEV_MIX ? MOUSEDEV_MIX : 0);
+                            minor == MOUSEDEV_MIX ? SINGLE_DEPTH_NESTING : 0);
        init_waitqueue_head(&mousedev->wait);
  
        if (minor == MOUSEDEV_MIX)
  /* FIXME: IR_KEYPRESS_TIMEOUT should be protocol specific */
  #define IR_KEYPRESS_TIMEOUT 250
  
+ /**
+  * ir_create_table() - initializes a scancode table
+  * @rc_tab:   the ir_scancode_table to initialize
+  * @name:     name to assign to the table
+  * @ir_type:  ir type to assign to the new table
+  * @size:     initial size of the table
+  * @return:   zero on success or a negative error code
+  *
+  * This routine will initialize the ir_scancode_table and will allocate
+  * memory to hold at least the specified number elements.
+  */
+ static int ir_create_table(struct ir_scancode_table *rc_tab,
+                          const char *name, u64 ir_type, size_t size)
+ {
+       rc_tab->name = name;
+       rc_tab->ir_type = ir_type;
+       rc_tab->alloc = roundup_pow_of_two(size * sizeof(struct ir_scancode));
+       rc_tab->size = rc_tab->alloc / sizeof(struct ir_scancode);
+       rc_tab->scan = kmalloc(rc_tab->alloc, GFP_KERNEL);
+       if (!rc_tab->scan)
+               return -ENOMEM;
+       IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
+                  rc_tab->size, rc_tab->alloc);
+       return 0;
+ }
+ /**
+  * ir_free_table() - frees memory allocated by a scancode table
+  * @rc_tab:   the table whose mappings need to be freed
+  *
+  * This routine will free memory alloctaed for key mappings used by given
+  * scancode table.
+  */
+ static void ir_free_table(struct ir_scancode_table *rc_tab)
+ {
+       rc_tab->size = 0;
+       kfree(rc_tab->scan);
+       rc_tab->scan = NULL;
+ }
  /**
   * ir_resize_table() - resizes a scancode table if necessary
   * @rc_tab:   the ir_scancode_table to resize
+  * @gfp_flags:        gfp flags to use when allocating memory
   * @return:   zero on success or a negative error code
   *
   * This routine will shrink the ir_scancode_table if it has lots of
   * unused entries and grow it if it is full.
   */
- static int ir_resize_table(struct ir_scancode_table *rc_tab)
+ static int ir_resize_table(struct ir_scancode_table *rc_tab, gfp_t gfp_flags)
  {
        unsigned int oldalloc = rc_tab->alloc;
        unsigned int newalloc = oldalloc;
@@@ -57,7 -99,7 +99,7 @@@
        if (newalloc == oldalloc)
                return 0;
  
-       newscan = kmalloc(newalloc, GFP_ATOMIC);
+       newscan = kmalloc(newalloc, gfp_flags);
        if (!newscan) {
                IR_dprintk(1, "Failed to kmalloc %u bytes\n", newalloc);
                return -ENOMEM;
  }
  
  /**
-  * ir_do_setkeycode() - internal function to set a keycode in the
-  *                    scancode->keycode table
+  * ir_update_mapping() - set a keycode in the scancode->keycode table
   * @dev:      the struct input_dev device descriptor
-  * @rc_tab:   the struct ir_scancode_table to set the keycode in
-  * @scancode: the scancode for the ir command
-  * @keycode:  the keycode for the ir command
-  * @resize:   whether the keytable may be shrunk
-  * @return:   -EINVAL if the keycode could not be inserted, otherwise zero.
+  * @rc_tab:   scancode table to be adjusted
+  * @index:    index of the mapping that needs to be updated
+  * @keycode:  the desired keycode
+  * @return:   previous keycode assigned to the mapping
+  *
+  * This routine is used to update scancode->keycopde mapping at given
+  * position.
+  */
+ static unsigned int ir_update_mapping(struct input_dev *dev,
+                                     struct ir_scancode_table *rc_tab,
+                                     unsigned int index,
+                                     unsigned int new_keycode)
+ {
+       int old_keycode = rc_tab->scan[index].keycode;
+       int i;
+       /* Did the user wish to remove the mapping? */
+       if (new_keycode == KEY_RESERVED || new_keycode == KEY_UNKNOWN) {
+               IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",
+                          index, rc_tab->scan[index].scancode);
+               rc_tab->len--;
+               memmove(&rc_tab->scan[index], &rc_tab->scan[index+ 1],
+                       (rc_tab->len - index) * sizeof(struct ir_scancode));
+       } else {
+               IR_dprintk(1, "#%d: %s scan 0x%04x with key 0x%04x\n",
+                          index,
+                          old_keycode == KEY_RESERVED ? "New" : "Replacing",
+                          rc_tab->scan[index].scancode, new_keycode);
+               rc_tab->scan[index].keycode = new_keycode;
+               __set_bit(new_keycode, dev->keybit);
+       }
+       if (old_keycode != KEY_RESERVED) {
+               /* A previous mapping was updated... */
+               __clear_bit(old_keycode, dev->keybit);
+               /* ... but another scancode might use the same keycode */
+               for (i = 0; i < rc_tab->len; i++) {
+                       if (rc_tab->scan[i].keycode == old_keycode) {
+                               __set_bit(old_keycode, dev->keybit);
+                               break;
+                       }
+               }
+               /* Possibly shrink the keytable, failure is not a problem */
+               ir_resize_table(rc_tab, GFP_ATOMIC);
+       }
+       return old_keycode;
+ }
+ /**
+  * ir_locate_scancode() - set a keycode in the scancode->keycode table
+  * @ir_dev:   the struct ir_input_dev device descriptor
+  * @rc_tab:   scancode table to be searched
+  * @scancode: the desired scancode
+  * @resize:   controls whether we allowed to resize the table to
+  *            accomodate not yet present scancodes
+  * @return:   index of the mapping containing scancode in question
+  *            or -1U in case of failure.
   *
-  * This routine is used internally to manipulate the scancode->keycode table.
-  * The caller has to hold @rc_tab->lock.
+  * This routine is used to locate given scancode in ir_scancode_table.
+  * If scancode is not yet present the routine will allocate a new slot
+  * for it.
   */
- static int ir_do_setkeycode(struct input_dev *dev,
-                           struct ir_scancode_table *rc_tab,
-                           unsigned scancode, unsigned keycode,
-                           bool resize)
+ static unsigned int ir_establish_scancode(struct ir_input_dev *ir_dev,
+                                         struct ir_scancode_table *rc_tab,
+                                         unsigned int scancode,
+                                         bool resize)
  {
        unsigned int i;
-       int old_keycode = KEY_RESERVED;
-       struct ir_input_dev *ir_dev = input_get_drvdata(dev);
  
        /*
         * Unfortunately, some hardware-based IR decoders don't provide
         * the provided IR with another one, it is needed to allow loading
         * IR tables from other remotes. So,
         */
-       if (ir_dev->props && ir_dev->props->scanmask) {
+       if (ir_dev->props && ir_dev->props->scanmask)
                scancode &= ir_dev->props->scanmask;
-       }
  
        /* First check if we already have a mapping for this ir command */
        for (i = 0; i < rc_tab->len; i++) {
+               if (rc_tab->scan[i].scancode == scancode)
+                       return i;
                /* Keytable is sorted from lowest to highest scancode */
-               if (rc_tab->scan[i].scancode > scancode)
+               if (rc_tab->scan[i].scancode >= scancode)
                        break;
-               else if (rc_tab->scan[i].scancode < scancode)
-                       continue;
-               old_keycode = rc_tab->scan[i].keycode;
-               rc_tab->scan[i].keycode = keycode;
-               /* Did the user wish to remove the mapping? */
-               if (keycode == KEY_RESERVED || keycode == KEY_UNKNOWN) {
-                       IR_dprintk(1, "#%d: Deleting scan 0x%04x\n",
-                                  i, scancode);
-                       rc_tab->len--;
-                       memmove(&rc_tab->scan[i], &rc_tab->scan[i + 1],
-                               (rc_tab->len - i) * sizeof(struct ir_scancode));
-               }
-               /* Possibly shrink the keytable, failure is not a problem */
-               ir_resize_table(rc_tab);
-               break;
        }
  
-       if (old_keycode == KEY_RESERVED && keycode != KEY_RESERVED) {
-               /* No previous mapping found, we might need to grow the table */
-               if (resize && ir_resize_table(rc_tab))
-                       return -ENOMEM;
-               IR_dprintk(1, "#%d: New scan 0x%04x with key 0x%04x\n",
-                          i, scancode, keycode);
+       /* No previous mapping found, we might need to grow the table */
+       if (rc_tab->size == rc_tab->len) {
+               if (!resize || ir_resize_table(rc_tab, GFP_ATOMIC))
+                       return -1U;
+       }
  
-               /* i is the proper index to insert our new keycode */
+       /* i is the proper index to insert our new keycode */
+       if (i < rc_tab->len)
                memmove(&rc_tab->scan[i + 1], &rc_tab->scan[i],
                        (rc_tab->len - i) * sizeof(struct ir_scancode));
-               rc_tab->scan[i].scancode = scancode;
-               rc_tab->scan[i].keycode = keycode;
-               rc_tab->len++;
-               set_bit(keycode, dev->keybit);
-       } else {
-               IR_dprintk(1, "#%d: Replacing scan 0x%04x with key 0x%04x\n",
-                          i, scancode, keycode);
-               /* A previous mapping was updated... */
-               clear_bit(old_keycode, dev->keybit);
-               /* ...but another scancode might use the same keycode */
-               for (i = 0; i < rc_tab->len; i++) {
-                       if (rc_tab->scan[i].keycode == old_keycode) {
-                               set_bit(old_keycode, dev->keybit);
-                               break;
-                       }
-               }
-       }
+       rc_tab->scan[i].scancode = scancode;
+       rc_tab->scan[i].keycode = KEY_RESERVED;
+       rc_tab->len++;
  
-       return 0;
+       return i;
  }
  
  /**
   * This routine is used to handle evdev EVIOCSKEY ioctl.
   */
  static int ir_setkeycode(struct input_dev *dev,
-                        unsigned int scancode, unsigned int keycode)
+                        const struct input_keymap_entry *ke,
+                        unsigned int *old_keycode)
  {
-       int rc;
-       unsigned long flags;
        struct ir_input_dev *ir_dev = input_get_drvdata(dev);
        struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
+       unsigned int index;
+       unsigned int scancode;
+       int retval;
+       unsigned long flags;
  
        spin_lock_irqsave(&rc_tab->lock, flags);
-       rc = ir_do_setkeycode(dev, rc_tab, scancode, keycode, true);
+       if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+               index = ke->index;
+               if (index >= rc_tab->len) {
+                       retval = -EINVAL;
+                       goto out;
+               }
+       } else {
+               retval = input_scancode_to_scalar(ke, &scancode);
+               if (retval)
+                       goto out;
+               index = ir_establish_scancode(ir_dev, rc_tab, scancode, true);
+               if (index >= rc_tab->len) {
+                       retval = -ENOMEM;
+                       goto out;
+               }
+       }
+       *old_keycode = ir_update_mapping(dev, rc_tab, index, ke->keycode);
+ out:
        spin_unlock_irqrestore(&rc_tab->lock, flags);
-       return rc;
+       return retval;
  }
  
  /**
   * @dev:      the struct input_dev device descriptor
   * @to:               the struct ir_scancode_table to copy entries to
   * @from:     the struct ir_scancode_table to copy entries from
-  * @return:   -EINVAL if all keycodes could not be inserted, otherwise zero.
+  * @return:   -ENOMEM if all keycodes could not be inserted, otherwise zero.
   *
   * This routine is used to handle table initialization.
   */
- static int ir_setkeytable(struct input_dev *dev,
-                         struct ir_scancode_table *to,
+ static int ir_setkeytable(struct ir_input_dev *ir_dev,
                          const struct ir_scancode_table *from)
  {
-       struct ir_input_dev *ir_dev = input_get_drvdata(dev);
        struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
-       unsigned long flags;
-       unsigned int i;
-       int rc = 0;
+       unsigned int i, index;
+       int rc;
+       rc = ir_create_table(&ir_dev->rc_tab,
+                            from->name, from->ir_type, from->size);
+       if (rc)
+               return rc;
+       IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
+                  rc_tab->size, rc_tab->alloc);
  
-       spin_lock_irqsave(&rc_tab->lock, flags);
        for (i = 0; i < from->size; i++) {
-               rc = ir_do_setkeycode(dev, to, from->scan[i].scancode,
-                                     from->scan[i].keycode, false);
-               if (rc)
+               index = ir_establish_scancode(ir_dev, rc_tab,
+                                             from->scan[i].scancode, false);
+               if (index >= rc_tab->len) {
+                       rc = -ENOMEM;
                        break;
+               }
+               ir_update_mapping(ir_dev->input_dev, rc_tab, index,
+                                 from->scan[i].keycode);
        }
-       spin_unlock_irqrestore(&rc_tab->lock, flags);
+       if (rc)
+               ir_free_table(rc_tab);
        return rc;
  }
  
+ /**
+  * ir_lookup_by_scancode() - locate mapping by scancode
+  * @rc_tab:   the &struct ir_scancode_table to search
+  * @scancode: scancode to look for in the table
+  * @return:   index in the table, -1U if not found
+  *
+  * This routine performs binary search in RC keykeymap table for
+  * given scancode.
+  */
+ static unsigned int ir_lookup_by_scancode(const struct ir_scancode_table *rc_tab,
+                                         unsigned int scancode)
+ {
+       unsigned int start = 0;
+       unsigned int end = rc_tab->len - 1;
+       unsigned int mid;
+       while (start <= end) {
+               mid = (start + end) / 2;
+               if (rc_tab->scan[mid].scancode < scancode)
+                       start = mid + 1;
+               else if (rc_tab->scan[mid].scancode > scancode)
+                       end = mid - 1;
+               else
+                       return mid;
+       }
+       return -1U;
+ }
  /**
   * ir_getkeycode() - get a keycode from the scancode->keycode table
   * @dev:      the struct input_dev device descriptor
   * This routine is used to handle evdev EVIOCGKEY ioctl.
   */
  static int ir_getkeycode(struct input_dev *dev,
-                        unsigned int scancode, unsigned int *keycode)
+                        struct input_keymap_entry *ke)
  {
-       int start, end, mid;
-       unsigned long flags;
-       int key = KEY_RESERVED;
        struct ir_input_dev *ir_dev = input_get_drvdata(dev);
        struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
+       struct ir_scancode *entry;
+       unsigned long flags;
+       unsigned int index;
+       unsigned int scancode;
+       int retval;
  
        spin_lock_irqsave(&rc_tab->lock, flags);
-       start = 0;
-       end = rc_tab->len - 1;
-       while (start <= end) {
-               mid = (start + end) / 2;
-               if (rc_tab->scan[mid].scancode < scancode)
-                       start = mid + 1;
-               else if (rc_tab->scan[mid].scancode > scancode)
-                       end = mid - 1;
-               else {
-                       key = rc_tab->scan[mid].keycode;
-                       break;
-               }
+       if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
+               index = ke->index;
+       } else {
+               retval = input_scancode_to_scalar(ke, &scancode);
+               if (retval)
+                       goto out;
+               index = ir_lookup_by_scancode(rc_tab, scancode);
+       }
+       if (index >= rc_tab->len) {
+               if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))
+                       IR_dprintk(1, "unknown key for scancode 0x%04x\n",
+                                  scancode);
+               retval = -EINVAL;
+               goto out;
        }
-       spin_unlock_irqrestore(&rc_tab->lock, flags);
  
-       if (key == KEY_RESERVED)
-               IR_dprintk(1, "unknown key for scancode 0x%04x\n",
-                          scancode);
+       entry = &rc_tab->scan[index];
  
-       *keycode = key;
-       return 0;
+       ke->index = index;
+       ke->keycode = entry->keycode;
+       ke->len = sizeof(entry->scancode);
+       memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));
+ out:
+       spin_unlock_irqrestore(&rc_tab->lock, flags);
+       return retval;
  }
  
  /**
   */
  u32 ir_g_keycode_from_table(struct input_dev *dev, u32 scancode)
  {
-       int keycode;
+       struct ir_input_dev *ir_dev = input_get_drvdata(dev);
+       struct ir_scancode_table *rc_tab = &ir_dev->rc_tab;
+       unsigned int keycode;
+       unsigned int index;
+       unsigned long flags;
+       spin_lock_irqsave(&rc_tab->lock, flags);
+       index = ir_lookup_by_scancode(rc_tab, scancode);
+       keycode = index < rc_tab->len ?
+                       rc_tab->scan[index].keycode : KEY_RESERVED;
+       spin_unlock_irqrestore(&rc_tab->lock, flags);
  
-       ir_getkeycode(dev, scancode, &keycode);
        if (keycode != KEY_RESERVED)
                IR_dprintk(1, "%s: scancode 0x%04x keycode 0x%02x\n",
                           dev->name, scancode, keycode);
        return keycode;
  }
  EXPORT_SYMBOL_GPL(ir_g_keycode_from_table);
@@@ -319,7 -469,7 +469,7 @@@ static void ir_timer_keyup(unsigned lon
         * a keyup event might follow immediately after the keydown.
         */
        spin_lock_irqsave(&ir->keylock, flags);
 -      if (time_is_after_eq_jiffies(ir->keyup_jiffies))
 +      if (time_is_before_eq_jiffies(ir->keyup_jiffies))
                ir_keyup(ir);
        spin_unlock_irqrestore(&ir->keylock, flags);
  }
@@@ -453,8 -603,8 +603,8 @@@ int __ir_input_register(struct input_de
                goto out_dev;
        }
  
-       input_dev->getkeycode = ir_getkeycode;
-       input_dev->setkeycode = ir_setkeycode;
+       input_dev->getkeycode_new = ir_getkeycode;
+       input_dev->setkeycode_new = ir_setkeycode;
        input_set_drvdata(input_dev, ir_dev);
        ir_dev->input_dev = input_dev;
  
        spin_lock_init(&ir_dev->keylock);
        setup_timer(&ir_dev->timer_keyup, ir_timer_keyup, (unsigned long)ir_dev);
  
-       ir_dev->rc_tab.name = rc_tab->name;
-       ir_dev->rc_tab.ir_type = rc_tab->ir_type;
-       ir_dev->rc_tab.alloc = roundup_pow_of_two(rc_tab->size *
-                                                 sizeof(struct ir_scancode));
-       ir_dev->rc_tab.scan = kmalloc(ir_dev->rc_tab.alloc, GFP_KERNEL);
-       ir_dev->rc_tab.size = ir_dev->rc_tab.alloc / sizeof(struct ir_scancode);
        if (props) {
                ir_dev->props = props;
                if (props->open)
                        input_dev->close = ir_close;
        }
  
-       if (!ir_dev->rc_tab.scan) {
-               rc = -ENOMEM;
-               goto out_name;
-       }
-       IR_dprintk(1, "Allocated space for %u keycode entries (%u bytes)\n",
-                  ir_dev->rc_tab.size, ir_dev->rc_tab.alloc);
        set_bit(EV_KEY, input_dev->evbit);
        set_bit(EV_REP, input_dev->evbit);
        set_bit(EV_MSC, input_dev->evbit);
        set_bit(MSC_SCAN, input_dev->mscbit);
  
-       if (ir_setkeytable(input_dev, &ir_dev->rc_tab, rc_tab)) {
-               rc = -ENOMEM;
-               goto out_table;
-       }
+       rc = ir_setkeytable(ir_dev, rc_tab);
+       if (rc)
+               goto out_name;
  
        rc = ir_register_class(input_dev);
        if (rc < 0)
                   (ir_dev->props && ir_dev->props->driver_type == RC_DRIVER_IR_RAW) ?
                        " in raw mode" : "");
  
 +      /*
 +       * Default delay of 250ms is too short for some protocols, expecially
 +       * since the timeout is currently set to 250ms. Increase it to 500ms,
 +       * to avoid wrong repetition of the keycodes.
 +       */
 +      input_dev->rep[REP_DELAY] = 500;
 +
        return 0;
  
  out_event:
        ir_unregister_class(input_dev);
  out_table:
-       kfree(ir_dev->rc_tab.scan);
+       ir_free_table(&ir_dev->rc_tab);
  out_name:
        kfree(ir_dev->driver_name);
  out_dev:
@@@ -540,7 -668,6 +675,6 @@@ EXPORT_SYMBOL_GPL(__ir_input_register)
  void ir_input_unregister(struct input_dev *input_dev)
  {
        struct ir_input_dev *ir_dev = input_get_drvdata(input_dev);
-       struct ir_scancode_table *rc_tab;
  
        if (!ir_dev)
                return;
                if (ir_dev->props->driver_type == RC_DRIVER_IR_RAW)
                        ir_raw_event_unregister(input_dev);
  
-       rc_tab = &ir_dev->rc_tab;
-       rc_tab->size = 0;
-       kfree(rc_tab->scan);
-       rc_tab->scan = NULL;
+       ir_free_table(&ir_dev->rc_tab);
  
        ir_unregister_class(input_dev);
  
diff --combined drivers/staging/Kconfig
@@@ -113,6 -113,8 +113,6 @@@ source "drivers/staging/vme/Kconfig
  
  source "drivers/staging/memrar/Kconfig"
  
 -source "drivers/staging/sep/Kconfig"
 -
  source "drivers/staging/iio/Kconfig"
  
  source "drivers/staging/zram/Kconfig"
@@@ -139,8 -141,6 +139,6 @@@ source "drivers/staging/adis16255/Kconf
  
  source "drivers/staging/xgifb/Kconfig"
  
- source "drivers/staging/mrst-touchscreen/Kconfig"
  source "drivers/staging/msm/Kconfig"
  
  source "drivers/staging/lirc/Kconfig"
diff --combined drivers/staging/Makefile
@@@ -38,6 -38,7 +38,6 @@@ obj-$(CONFIG_FB_UDL)          += udlfb
  obj-$(CONFIG_HYPERV)          += hv/
  obj-$(CONFIG_VME_BUS)         += vme/
  obj-$(CONFIG_MRST_RAR_HANDLER)        += memrar/
 -obj-$(CONFIG_DX_SEP)          += sep/
  obj-$(CONFIG_IIO)             += iio/
  obj-$(CONFIG_ZRAM)            += zram/
  obj-$(CONFIG_WLAGS49_H2)      += wlags49_h2/
@@@ -51,7 -52,6 +51,6 @@@ obj-$(CONFIG_CXT1E1)          += cxt1e1
  obj-$(CONFIG_TI_ST)           += ti-st/
  obj-$(CONFIG_ADIS16255)               += adis16255/
  obj-$(CONFIG_FB_XGI)          += xgifb/
- obj-$(CONFIG_TOUCHSCREEN_MRSTOUCH)    += mrst-touchscreen/
  obj-$(CONFIG_MSM_STAGING)     += msm/
  obj-$(CONFIG_EASYCAP)         += easycap/
  obj-$(CONFIG_SOLO6X10)                += solo6x10/
diff --combined include/linux/input.h
@@@ -34,7 -34,7 +34,7 @@@ struct input_event 
   * Protocol version.
   */
  
- #define EV_VERSION            0x010000
+ #define EV_VERSION            0x010001
  
  /*
   * IOCTLs (0x00 - 0x7f)
@@@ -56,25 -56,50 +56,50 @@@ struct input_absinfo 
        __s32 resolution;
  };
  
+ /**
+  * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
+  * @scancode: scancode represented in machine-endian form.
+  * @len: length of the scancode that resides in @scancode buffer.
+  * @index: index in the keymap, may be used instead of scancode
+  * @flags: allows to specify how kernel should handle the request. For
+  *    example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
+  *    should perform lookup in keymap by @index instead of @scancode
+  * @keycode: key code assigned to this scancode
+  *
+  * The structure is used to retrieve and modify keymap data. Users have
+  * option of performing lookup either by @scancode itself or by @index
+  * in keymap entry. EVIOCGKEYCODE will also return scancode or index
+  * (depending on which element was used to perform lookup).
+  */
+ struct input_keymap_entry {
+ #define INPUT_KEYMAP_BY_INDEX (1 << 0)
+       __u8  flags;
+       __u8  len;
+       __u16 index;
+       __u32 keycode;
+       __u8  scancode[32];
+ };
  #define EVIOCGVERSION         _IOR('E', 0x01, int)                    /* get driver version */
  #define EVIOCGID              _IOR('E', 0x02, struct input_id)        /* get device ID */
  #define EVIOCGREP             _IOR('E', 0x03, unsigned int[2])        /* get repeat settings */
  #define EVIOCSREP             _IOW('E', 0x03, unsigned int[2])        /* set repeat settings */
- #define EVIOCGKEYCODE         _IOR('E', 0x04, unsigned int[2])        /* get keycode */
- #define EVIOCSKEYCODE         _IOW('E', 0x04, unsigned int[2])        /* set keycode */
+ #define EVIOCGKEYCODE         _IOR('E', 0x04, struct input_keymap_entry)      /* get keycode */
+ #define EVIOCSKEYCODE         _IOW('E', 0x04, struct input_keymap_entry)      /* set keycode */
  
  #define EVIOCGNAME(len)               _IOC(_IOC_READ, 'E', 0x06, len)         /* get device name */
  #define EVIOCGPHYS(len)               _IOC(_IOC_READ, 'E', 0x07, len)         /* get physical location */
  #define EVIOCGUNIQ(len)               _IOC(_IOC_READ, 'E', 0x08, len)         /* get unique identifier */
  
- #define EVIOCGKEY(len)                _IOC(_IOC_READ, 'E', 0x18, len)         /* get global keystate */
+ #define EVIOCGKEY(len)                _IOC(_IOC_READ, 'E', 0x18, len)         /* get global key state */
  #define EVIOCGLED(len)                _IOC(_IOC_READ, 'E', 0x19, len)         /* get all LEDs */
  #define EVIOCGSND(len)                _IOC(_IOC_READ, 'E', 0x1a, len)         /* get all sounds status */
  #define EVIOCGSW(len)         _IOC(_IOC_READ, 'E', 0x1b, len)         /* get all switch states */
  
  #define EVIOCGBIT(ev,len)     _IOC(_IOC_READ, 'E', 0x20 + ev, len)    /* get event bits */
- #define EVIOCGABS(abs)                _IOR('E', 0x40 + abs, struct input_absinfo)             /* get abs value/limits */
- #define EVIOCSABS(abs)                _IOW('E', 0xc0 + abs, struct input_absinfo)             /* set abs value/limits */
+ #define EVIOCGABS(abs)                _IOR('E', 0x40 + abs, struct input_absinfo)     /* get abs value/limits */
+ #define EVIOCSABS(abs)                _IOW('E', 0xc0 + abs, struct input_absinfo)     /* set abs value/limits */
  
  #define EVIOCSFF              _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect))   /* send a force effect to a force feedback device */
  #define EVIOCRMFF             _IOW('E', 0x81, int)                    /* Erase a force effect */
@@@ -1088,13 -1113,13 +1113,13 @@@ struct input_mt_slot 
   * @keycodemax: size of keycode table
   * @keycodesize: size of elements in keycode table
   * @keycode: map of scancodes to keycodes for this device
+  * @getkeycode: optional legacy method to retrieve current keymap.
   * @setkeycode: optional method to alter current keymap, used to implement
   *    sparse keymaps. If not supplied default mechanism will be used.
   *    The method is being called while holding event_lock and thus must
   *    not sleep
-  * @getkeycode: optional method to retrieve current keymap. If not supplied
-  *    default mechanism will be used. The method is being called while
-  *    holding event_lock and thus must not sleep
+  * @getkeycode_new: transition method
+  * @setkeycode_new: transition method
   * @ff: force feedback structure associated with the device if device
   *    supports force feedback effects
   * @repeat_key: stores key code of the last key pressed; used to implement
@@@ -1168,10 -1193,16 +1193,16 @@@ struct input_dev 
        unsigned int keycodemax;
        unsigned int keycodesize;
        void *keycode;
        int (*setkeycode)(struct input_dev *dev,
                          unsigned int scancode, unsigned int keycode);
        int (*getkeycode)(struct input_dev *dev,
                          unsigned int scancode, unsigned int *keycode);
+       int (*setkeycode_new)(struct input_dev *dev,
+                             const struct input_keymap_entry *ke,
+                             unsigned int *old_keycode);
+       int (*getkeycode_new)(struct input_dev *dev,
+                             struct input_keymap_entry *ke);
  
        struct ff_device *ff;
  
        int (*flush)(struct input_dev *dev, struct file *file);
        int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
  
 -      struct input_handle *grab;
 +      struct input_handle __rcu *grab;
  
        spinlock_t event_lock;
        struct mutex mutex;
@@@ -1478,10 -1509,12 +1509,12 @@@ INPUT_GENERATE_ABS_ACCESSORS(fuzz, fuzz
  INPUT_GENERATE_ABS_ACCESSORS(flat, flat)
  INPUT_GENERATE_ABS_ACCESSORS(res, resolution)
  
- int input_get_keycode(struct input_dev *dev,
-                     unsigned int scancode, unsigned int *keycode);
+ int input_scancode_to_scalar(const struct input_keymap_entry *ke,
+                            unsigned int *scancode);
+ int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);
  int input_set_keycode(struct input_dev *dev,
-                     unsigned int scancode, unsigned int keycode);
+                     const struct input_keymap_entry *ke);
  
  extern struct class input_class;