Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sven Van Asbroeck and committed by
Dmitry Torokhov
cc12ba18 b32fbeae

+14
+14
drivers/input/touchscreen/ili210x.c
··· 33 33 bool (*continue_polling)(const u8 *data, bool touch); 34 34 unsigned int max_touches; 35 35 unsigned int resolution; 36 + bool has_calibrate_reg; 36 37 }; 37 38 38 39 struct ili210x { ··· 104 103 .parse_touch_data = ili210x_touchdata_to_coords, 105 104 .continue_polling = ili210x_check_continue_polling, 106 105 .max_touches = 2, 106 + .has_calibrate_reg = true, 107 107 }; 108 108 109 109 static int ili211x_read_touch_data(struct i2c_client *client, u8 *data) ··· 230 228 .parse_touch_data = ili251x_touchdata_to_coords, 231 229 .continue_polling = ili251x_check_continue_polling, 232 230 .max_touches = 10, 231 + .has_calibrate_reg = true, 233 232 }; 234 233 235 234 static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata) ··· 314 311 NULL, 315 312 }; 316 313 314 + static umode_t ili210x_calibrate_visible(struct kobject *kobj, 315 + struct attribute *attr, int index) 316 + { 317 + struct device *dev = kobj_to_dev(kobj); 318 + struct i2c_client *client = to_i2c_client(dev); 319 + struct ili210x *priv = i2c_get_clientdata(client); 320 + 321 + return priv->chip->has_calibrate_reg; 322 + } 323 + 317 324 static const struct attribute_group ili210x_attr_group = { 318 325 .attrs = ili210x_attributes, 326 + .is_visible = ili210x_calibrate_visible, 319 327 }; 320 328 321 329 static void ili210x_power_down(void *data)