Skip to content

Commit cc12ba1

Browse files
Sven Van Asbroeckdtor
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent b32fbea commit cc12ba1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/input/touchscreen/ili210x.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct ili2xxx_chip {
3333
bool (*continue_polling)(const u8 *data, bool touch);
3434
unsigned int max_touches;
3535
unsigned int resolution;
36+
bool has_calibrate_reg;
3637
};
3738

3839
struct ili210x {
@@ -103,6 +104,7 @@ static const struct ili2xxx_chip ili210x_chip = {
103104
.parse_touch_data = ili210x_touchdata_to_coords,
104105
.continue_polling = ili210x_check_continue_polling,
105106
.max_touches = 2,
107+
.has_calibrate_reg = true,
106108
};
107109

108110
static int ili211x_read_touch_data(struct i2c_client *client, u8 *data)
@@ -228,6 +230,7 @@ static const struct ili2xxx_chip ili251x_chip = {
228230
.parse_touch_data = ili251x_touchdata_to_coords,
229231
.continue_polling = ili251x_check_continue_polling,
230232
.max_touches = 10,
233+
.has_calibrate_reg = true,
231234
};
232235

233236
static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata)
@@ -311,8 +314,19 @@ static struct attribute *ili210x_attributes[] = {
311314
NULL,
312315
};
313316

317+
static umode_t ili210x_calibrate_visible(struct kobject *kobj,
318+
struct attribute *attr, int index)
319+
{
320+
struct device *dev = kobj_to_dev(kobj);
321+
struct i2c_client *client = to_i2c_client(dev);
322+
struct ili210x *priv = i2c_get_clientdata(client);
323+
324+
return priv->chip->has_calibrate_reg;
325+
}
326+
314327
static const struct attribute_group ili210x_attr_group = {
315328
.attrs = ili210x_attributes,
329+
.is_visible = ili210x_calibrate_visible,
316330
};
317331

318332
static void ili210x_power_down(void *data)

0 commit comments

Comments
 (0)