From: Lucas Stach <l.stach@pengutronix.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, kernel@pengutronix.de,
patchwork-lst@pengutronix.de
Subject: [PATCH v2 3/4] Input: exc3000: expose type, model and firmware revision as sysfs attributes
Date: Fri, 13 Mar 2020 15:33:44 +0100 [thread overview]
Message-ID: <20200313143345.28565-3-l.stach@pengutronix.de> (raw)
In-Reply-To: <20200313143345.28565-1-l.stach@pengutronix.de>
This can be used by userspace to determine if a firmware update should be
started.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
v2:
- use devm_device_add_group
---
drivers/input/touchscreen/exc3000.c | 47 +++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/input/touchscreen/exc3000.c b/drivers/input/touchscreen/exc3000.c
index 8d170bac182d..28621389917c 100644
--- a/drivers/input/touchscreen/exc3000.c
+++ b/drivers/input/touchscreen/exc3000.c
@@ -209,6 +209,48 @@ static int exc3000_vendor_data_request(struct exc3000_data *data, u8 *request,
return ret;
}
+
+static ssize_t exc3000_sysfs_type_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct exc3000_data *data = dev_get_drvdata(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", data->type);
+}
+static DEVICE_ATTR(type, 0444, exc3000_sysfs_type_show, NULL);
+
+static ssize_t exc3000_sysfs_model_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct exc3000_data *data = dev_get_drvdata(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", data->model);
+}
+static DEVICE_ATTR(model, 0444, exc3000_sysfs_model_show, NULL);
+
+static ssize_t exc3000_sysfs_fw_rev_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct exc3000_data *data = dev_get_drvdata(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%s\n", data->fw_rev);
+}
+static DEVICE_ATTR(fw_rev, 0444, exc3000_sysfs_fw_rev_show, NULL);
+
+static struct attribute *exc3000_fw_info_attrs[] = {
+ &dev_attr_type.attr,
+ &dev_attr_model.attr,
+ &dev_attr_fw_rev.attr,
+ NULL
+};
+
+static const struct attribute_group exc3000_fw_info_attr_group = {
+ .attrs = exc3000_fw_info_attrs,
+};
+
static int exc3000_populate_device_info(struct exc3000_data *data)
{
struct device *dev = &data->client->dev;
@@ -263,6 +305,10 @@ static int exc3000_populate_device_info(struct exc3000_data *data)
if (!data->fw_rev)
return -ENOMEM;
+ ret = devm_device_add_group(dev, &exc3000_fw_info_attr_group);
+ if (ret)
+ return ret;
+
dev_info(&data->client->dev,
"found type %s, model %s, firmware revision %s",
data->type, data->model, data->fw_rev);
@@ -314,6 +360,7 @@ static int exc3000_probe(struct i2c_client *client,
if (error)
return error;
+ dev_set_drvdata(&client->dev, data);
error = exc3000_populate_device_info(data);
if (error)
return error;
--
2.20.1
next prev parent reply other threads:[~2020-03-13 14:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 14:33 [PATCH v2 1/4] Input: exc3000: split MT event handling from IRQ handler Lucas Stach
2020-03-13 14:33 ` [PATCH v2 2/4] Input: exc3000: query and show type, model and firmware revision info Lucas Stach
2020-03-13 14:33 ` Lucas Stach [this message]
2020-03-13 14:33 ` [PATCH v2 4/4] Input: exc3000: add firmware update support Lucas Stach
2020-05-18 13:24 ` [PATCH v2 1/4] Input: exc3000: split MT event handling from IRQ handler Lucas Stach
2020-08-10 12:40 ` Lucas Stach
2020-08-10 16:27 ` Dmitry Torokhov
2020-08-10 16:49 ` Lucas Stach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200313143345.28565-3-l.stach@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=dmitry.torokhov@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-input@vger.kernel.org \
--cc=patchwork-lst@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).