From: Marco Felsch <m.felsch@pengutronix.de>
To: dmitry.torokhov@gmail.com, andriy.shevchenko@linux.intel.com,
hdegoede@redhat.com, LW@KARO-electronics.de
Cc: linux-input@vger.kernel.org, kernel@pengutronix.de
Subject: [PATCH 2/4] Input: edt-ft5x06 - move parameter restore into helper
Date: Thu, 27 Feb 2020 12:28:17 +0100 [thread overview]
Message-ID: <20200227112819.16754-3-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20200227112819.16754-1-m.felsch@pengutronix.de>
We need to restore the parameters if we switch between the
factory/work mode and during the resume process if we switched off the
power-supply. Therefore refactor edt_ft5x06_work_mode() and move the
"restore the parameters" into a helper routine so we can reuse it later.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/input/touchscreen/edt-ft5x06.c | 43 ++++++++++++++------------
1 file changed, 24 insertions(+), 19 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 9b8450794a8a..bb9107093796 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -527,6 +527,29 @@ static const struct attribute_group edt_ft5x06_attr_group = {
.attrs = edt_ft5x06_attrs,
};
+static void edt_ft5x06_restore_reg_parameters(struct edt_ft5x06_ts_data *tsdata)
+{
+ struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
+
+ edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold,
+ tsdata->threshold);
+ edt_ft5x06_register_write(tsdata, reg_addr->reg_gain,
+ tsdata->gain);
+ if (reg_addr->reg_offset != NO_REGISTER)
+ edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
+ tsdata->offset);
+ if (reg_addr->reg_offset_x != NO_REGISTER)
+ edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x,
+ tsdata->offset_x);
+ if (reg_addr->reg_offset_y != NO_REGISTER)
+ edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y,
+ tsdata->offset_y);
+ if (reg_addr->reg_report_rate != NO_REGISTER)
+ edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate,
+ tsdata->report_rate);
+
+}
+
#ifdef CONFIG_DEBUG_FS
static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata)
{
@@ -592,7 +615,6 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
{
struct i2c_client *client = tsdata->client;
int retries = EDT_SWITCH_MODE_RETRIES;
- struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
int ret;
int error;
@@ -624,24 +646,7 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
kfree(tsdata->raw_buffer);
tsdata->raw_buffer = NULL;
- /* restore parameters */
- edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold,
- tsdata->threshold);
- edt_ft5x06_register_write(tsdata, reg_addr->reg_gain,
- tsdata->gain);
- if (reg_addr->reg_offset != NO_REGISTER)
- edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
- tsdata->offset);
- if (reg_addr->reg_offset_x != NO_REGISTER)
- edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x,
- tsdata->offset_x);
- if (reg_addr->reg_offset_y != NO_REGISTER)
- edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y,
- tsdata->offset_y);
- if (reg_addr->reg_report_rate != NO_REGISTER)
- edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate,
- tsdata->report_rate);
-
+ edt_ft5x06_restore_reg_parameters(tsdata);
enable_irq(client->irq);
return 0;
--
2.20.1
next prev parent reply other threads:[~2020-02-27 11:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 11:28 [PATCH 0/4] EDT-FT5x06 Fixes and improvments Marco Felsch
2020-02-27 11:28 ` [PATCH 1/4] Input: edt-ft5x06 - fix get_default register write access Marco Felsch
2020-05-09 19:05 ` Dmitry Torokhov
2020-05-10 11:06 ` Marco Felsch
2020-05-11 17:53 ` Dmitry Torokhov
2020-05-12 17:01 ` Marco Felsch
2020-02-27 11:28 ` Marco Felsch [this message]
2020-05-09 19:06 ` [PATCH 2/4] Input: edt-ft5x06 - move parameter restore into helper Dmitry Torokhov
2020-02-27 11:28 ` [PATCH 3/4] Input: edt-ft5x06 - improve power management operations Marco Felsch
2020-05-09 21:21 ` Dmitry Torokhov
2020-02-27 11:28 ` [PATCH 4/4] Input: edt-ft5x06 - prefer asynchronous probe Marco Felsch
2020-05-09 21:28 ` Dmitry Torokhov
2020-03-09 6:44 ` [PATCH 0/4] EDT-FT5x06 Fixes and improvments Marco Felsch
2020-03-31 7:50 ` Marco Felsch
2020-05-08 8:22 ` Marco Felsch
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=20200227112819.16754-3-m.felsch@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=LW@KARO-electronics.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dmitry.torokhov@gmail.com \
--cc=hdegoede@redhat.com \
--cc=kernel@pengutronix.de \
--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).