diff mbox series

[v3,4/5] Input: exc3000 - add type sysfs attribute

Message ID 20210125182527.1225245-5-l.stach@pengutronix.de (mailing list archive)
State Accepted
Commit ad117c558e838f9fa93af265d8f9dd54e87e15b1
Headers show
Series exc3000 firmware update support | expand

Commit Message

Lucas Stach Jan. 25, 2021, 6:25 p.m. UTC
Add a sysfs attribute to query the type of the touchscreen device.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 .../ABI/testing/sysfs-driver-input-exc3000      |  9 +++++++++
 drivers/input/touchscreen/exc3000.c             | 17 +++++++++++++++++
 2 files changed, 26 insertions(+)

Comments

Dmitry Torokhov March 8, 2021, 5:44 a.m. UTC | #1
On Mon, Jan 25, 2021 at 07:25:26PM +0100, Lucas Stach wrote:
> Add a sysfs attribute to query the type of the touchscreen device.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

Applied, thank you.
diff mbox series

Patch

diff --git a/Documentation/ABI/testing/sysfs-driver-input-exc3000 b/Documentation/ABI/testing/sysfs-driver-input-exc3000
index cd7c578aef2c..704434b277b0 100644
--- a/Documentation/ABI/testing/sysfs-driver-input-exc3000
+++ b/Documentation/ABI/testing/sysfs-driver-input-exc3000
@@ -15,3 +15,12 @@  Description:    Reports the model identification provided by the touchscreen, fo
 		Access: Read
 
 		Valid values: Represented as string
+
+What:		/sys/bus/i2c/devices/xxx/type
+Date:		Jan 2021
+Contact:	linux-input@vger.kernel.org
+Description:	Reports the type identification provided by the touchscreen, for example "PCAP82H80 Series"
+
+		Access: Read
+
+		Valid values: Represented as string
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index ae06290a4c45..74ba03dcaaf7 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -298,9 +298,26 @@  static ssize_t model_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(model);
 
+static ssize_t type_show(struct device *dev,
+			  struct device_attribute *attr, char *buf)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct exc3000_data *data = i2c_get_clientdata(client);
+	u8 response[EXC3000_LEN_FRAME];
+	int ret;
+
+	ret = exc3000_vendor_data_request(data, (u8[]){'F'}, 1, response, 1);
+	if (ret < 0)
+		return ret;
+
+	return sprintf(buf, "%s\n", &response[1]);
+}
+static DEVICE_ATTR_RO(type);
+
 static struct attribute *sysfs_attrs[] = {
 	&dev_attr_fw_version.attr,
 	&dev_attr_model.attr,
+	&dev_attr_type.attr,
 	NULL
 };