From: Nick Dyer <nick@shmanahar.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Andrew Duggan <aduggan@synaptics.com>
Cc: Chris Healy <cphealy@gmail.com>,
Henrik Rydberg <rydberg@bitmath.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Nick Dyer <nick@shmanahar.org>
Subject: [PATCH v4 5/7] Input: synaptics-rmi4 - add sysfs attribute update_fw_status
Date: Wed, 19 Oct 2016 00:26:06 +0100 [thread overview]
Message-ID: <1476833168-12880-5-git-send-email-nick@shmanahar.org> (raw)
In-Reply-To: <1476833168-12880-1-git-send-email-nick@shmanahar.org>
The status is the percentage complete, or once complete, zero for
success or a negative return code.
Signed-off-by: Nick Dyer <nick@shmanahar.org>
---
drivers/input/rmi4/rmi_f34.c | 34 ++++++++++++++++++++++++++++++++++
drivers/input/rmi4/rmi_f34.h | 4 ++++
drivers/input/rmi4/rmi_f34v7.c | 14 ++++++++++++++
3 files changed, 52 insertions(+)
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index 4f97613..59adfec 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -156,6 +156,9 @@ static int rmi_f34_write_blocks(struct f34_data *f34, const void *data,
i + 1, block_count);
data += f34->v5.block_size;
+ f34->update_progress += f34->v5.block_size;
+ f34->update_status = (f34->update_progress * 100) /
+ f34->update_size;
}
return 0;
@@ -185,6 +188,8 @@ static int rmi_f34_flash_firmware(struct f34_data *f34,
struct rmi_function *fn = f34->fn;
int ret;
+ f34->update_progress = 0;
+ f34->update_size = syn_fw->image_size + syn_fw->config_size;
if (syn_fw->image_size) {
dev_info(&fn->dev, "Erasing firmware...\n");
ret = rmi_f34_command(f34, F34_ERASE_ALL,
@@ -276,12 +281,24 @@ int rmi_f34_update_firmware(struct f34_data *f34, const struct firmware *fw)
ret = rmi_f34_flash_firmware(f34, syn_fw);
+ f34->update_status = ret;
mutex_unlock(&f34->v5.flash_mutex);
out:
return ret;
}
+int rmi_f34_status(struct rmi_function *fn)
+{
+ struct f34_data *f34 = dev_get_drvdata(&fn->dev);
+
+ /*
+ * The status is the percentage complete, or once complete,
+ * zero for success or a negative return code.
+ */
+ return f34->update_status;
+}
+
static int rmi_firmware_update(struct rmi_driver_data *data,
const struct firmware *fw)
{
@@ -400,8 +417,25 @@ static ssize_t rmi_driver_update_fw_store(struct device *dev,
static DEVICE_ATTR(update_fw, 0200, NULL, rmi_driver_update_fw_store);
+static ssize_t rmi_driver_update_fw_status_show(struct device *dev,
+ struct device_attribute *dattr,
+ char *buf)
+{
+ struct rmi_driver_data *data = dev_get_drvdata(dev);
+ int update_status = 0;
+
+ if (data->f34_container)
+ update_status = rmi_f34_status(data->f34_container);
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n", update_status);
+}
+
+static DEVICE_ATTR(update_fw_status, 0444,
+ rmi_driver_update_fw_status_show, NULL);
+
static struct attribute *rmi_firmware_attrs[] = {
&dev_attr_update_fw.attr,
+ &dev_attr_update_fw_status.attr,
NULL
};
diff --git a/drivers/input/rmi4/rmi_f34.h b/drivers/input/rmi4/rmi_f34.h
index 9ab8ece..726d5ed 100644
--- a/drivers/input/rmi4/rmi_f34.h
+++ b/drivers/input/rmi4/rmi_f34.h
@@ -424,6 +424,10 @@ struct f34_data {
unsigned char bootloader_id[5];
unsigned char configuration_id[9];
+ int update_status;
+ int update_progress;
+ int update_size;
+
union {
struct f34v5_data v5;
struct f34v7_data v7;
diff --git a/drivers/input/rmi4/rmi_f34v7.c b/drivers/input/rmi4/rmi_f34v7.c
index 839f308..af00a3f 100644
--- a/drivers/input/rmi4/rmi_f34v7.c
+++ b/drivers/input/rmi4/rmi_f34v7.c
@@ -918,6 +918,11 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
block_ptr += (transfer * f34->v7.block_size);
remaining -= transfer;
+
+ if (command == v7_CMD_WRITE_FW)
+ f34->update_status = 80 - 70*remaining/block_cnt;
+ else if (command == v7_CMD_WRITE_CONFIG)
+ f34->update_status = 90 - 10*remaining/block_cnt;
} while (remaining);
return 0;
@@ -1273,6 +1278,8 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw)
if (ret < 0)
goto fail;
+ f34->update_status = 5;
+
if (!f34->v7.new_partition_table) {
ret = rmi_f34v7_check_ui_firmware_size(f34);
if (ret < 0)
@@ -1312,6 +1319,7 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw)
__func__);
}
+ f34->update_status = 10;
dev_info(&f34->fn->dev, "Writing firmware (%d bytes)...\n",
f34->v7.img.ui_firmware.size);
@@ -1336,6 +1344,8 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw)
goto fail;
}
+ f34->update_status = 95;
+
if (f34->v7.new_partition_table) {
if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) {
dev_info(&f34->fn->dev, "Writing guest code...\n");
@@ -1346,7 +1356,11 @@ int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw)
}
}
+ f34->update_status = 0;
+ return 0;
+
fail:
+ f34->update_status = ret;
return ret;
}
--
2.7.4
next prev parent reply other threads:[~2016-10-18 23:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 23:26 [PATCH v4 1/7] Input: synaptics-rmi4 - factor out functions from probe Nick Dyer
2016-10-18 23:26 ` [PATCH v4 2/7] Input: synaptics-rmi4 - add a couple of debug lines Nick Dyer
2016-10-18 23:26 ` [PATCH v4 3/7] Input: synaptics-rmi4 - add support for F34 device reflash Nick Dyer
2016-10-18 23:26 ` [PATCH v4 4/7] Input: synaptics-rmi4 - add support for F34 V7 bootloader Nick Dyer
2016-10-18 23:48 ` Bjorn Andersson
2016-10-18 23:26 ` Nick Dyer [this message]
2016-10-18 23:26 ` [PATCH v4 6/7] Input: synaptics-rmi4 - add sysfs interfaces for hardware IDs Nick Dyer
2016-10-18 23:26 ` [PATCH v4 7/7] Input: synaptics-rmi4 - add package_id sysfs attribute Nick Dyer
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=1476833168-12880-5-git-send-email-nick@shmanahar.org \
--to=nick@shmanahar.org \
--cc=aduggan@synaptics.com \
--cc=benjamin.tissoires@redhat.com \
--cc=bjorn.andersson@linaro.org \
--cc=cphealy@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rydberg@bitmath.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).