@@ -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;
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(+)