From: Pooyan Azad <pooyan.azadparvar@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Muhammad Bilal" <meatuni001@gmail.com>,
"Herlangga Maulani" <w1zardsec@proton.me>,
"Rob Herring" <robh@kernel.org>,
"Jeffrey Lin" <jeffrey.lin@rad-ic.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/3] Input: raydium_i2c_ts - resize report buffer after firmware update
Date: Mon, 28 Sep 2026 18:26:17 +0200 [thread overview]
Message-ID: <4c40e69aa94c91a241c2efbc26496dcabb0fca9e.1790612085.git.pooyan.azadparvar@gmail.com> (raw)
In-Reply-To: <cover.1790612085.git.pooyan.azadparvar@gmail.com>
A firmware update can change the packet size. The driver currently warns
and keeps the old report buffer in that case, while still updating other
report parameters. This leaves the buffer and parser state inconsistent.
Resize an existing report buffer after all device information has been
read successfully. Keep the new parameters local until the resize
succeeds so an error leaves the previous configuration intact.
Link: https://lore.kernel.org/r/20260927114425.442803-1-pooyan.azadparvar@gmail.com/
Reviewed-by: Muhammad Bilal <meatuni001@gmail.com>
Signed-off-by: Pooyan Azad <pooyan.azadparvar@gmail.com>
---
drivers/input/touchscreen/raydium_i2c_ts.c | 44 +++++++++++-----------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
index 03ea0ae62999..00990c61010f 100644
--- a/drivers/input/touchscreen/raydium_i2c_ts.c
+++ b/drivers/input/touchscreen/raydium_i2c_ts.c
@@ -332,7 +332,9 @@ static int raydium_i2c_query_ts_info(struct raydium_data *ts)
{
struct i2c_client *client = ts->client;
struct raydium_data_info data_info;
+ struct raydium_info info;
__le32 query_bank_addr;
+ u8 *report_data;
u8 report_size;
int error, retry_cnt;
@@ -360,27 +362,6 @@ static int raydium_i2c_query_ts_info(struct raydium_data *ts)
return -EINVAL;
}
- /*
- * Warn user if we already allocated memory for reports and
- * then the size changed (due to firmware update?) and keep
- * old size instead.
- */
- if (ts->report_data && ts->pkg_size != data_info.pkg_size) {
- dev_warn(&client->dev,
- "report size changes, was: %d, new: %d\n",
- ts->pkg_size, data_info.pkg_size);
- } else {
- ts->pkg_size = data_info.pkg_size;
- ts->report_size = report_size;
- }
-
- ts->contact_size = data_info.tp_info_size;
- ts->data_bank_addr = le32_to_cpu(data_info.data_bank_addr);
-
- dev_dbg(&client->dev,
- "data_bank_addr: %#08x, report_size: %d, contact_size: %d\n",
- ts->data_bank_addr, ts->report_size, ts->contact_size);
-
error = raydium_i2c_read(client, RM_CMD_QUERY_BANK,
&query_bank_addr,
sizeof(query_bank_addr));
@@ -388,10 +369,29 @@ static int raydium_i2c_query_ts_info(struct raydium_data *ts)
continue;
error = raydium_i2c_read(client, le32_to_cpu(query_bank_addr),
- &ts->info, sizeof(ts->info));
+ &info, sizeof(info));
if (error)
continue;
+ if (ts->report_data && ts->pkg_size != data_info.pkg_size) {
+ report_data = devm_krealloc(&client->dev, ts->report_data,
+ data_info.pkg_size, GFP_KERNEL);
+ if (!report_data)
+ return -ENOMEM;
+
+ ts->report_data = report_data;
+ }
+
+ ts->pkg_size = data_info.pkg_size;
+ ts->report_size = report_size;
+ ts->contact_size = data_info.tp_info_size;
+ ts->data_bank_addr = le32_to_cpu(data_info.data_bank_addr);
+ ts->info = info;
+
+ dev_dbg(&client->dev,
+ "data_bank_addr: %#08x, report_size: %d, contact_size: %d\n",
+ ts->data_bank_addr, ts->report_size, ts->contact_size);
+
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-09-28 16:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 11:44 [PATCH] Input: raydium_i2c_ts - validate report parameters Pooyan Azad
2026-09-27 17:30 ` Muhammad Bilal
2026-09-27 17:58 ` Pooyan Azadparvar
2026-09-28 2:38 ` Dmitry Torokhov
2026-09-28 6:04 ` Pooyan Azadparvar
2026-09-28 16:26 ` [PATCH v2 0/3] Input: raydium_i2c_ts report handling fixes Pooyan Azad
2026-09-28 16:26 ` [PATCH v2 1/3] Input: raydium_i2c_ts - validate report parameters Pooyan Azad
2026-09-28 16:26 ` Pooyan Azad [this message]
2026-09-28 16:26 ` [PATCH v2 3/3] Input: raydium_i2c_ts - defer report buffer allocation Pooyan Azad
2026-10-07 9:04 ` [PATCH v2 0/3] Input: raydium_i2c_ts report handling fixes Pooyan Azadparvar
2026-11-04 13:43 ` Pooyan Azadparvar
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=4c40e69aa94c91a241c2efbc26496dcabb0fca9e.1790612085.git.pooyan.azadparvar@gmail.com \
--to=pooyan.azadparvar@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jeffrey.lin@rad-ic.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=meatuni001@gmail.com \
--cc=robh@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=w1zardsec@proton.me \
/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
all inboxes | Powered by JetHome®