From: Sangwon Jee <jeesw@melfas.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, jeesw@melfas.com
Subject: [2/2] Input: melfas_mip4 - add fw_name sysfs attribute
Date: Fri, 21 Oct 2016 19:49:26 +0900 [thread overview]
Message-ID: <1477046966-9385-1-git-send-email-jeesw@melfas.com> (raw)
To support user firmware file name, add fw_name sysfs attribute
and modify to use fw_name variable instead of predefined value.
Signed-off-by: Sangwon Jee <jeesw@melfas.com>
---
drivers/input/touchscreen/melfas_mip4.c | 46 +++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 8739cb7..ae9c428 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -162,6 +162,7 @@ struct mip4_ts {
char product_name[16];
u16 product_id;
char ic_name[4];
+ char *fw_name;
unsigned int max_x;
unsigned int max_y;
@@ -1285,11 +1286,11 @@ static ssize_t mip4_sysfs_fw_update(struct device *dev,
const struct firmware *fw;
int error;
- error = request_firmware(&fw, MIP4_FW_NAME, dev);
+ error = request_firmware(&fw, ts->fw_name, dev);
if (error) {
dev_err(&ts->client->dev,
"Failed to retrieve firmware %s: %d\n",
- MIP4_FW_NAME, error);
+ ts->fw_name, error);
return error;
}
@@ -1403,11 +1404,51 @@ static ssize_t mip4_sysfs_read_ic_name(struct device *dev,
static DEVICE_ATTR(ic_name, S_IRUGO, mip4_sysfs_read_ic_name, NULL);
+static ssize_t mip4_sysfs_read_fw_name(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct mip4_ts *ts = i2c_get_clientdata(client);
+ size_t count;
+
+ mutex_lock(&ts->input->mutex);
+
+ count = snprintf(buf, PAGE_SIZE, "%s\n", ts->fw_name);
+
+ mutex_unlock(&ts->input->mutex);
+
+ return count;
+}
+
+static ssize_t mip4_sysfs_write_fw_name(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t count)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct mip4_ts *ts = i2c_get_clientdata(client);
+ char *filename;
+
+ filename = devm_kzalloc(dev, count - 1, GFP_KERNEL);
+ memcpy(filename, buf, count - 1);
+
+ ts->fw_name = devm_kstrdup(dev, filename, GFP_KERNEL);
+
+ devm_kfree(dev, filename);
+
+ return count;
+}
+
+static DEVICE_ATTR(fw_name, S_IRUGO | S_IWUSR,
+ mip4_sysfs_read_fw_name, mip4_sysfs_write_fw_name);
+
static struct attribute *mip4_attrs[] = {
&dev_attr_fw_version.attr,
&dev_attr_hw_version.attr,
&dev_attr_product_id.attr,
&dev_attr_ic_name.attr,
+ &dev_attr_fw_name.attr,
&dev_attr_update_fw.attr,
NULL,
};
@@ -1444,6 +1485,7 @@ static int mip4_probe(struct i2c_client *client, const struct i2c_device_id *id)
ts->client = client;
ts->input = input;
+ ts->fw_name = devm_kstrdup(&client->dev, MIP4_FW_NAME, GFP_KERNEL);
snprintf(ts->phys, sizeof(ts->phys),
"%s/input0", dev_name(&client->dev));
--
1.9.1
next reply other threads:[~2016-10-21 10:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 10:49 Sangwon Jee [this message]
2016-10-21 22:33 ` [2/2] Input: melfas_mip4 - add fw_name sysfs attribute Dmitry Torokhov
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=1477046966-9385-1-git-send-email-jeesw@melfas.com \
--to=jeesw@melfas.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
/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).