diff mbox series

[2/8] Input: atmel_mxt_ts - show info/confing checksum.

Message ID 20190828095349.30607-2-jongpuls@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/8] Input: atmel_mxt_ts - eanble calibration via sysfs | expand

Commit Message

Jongpil Jung Aug. 28, 2019, 9:53 a.m. UTC
From: Jongpil Jung <jongpil19.jung@samsung.corp-partner.google.com>

To check current touchscreen config, we need to read information and
config checksum.
With patch, we can check checksum in user space via sysfs easily.

Change-Id: I0328945cec10f142bd5670bfd7a3133de3f473db
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 4fe2059fa3c1..cabe746607fc 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -2692,6 +2692,13 @@  static ssize_t mxt_calibrate_store(struct device *dev,
 	return ret ?: count;
 }
 
+static ssize_t mxt_config_csum_show(struct device *dev,
+				    struct device_attribute *attr, char *buf)
+{
+	struct mxt_data *data = dev_get_drvdata(dev);
+	return scnprintf(buf, PAGE_SIZE, "%06x\n", data->config_crc);
+}
+
 /* Firmware Version is returned as Major.Minor.Build */
 static ssize_t mxt_fw_version_show(struct device *dev,
 				   struct device_attribute *attr, char *buf)
@@ -2712,6 +2719,13 @@  static ssize_t mxt_hw_version_show(struct device *dev,
 			 info->family_id, info->variant_id);
 }
 
+static ssize_t mxt_info_csum_show(struct device *dev,
+				  struct device_attribute *attr, char *buf)
+{
+	struct mxt_data *data = dev_get_drvdata(dev);
+	return scnprintf(buf, PAGE_SIZE, "%06x\n", data->info_crc);
+}
+
 static ssize_t mxt_show_instance(char *buf, int count,
 				 struct mxt_object *object, int instance,
 				 const u8 *val)
@@ -2940,15 +2954,19 @@  static ssize_t mxt_update_fw_store(struct device *dev,
 }
 
 static DEVICE_ATTR(calibrate, S_IWUSR, NULL, mxt_calibrate_store);
+static DEVICE_ATTR(config_csum, S_IRUGO, mxt_config_csum_show, NULL);
 static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL);
 static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL);
+static DEVICE_ATTR(info_csum, S_IRUGO, mxt_info_csum_show, NULL);
 static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL);
 static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store);
 
 static struct attribute *mxt_attrs[] = {
 	&dev_attr_calibrate.attr,
+	&dev_attr_config_csum.attr,
 	&dev_attr_fw_version.attr,
 	&dev_attr_hw_version.attr,
+	&dev_attr_info_csum.attr,
 	&dev_attr_object.attr,
 	&dev_attr_update_fw.attr,
 	NULL