summaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorSven Van Asbroeck <thesven73@gmail.com>2019-11-12 15:44:10 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2019-11-12 15:53:33 -0800
commitcc12ba1872c6bf05b5f177fae5082bcbea335f2b (patch)
tree189f75f69451c6fa607f93bf4d41da3d88afeff6 /drivers/input
parentb32fbeaec52d387004dd7fa15877b8adf7b396c3 (diff)
downloadlinux-cc12ba1872c6bf05b5f177fae5082bcbea335f2b.tar.gz
linux-cc12ba1872c6bf05b5f177fae5082bcbea335f2b.tar.bz2
linux-cc12ba1872c6bf05b5f177fae5082bcbea335f2b.zip
Input: ili210x - optionally show calibrate sysfs attribute
Only show the 'calibrate' sysfs attribute on chip flavours which support calibration by writing to a calibration register. Do this by adding a flag to the chip operations structure. Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Link: https://lore.kernel.org/r/20191112210148.3535-2-TheSven73@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/ili210x.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 6861ac4355b2..4a17096e83e1 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -33,6 +33,7 @@ struct ili2xxx_chip {
bool (*continue_polling)(const u8 *data, bool touch);
unsigned int max_touches;
unsigned int resolution;
+ bool has_calibrate_reg;
};
struct ili210x {
@@ -103,6 +104,7 @@ static const struct ili2xxx_chip ili210x_chip = {
.parse_touch_data = ili210x_touchdata_to_coords,
.continue_polling = ili210x_check_continue_polling,
.max_touches = 2,
+ .has_calibrate_reg = true,
};
static int ili211x_read_touch_data(struct i2c_client *client, u8 *data)
@@ -228,6 +230,7 @@ static const struct ili2xxx_chip ili251x_chip = {
.parse_touch_data = ili251x_touchdata_to_coords,
.continue_polling = ili251x_check_continue_polling,
.max_touches = 10,
+ .has_calibrate_reg = true,
};
static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
@@ -311,8 +314,19 @@ static struct attribute *ili210x_attributes[] = {
NULL,
};
+static umode_t ili210x_calibrate_visible(struct kobject *kobj,
+ struct attribute *attr, int index)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct i2c_client *client = to_i2c_client(dev);
+ struct ili210x *priv = i2c_get_clientdata(client);
+
+ return priv->chip->has_calibrate_reg;
+}
+
static const struct attribute_group ili210x_attr_group = {
.attrs = ili210x_attributes,
+ .is_visible = ili210x_calibrate_visible,
};
static void ili210x_power_down(void *data)