Commit e9003c9c authored by Michael Welling's avatar Michael Welling Committed by Dmitry Torokhov

Input: tsc200x - report proper input_dev name

Passes input_id struct to the common probe function for the tsc200x drivers
instead of just the bustype.

This allows for the use of the product variable to set the input_dev->name
variable according to the type of touchscreen used. Note that when we
introduced support for TSC2004 we started calling everything TSC200X, so
let's keep this quirk.
Signed-off-by: default avatarMichael Welling <mwelling@ieee.org>
Cc: stable@vger.kernel.org
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Acked-by: default avatarPali Rohár <pali.rohar@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 510cccb5
...@@ -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));
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->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);
......
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