Commit 3aa536d9 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/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
parents f1894d83 e9003c9c
...@@ -66,7 +66,7 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12) ...@@ -66,7 +66,7 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)
struct rmi_device *rmi_dev = fn->rmi_dev; struct rmi_device *rmi_dev = fn->rmi_dev;
int ret; int ret;
int offset; int offset;
u8 buf[14]; u8 buf[15];
int pitch_x = 0; int pitch_x = 0;
int pitch_y = 0; int pitch_y = 0;
int clip_x_low = 0; int clip_x_low = 0;
...@@ -86,9 +86,10 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12) ...@@ -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); offset = rmi_register_desc_calc_reg_offset(&f12->control_reg_desc, 8);
if (item->reg_size > 14) { if (item->reg_size > sizeof(buf)) {
dev_err(&fn->dev, "F12 control8 should be 14 bytes, not: %ld\n", dev_err(&fn->dev,
item->reg_size); "F12 control8 should be no bigger than %zd bytes, not: %ld\n",
sizeof(buf), item->reg_size);
return -ENODEV; return -ENODEV;
} }
......
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
#include <linux/regmap.h> #include <linux/regmap.h>
#include "tsc200x-core.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) static int tsc2004_cmd(struct device *dev, u8 cmd)
{ {
u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
...@@ -42,7 +47,7 @@ static int tsc2004_probe(struct i2c_client *i2c, ...@@ -42,7 +47,7 @@ static int tsc2004_probe(struct i2c_client *i2c,
const struct i2c_device_id *id) 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), devm_regmap_init_i2c(i2c, &tsc200x_regmap_config),
tsc2004_cmd); tsc2004_cmd);
} }
......
...@@ -24,6 +24,11 @@ ...@@ -24,6 +24,11 @@
#include <linux/regmap.h> #include <linux/regmap.h>
#include "tsc200x-core.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) static int tsc2005_cmd(struct device *dev, u8 cmd)
{ {
u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd; u8 tx = TSC200X_CMD | TSC200X_CMD_12BIT | cmd;
...@@ -62,7 +67,7 @@ static int tsc2005_probe(struct spi_device *spi) ...@@ -62,7 +67,7 @@ static int tsc2005_probe(struct spi_device *spi)
if (error) if (error)
return 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), devm_regmap_init_spi(spi, &tsc200x_regmap_config),
tsc2005_cmd); tsc2005_cmd);
} }
......
...@@ -450,7 +450,7 @@ static void tsc200x_close(struct input_dev *input) ...@@ -450,7 +450,7 @@ static void tsc200x_close(struct input_dev *input)
mutex_unlock(&ts->mutex); 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, struct regmap *regmap,
int (*tsc200x_cmd)(struct device *dev, u8 cmd)) int (*tsc200x_cmd)(struct device *dev, u8 cmd))
{ {
...@@ -547,9 +547,18 @@ int tsc200x_probe(struct device *dev, int irq, __u16 bustype, ...@@ -547,9 +547,18 @@ int tsc200x_probe(struct device *dev, int irq, __u16 bustype,
snprintf(ts->phys, sizeof(ts->phys), snprintf(ts->phys, sizeof(ts->phys),
"%s/input-ts", dev_name(dev)); "%s/input-ts", dev_name(dev));
if (tsc_id->product == 2004) {
input_dev->name = "TSC200X touchscreen"; 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->phys = ts->phys;
input_dev->id.bustype = bustype; input_dev->id = *tsc_id;
input_dev->dev.parent = dev; input_dev->dev.parent = dev;
input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
extern const struct regmap_config tsc200x_regmap_config; extern const struct regmap_config tsc200x_regmap_config;
extern const struct dev_pm_ops tsc200x_pm_ops; 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, struct regmap *regmap,
int (*tsc200x_cmd)(struct device *dev, u8 cmd)); int (*tsc200x_cmd)(struct device *dev, u8 cmd));
int tsc200x_remove(struct device *dev); int tsc200x_remove(struct device *dev);
......
...@@ -366,23 +366,12 @@ static void to_utf8(struct vc_data *vc, uint c) ...@@ -366,23 +366,12 @@ static void to_utf8(struct vc_data *vc, uint c)
static void do_compute_shiftstate(void) static void do_compute_shiftstate(void)
{ {
unsigned int i, j, k, sym, val; unsigned int k, sym, val;
shift_state = 0; shift_state = 0;
memset(shift_down, 0, sizeof(shift_down)); memset(shift_down, 0, sizeof(shift_down));
for (i = 0; i < ARRAY_SIZE(key_down); i++) { for_each_set_bit(k, key_down, min(NR_KEYS, KEY_CNT)) {
if (!key_down[i])
continue;
k = i * BITS_PER_LONG;
for (j = 0; j < BITS_PER_LONG; j++, k++) {
if (!test_bit(k, key_down))
continue;
sym = U(key_maps[0][k]); sym = U(key_maps[0][k]);
if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK) if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK)
continue; continue;
...@@ -392,8 +381,7 @@ static void do_compute_shiftstate(void) ...@@ -392,8 +381,7 @@ static void do_compute_shiftstate(void)
val = KVAL(K_SHIFT); val = KVAL(K_SHIFT);
shift_down[val]++; shift_down[val]++;
shift_state |= (1 << val); shift_state |= BIT(val);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment