From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-input@vger.kernel.org, Henrik Rydberg <rydberg@bitmath.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 5/5] Input: edt-ft5x06 - allocate buffer once for debugging
Date: Tue, 3 Mar 2020 20:09:17 +0200 [thread overview]
Message-ID: <20200303180917.12563-5-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200303180917.12563-1-andriy.shevchenko@linux.intel.com>
There is no need to allocate buffer each time we switch modes. First of all,
the code is protected by checking the factory_mode state. The size of the
buffer is static and can't be changed after ->probe() anyway.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/input/touchscreen/edt-ft5x06.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 1023d4134b8d..3895e194006a 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -544,16 +544,6 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata)
disable_irq(client->irq);
- if (!tsdata->raw_buffer) {
- tsdata->raw_bufsize = tsdata->num_x * tsdata->num_y *
- sizeof(u16);
- tsdata->raw_buffer = kzalloc(tsdata->raw_bufsize, GFP_KERNEL);
- if (!tsdata->raw_buffer) {
- error = -ENOMEM;
- goto err_out;
- }
- }
-
/* mode register is 0x3c when in the work mode */
error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03);
if (error) {
@@ -581,8 +571,6 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata)
return 0;
err_out:
- kfree(tsdata->raw_buffer);
- tsdata->raw_buffer = NULL;
tsdata->factory_mode = false;
enable_irq(client->irq);
@@ -622,9 +610,6 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata)
return -EIO;
}
- kfree(tsdata->raw_buffer);
- tsdata->raw_buffer = NULL;
-
/* restore parameters */
edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold,
tsdata->threshold);
@@ -697,7 +682,7 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,
mutex_lock(&tsdata->mutex);
- if (!tsdata->factory_mode || !tsdata->raw_buffer) {
+ if (!tsdata->factory_mode) {
error = -EIO;
goto out;
}
@@ -774,6 +759,12 @@ edt_ft5x06_ts_prepare_debugfs(struct edt_ft5x06_ts_data *tsdata,
debugfs_create_file("mode", S_IRUSR | S_IWUSR,
tsdata->debug_dir, tsdata, &debugfs_mode_fops);
+
+ tsdata->raw_bufsize = tsdata->num_x * tsdata->num_y * sizeof(u16);
+ tsdata->raw_buffer = kzalloc(tsdata->raw_bufsize, GFP_KERNEL);
+ if (!tsdata->raw_buffer)
+ return;
+
debugfs_create_file("raw_data", S_IRUSR,
tsdata->debug_dir, tsdata, &debugfs_raw_data_fops);
}
--
2.25.1
next prev parent reply other threads:[~2020-03-03 18:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 18:09 [PATCH v1 1/5] Input: of_touchscreen - explicitly choose axis Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 2/5] Input: edt-ft5x06 - refactor condition in edt_ft5x06_debugfs_mode_set() Andy Shevchenko
2020-03-07 1:11 ` Dmitry Torokhov
2020-03-03 18:09 ` [PATCH v1 3/5] Input: edt-ft5x06 - use U16_MAX instead of -1 Andy Shevchenko
2020-05-11 10:09 ` Andy Shevchenko
2020-03-03 18:09 ` [PATCH v1 4/5] Input: edt-ft5x06 - do not try to allocate too much memory Andy Shevchenko
2020-03-07 1:08 ` Dmitry Torokhov
2020-05-11 10:08 ` Andy Shevchenko
2020-03-03 18:09 ` Andy Shevchenko [this message]
2020-03-07 0:57 ` [PATCH v1 5/5] Input: edt-ft5x06 - allocate buffer once for debugging Dmitry Torokhov
2020-03-07 1:12 ` [PATCH v1 1/5] Input: of_touchscreen - explicitly choose axis 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=20200303180917.12563-5-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@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).