[PATCH v2 2/3] Input: raydium_i2c_ts - resize report buffer after firmware update

From: Pooyan Azad

Date: Mon Sep 28 2026 - 12:29:39 EST


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@xxxxxxxxx/
Reviewed-by: Muhammad Bilal <meatuni001@xxxxxxxxx>
Signed-off-by: Pooyan Azad <pooyan.azadparvar@xxxxxxxxx>
---
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