Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/dtor/input

Pull input fixes from Dmitry Torokhov:
 "A few more fixes for the input subsystem:

   - restore naming for tsc2005 touchscreens as some userspace match on it
   - fix out of bound access in legacy keyboard driver
   - fixup in RMI4 driver

  Everything is tagged for stable as well"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: tsc200x - report proper input_dev name
  tty/vt/keyboard: fix OOB access in do_compute_shiftstate()
  Input: synaptics-rmi4 - fix maximum size check for F12 control register 8
  • Loading branch information
Linus Torvalds committed Jul 23, 2016
2 parents f1894d8 + e9003c9 commit 3aa536d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 31 deletions.
9 changes: 5 additions & 4 deletions drivers/input/rmi4/rmi_f12.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)
struct rmi_device *rmi_dev = fn->rmi_dev;
int ret;
int offset;
u8 buf[14];
u8 buf[15];
int pitch_x = 0;
int pitch_y = 0;
int clip_x_low = 0;
Expand All @@ -86,9 +86,10 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)

offset = rmi_register_desc_calc_reg_offset(&f12->control_reg_desc, 8);

if (item->reg_size > 14) {
dev_err(&fn->dev, "F12 control8 should be 14 bytes, not: %ld\n",
item->reg_size);
if (item->reg_size > sizeof(buf)) {
dev_err(&fn->dev,
"F12 control8 should be no bigger than %zd bytes, not: %ld\n",
sizeof(buf), item->reg_size);
return -ENODEV;
}

Expand Down
7 changes: 6 additions & 1 deletion drivers/input/touchscreen/tsc2004.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#include <linux/regmap.h>
#include "tsc200x-core.h"

static const struct input_id tsc2004_input_id = {
.bustype = BUS_I2C,
.product = 2004,
};

static int tsc2004_cmd(struct device *dev, u8 cmd)
{
u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
Expand All @@ -42,7 +47,7 @@ static int tsc2004_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)

{
return tsc200x_probe(&i2c->dev, i2c->irq, BUS_I2C,
return tsc200x_probe(&i2c->dev, i2c->irq, &tsc2004_input_id,
devm_regmap_init_i2c(i2c, &tsc200x_regmap_config),
tsc2004_cmd);
}
Expand Down
7 changes: 6 additions & 1 deletion drivers/input/touchscreen/tsc2005.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include <linux/regmap.h>
#include "tsc200x-core.h"

static const struct input_id tsc2005_input_id = {
.bustype = BUS_SPI,
.product = 2005,
};

static int tsc2005_cmd(struct device *dev, u8 cmd)
{
u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
Expand Down Expand Up @@ -62,7 +67,7 @@ static int tsc2005_probe(struct spi_device *spi)
if (error)
return error;

return tsc200x_probe(&spi->dev, spi->irq, BUS_SPI,
return tsc200x_probe(&spi->dev, spi->irq, &tsc2005_input_id,
devm_regmap_init_spi(spi, &tsc200x_regmap_config),
tsc2005_cmd);
}
Expand Down
15 changes: 12 additions & 3 deletions drivers/input/touchscreen/tsc200x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static void tsc200x_close(struct input_dev *input)
mutex_unlock(&ts->mutex);
}

int tsc200x_probe(struct device *dev, int irq, __u16 bustype,
int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
struct regmap *regmap,
int (*tsc200x_cmd)(struct device *dev, u8 cmd))
{
Expand Down Expand Up @@ -547,9 +547,18 @@ int tsc200x_probe(struct device *dev, int irq, __u16 bustype,
snprintf(ts->phys, sizeof(ts->phys),
"%s/input-ts", dev_name(dev));

input_dev->name = "TSC200X touchscreen";
if (tsc_id->product == 2004) {
input_dev->name = "TSC200X touchscreen";
} else {
input_dev->name = devm_kasprintf(dev, GFP_KERNEL,
"TSC%04d touchscreen",
tsc_id->product);
if (!input_dev->name)
return -ENOMEM;
}

input_dev->phys = ts->phys;
input_dev->id.bustype = bustype;
input_dev->id = *tsc_id;
input_dev->dev.parent = dev;
input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/touchscreen/tsc200x-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
extern const struct regmap_config tsc200x_regmap_config;
extern const struct dev_pm_ops tsc200x_pm_ops;

int tsc200x_probe(struct device *dev, int irq, __u16 bustype,
int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id,
struct regmap *regmap,
int (*tsc200x_cmd)(struct device *dev, u8 cmd));
int tsc200x_remove(struct device *dev);
Expand Down
30 changes: 9 additions & 21 deletions drivers/tty/vt/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,34 +366,22 @@ static void to_utf8(struct vc_data *vc, uint c)

static void do_compute_shiftstate(void)
{
unsigned int i, j, k, sym, val;
unsigned int k, sym, val;

shift_state = 0;
memset(shift_down, 0, sizeof(shift_down));

for (i = 0; i < ARRAY_SIZE(key_down); i++) {

if (!key_down[i])
for_each_set_bit(k, key_down, min(NR_KEYS, KEY_CNT)) {
sym = U(key_maps[0][k]);
if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK)
continue;

k = i * BITS_PER_LONG;

for (j = 0; j < BITS_PER_LONG; j++, k++) {

if (!test_bit(k, key_down))
continue;
val = KVAL(sym);
if (val == KVAL(K_CAPSSHIFT))
val = KVAL(K_SHIFT);

sym = U(key_maps[0][k]);
if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK)
continue;

val = KVAL(sym);
if (val == KVAL(K_CAPSSHIFT))
val = KVAL(K_SHIFT);

shift_down[val]++;
shift_state |= (1 << val);
}
shift_down[val]++;
shift_state |= BIT(val);
}
}

Expand Down

0 comments on commit 3aa536d

Please sign in to comment.