Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexandre Hamamdjian" <azkali.limited@gmail.com>
Cc: conor+dt@kernel.org, linux-input@vger.kernel.org,
	dmitry.torokhov@gmail.com, devicetree@vger.kernel.org,
	robh@kernel.org
Subject: Re: [PATCH 3/4] Input: edt-ft5x06 - allow reading the touch frame one register at a time
Date: Thu, 23 Jul 2026 11:39:57 +0000	[thread overview]
Message-ID: <20260723113958.533CA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723-b4-ft5426-v1-3-d4b4e32be042@gmail.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The no-regmap-bulk-read fallback causes an out-of-bounds memory read and functional breakage on EDT_M06 devices.
- [Medium] Immediate redundant retries on permanent bus errors in edt_ft5x06_bulk_read.
- [Medium] Incomplete implementation of no-regmap-bulk-read leaves other bulk reads unpatched.
- [Low] Subsystem guide violation: variable `ret` used for error codes instead of `error` or `err`.
--

--- Patch [3]: [PATCH 3/4] Input: edt-ft5x06 - allow reading the touch frame one register at a time ---
commit 5f06c007cc93b45a3ff2f9ecba4f1f085c956d6f
Author: Teguh Sobirin <teguh@sobir.in>

Input: edt-ft5x06 - allow reading the touch frame one register at a time

This commit introduces a "no-regmap-bulk-read" property to handle I2C
controllers that cannot sustain multi-byte transfers. It implements a fallback
that reads the touch frame one register at a time.

> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index d6c3d033b83df..ac61ac44fd649 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
[ ... ]
> @@ -295,6 +296,31 @@ static const struct regmap_config edt_M06_i2c_regmap_config = {
>  	.write = edt_M06_i2c_write,
>  };
>  
> +static int edt_ft5x06_bulk_read(struct regmap *map, unsigned int start,
> +				void *val, size_t len)
> +{
> +	u8 *dst = val;
> +	size_t off;
> +
> +	for (off = 0; off < len; off++) {
> +		unsigned int v;
> +		int ret, tries;

[Severity: Low]
This isn't a bug, but does using 'ret' here violate the input subsystem
guidelines? 

The maintainer prefers using 'error' or 'err' for variables that only hold
negative error codes or 0 for success.

> +
> +		for (tries = 0; tries < 3; tries++) {
> +			ret = regmap_read(map, start + off, &v);

[Severity: High]
Does this 1-byte read cause an out-of-bounds access and functional breakage
on EDT_M06 devices?

If the board uses an M06 device with the no-regmap-bulk-read property, this
call will split the frame read into 1-byte chunks. However, the custom
edt_M06_i2c_read() function expects a larger buffer to validate the header:

    u8 *buf = (u8 *)val_buf;
    if (buf[0] != 0xaa || buf[1] != 0xaa ||
        buf[2] != val_size) {

Since regmap only provides a 1-byte buffer for a 1-byte read, this will read
out of bounds and deterministically fail the header validation. 

Additionally, subsequent bytes will hit the default case, sending invalid
factory commands instead of reading touch data.

> +			if (!ret)
> +				break;
> +			if (ret == -ETIMEDOUT || ret == -EAGAIN)
> +				usleep_range(2000, 4000);

[Severity: Medium]
Will this loop immediately issue redundant retries if the error is permanent?

If regmap_read() returns a permanent error like -EIO (e.g., due to a NACK), it
correctly skips the usleep_range() here. However, since there is no 'else break'
for unhandled errors, it will immediately loop and issue the failed transaction
again up to 3 times back-to-back.

> +		}
> +		if (ret)
> +			return ret;
> +		dst[off] = v;
> +	}
> +
> +	return 0;
> +}
[ ... ]
> @@ -1212,6 +1242,9 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client)
>  		return error;
>  	}
>  
> +	tsdata->no_regmap_bulk_read =
> +		device_property_read_bool(&client->dev, "no-regmap-bulk-read");
> +

[Severity: Medium]
Is the no-regmap-bulk-read workaround incomplete?

While the ISR now uses the fallback, other parts of the driver still use
unconditional bulk reads. For example, in edt_ft5x06_ts_identify() called
during probe:

    error = regmap_bulk_read(tsdata->regmap, 0xBB, rdbuf, EDT_NAME_LEN - 1);

If the bus truly cannot sustain multi-byte transfers, won't the probe and
debugfs features still fail despite this property being set?

>  	/*
>  	 * Check which sleep modes we can support. Power-off requires the
>  	 * reset-pin to ensure correct power-down/power-up behaviour. Start with

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260723-b4-ft5426-v1-0-d4b4e32be042@gmail.com?part=3

  reply	other threads:[~2026-07-23 11:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 11:27 [PATCH 0/4] Input: edt-ft5x06: robustness fixes for a FocalTech FT5426 on a marginal bus Alexandre Hamamdjian via B4 Relay
2026-07-23 11:27 ` [PATCH 1/4] Input: edt-ft5x06 - ignore contacts with an out-of-range slot id Alexandre Hamamdjian via B4 Relay
2026-07-23 11:40   ` sashiko-bot
2026-07-23 11:27 ` [PATCH 2/4] dt-bindings: input: edt-ft5x06 - add no-regmap-bulk-read property Alexandre Hamamdjian via B4 Relay
2026-07-23 11:35   ` sashiko-bot
2026-07-23 11:27 ` [PATCH 3/4] Input: edt-ft5x06 - allow reading the touch frame one register at a time Alexandre Hamamdjian via B4 Relay
2026-07-23 11:39   ` sashiko-bot [this message]
2026-07-23 11:27 ` [PATCH 4/4] Input: edt-ft5x06 - poll while a contact is down to recover dropped releases Alexandre Hamamdjian via B4 Relay
2026-07-23 11:39   ` sashiko-bot

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=20260723113958.533CA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=azkali.limited@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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