From: sashiko-bot@kernel.org
To: "Viral Patel" <viral8854@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 2/2] iio: magnetometer: add Infineon TLE493D-W2B6 driver
Date: Sat, 05 Dec 2026 07:37:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-251234@kernel.org> (raw)
In-Reply-To: <20261205-tle493d-v3-2-19fc44f81339@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] iio: magnetometer: tle493d_probe() broadcast reset breaks
sibling sensors
- [Medium] iio: magnetometer: tle493d_reset() lacks I2C bus lock across
reset frames
- [Medium] iio: magnetometer: tle493d_measure() can read torn data with
CA disabled
- [Medium] iio: tle493d: missing power-on delay after vdd enable in
tle493d_probe()
--
commit eb9704b11b9a3ed71756d6e4d39fe59ef234e32f
Author: Viral Patel <viral8854@gmail.com>
iio: magnetometer: add Infineon TLE493D-W2B6 driver
This commit adds an IIO driver for the Infineon TLE493D-W2B6 3-axis Hall
effect magnetometer and temperature sensor over I2C, supporting sysfs reads
and triggered buffer capture in master-controlled mode.
> diff --git a/drivers/iio/magnetometer/tle493d.c b/drivers/iio/magnetometer/tle493d.c
> new file mode 100644
> index 0000000000000..9982362b57cd2
> --- /dev/null
> +++ b/drivers/iio/magnetometer/tle493d.c
> @@ -0,0 +1,580 @@
[ ... ]
> +static int tle493d_measure(struct tle493d_data *data, u8 *buf)
> +{
> + u8 last_frm = tle493d_diag_frm(data->regs[TLE493D_REG_DIAG]);
> + u8 diag;
> + int ret, err;
> +
> + /* Rewriting Config with the write trigger starts a single conversion */
> + ret = tle493d_write(data, TLE493D_REG_CONFIG,
> + data->regs[TLE493D_REG_CONFIG], TLE493D_ADDR_TRIG_WRITE);
> + if (ret)
> + return ret;
> +
> + /* The result cannot be ready before the conversion time has passed */
> + fsleep(TLE493D_CONV_US);
> +
> + ret = read_poll_timeout(tle493d_read, err,
> + err || tle493d_conversion_done(buf, last_frm),
> + TLE493D_POLL_US, TLE493D_TIMEOUT_US, false,
> + data, buf, TLE493D_DATA_LEN);
[Severity: Medium]
Can tle493d_measure() return a torn measurement when a conversion finishes
mid-read?
tle493d_init() sets TLE493D_MOD1_CA, disabling clock stretching, and
tle493d_measure() sleeps only the typical conversion time (175 us) before
reading registers 0x00 through 0x06 in one transfer.
If the conversion completes after byte 0x00 starts clocking out and before
Diag (0x06) is read, buf[0..5] can mix old and new bytes while buf[6]
already reports completion.
Because tle493d_data_parity_ok() only checks a single XOR parity bit, half
of torn frames fail with -EIO and the other half silently pass with
corrupted readings. A clean read once Diag confirms completion (or
sleeping past the worst-case conversion time) would avoid this.
[ ... ]
> +static void tle493d_reset(struct tle493d_data *data)
> +{
> + struct i2c_adapter *adap = data->client->adapter;
> + static const struct {
> + u16 addr;
> + char read_write;
> + } frames[] = {
> + { 0x7f, I2C_SMBUS_READ },
> + { 0x7f, I2C_SMBUS_READ },
> + { 0x00, I2C_SMBUS_WRITE },
> + { 0x00, I2C_SMBUS_WRITE },
> + };
> +
> + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_QUICK)) {
> + dev_dbg(&data->client->dev, "adapter cannot send the reset sequence\n");
> + return;
> + }
> +
> + /* The reset frames are not acknowledged, so ignore the return values */
> + for (unsigned int i = 0; i < ARRAY_SIZE(frames); i++)
> + i2c_smbus_xfer(adap, frames[i].addr, 0, frames[i].read_write, 0,
> + I2C_SMBUS_QUICK, NULL);
> +
> + fsleep(TLE493D_RESET_DELAY_US);
> +}
[Severity: Medium]
Should tle493d_reset() hold the I2C segment lock across all four reset
frames?
i2c_smbus_xfer() acquires and releases I2C_LOCK_SEGMENT on each call, so
another driver on the adapter can interleave a transfer between frames and
silently break the reset sequence.
If the sensor fails to reset and retains a non-zero MOD2.PRD,
tle493d_init() computes FP assuming MOD2.PRD is 0 and can write a bad
parity bit that drops the sensor off the bus.
Locking with i2c_lock_bus(adap, I2C_LOCK_SEGMENT) around four
__i2c_smbus_xfer() calls and unlocking with i2c_unlock_bus() would keep the
sequence contiguous on the bus.
[ ... ]
> +static int tle493d_probe(struct i2c_client *client)
> +{
[ ... ]
> + ret = devm_regulator_get_enable(dev, "vdd");
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to enable vdd regulator\n");
[Severity: Medium]
Does tle493d_probe() need a power-on startup delay after enabling the vdd
regulator?
devm_regulator_get_enable() only waits for the regulator's own ramp time,
not the sensor's internal power-on reset and fuse-loading startup (~250 us).
When vdd is cold-enabled, especially on adapters without
I2C_FUNC_SMBUS_QUICK where tle493d_reset() returns with no delay, the
single non-retried MOD1 write in tle493d_init() can get a NACK and fail
probe.
> +
> + tle493d_reset(data);
> +
> + ret = tle493d_init(data, iicadr);
[Severity: High]
Will calling tle493d_reset() on every probe break already-probed TLE493D
sensors sharing the same I2C bus?
The driver supports all four factory address variants in
tle493d_i2c_addrs[], but tle493d_reset() sends unaddressed broadcast frames
(0x7f and general-call 0x00) that hardware-reset every TLE493D on the bus.
When a second sensor probes, it resets any already-initialized sibling back
to power-on defaults (PR=0, CA=0, INT=0, non-master mode), disrupting any
in-flight measurement and re-enabling /INT pulses on the shared SCL pin.
Because tle493d_measure() only rewrites Config and never restores MOD1,
previously probed sibling sensors stay permanently broken while only the
last-probed instance remains configured.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-tle493d-v3-0-19fc44f81339@gmail.com?part=2
prev parent reply other threads:[~2026-12-05 7:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 7:21 [PATCH v3 0/2] iio: magnetometer: add Infineon TLE493D-W2B6 support Viral Patel
2026-12-05 7:21 ` [PATCH v3 1/2] dt-bindings: iio: magnetometer: infineon,tlv493d-a1b6: add TLE493D-W2B6 Viral Patel
2026-12-05 7:21 ` [PATCH v3 2/2] iio: magnetometer: add Infineon TLE493D-W2B6 driver Viral Patel
2026-12-05 7:37 ` sashiko-bot [this message]
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=sashiko-outbox-251234@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=viral8854@gmail.com \
/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