Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Liviu Stan" <liviu.stan@analog.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 8/8] iio: temperature: ltc2983: Add support for ADT7604
Date: Thu, 21 May 2026 19:18:28 +0000	[thread overview]
Message-ID: <20260521191828.F20931F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260521164323.770626-9-liviu.stan@analog.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Reading the IIO_RESISTANCE channel bypasses hardware fault detection, causing hardware errors (like broken sensor traces) to be silently reported as valid data.

Pre-existing issues:
- [High] reinit_completion() is called after initiating the hardware conversion, creating a race condition that can cause spurious read timeouts.
--

commit d382a4cbefd41723ab5ddd91fd399d716c8faaec
Author: Liviu Stan <liviu.stan@analog.com>
Subject: iio: temperature: ltc2983: Add support for ADT7604

This commit adds support for the ADT7604 temperature sensor by repurposing
custom RTD and thermistor types as copper trace resistance and leak detector
sensors. It introduces two new software sensor types and exposes a new
IIO_RESISTANCE channel reading from a separate result register bank. The
ltc2983_chip_info struct is also extended to use a 64-bit supported_sensors
bitmask for the new types.

> diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
> index 326f843f42713..e2ffeee026eef 100644
> --- a/drivers/iio/temperature/ltc2983.c
> +++ b/drivers/iio/temperature/ltc2983.c

[ ... ]

> @@ -1205,7 +1502,8 @@ static struct ltc2983_sensor *ltc2983_temp_new(struct fwnode_handle *child,
>  }
>  
>  static int ltc2983_chan_read(struct ltc2983_data *st,
> -			const struct ltc2983_sensor *sensor, int *val)
> +			const struct ltc2983_sensor *sensor,
> +			u32 base_reg, int *val)
>  {
>  	struct device *dev = &st->spi->dev;
>  	u32 start_conversion = 0;

[Severity: High]
This is a pre-existing issue, but can this function experience spurious
read timeouts due to a race condition with the completion?

Looking at the rest of this function:

    ret = regmap_write(st->regmap, LTC2983_STATUS_REG, start_conversion);
    if (ret)
        return ret;

    reinit_completion(&st->completion);

If the hardware conversion finishes very quickly after regmap_write(),
could the interrupt fire and call complete() before the CPU executes
reinit_completion()? This would overwrite the completion event, causing the
subsequent wait_for_completion_timeout() to spuriously time out.

Would it be safer to call reinit_completion() before initiating the hardware
action?

[ ... ]

> @@ -1236,13 +1534,23 @@ static int ltc2983_chan_read(struct ltc2983_data *st,
>  	}
>  
>  	/* read the converted data */
> -	ret = regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan),
> +	ret = regmap_bulk_read(st->regmap, LTC2983_RESULT_ADDR(sensor->chan, base_reg),
>  			       &st->temp, sizeof(st->temp));
>  	if (ret)
>  		return ret;
>  
>  	*val = __be32_to_cpu(st->temp);
>  
> +	if (base_reg == ADT7604_RES_RES_START_REG) {
> +		/*
> +		 * Resistance result register gives a plain unsigned value,
> +		 * D31 is always 0, no valid bit, no fault bits. Read bits[30:0]
> +		 * directly — the temperature result format does not apply here.
> +		 */
> +		*val &= GENMASK(30, 0);
> +		return 0;

[Severity: High]
Will returning early here bypass hardware fault detection for resistance
channels?

As the comment notes, the resistance result register does not contain fault
bits. However, hardware fault indicators (like Hard Fault, Soft Fault, or
Over Range) are stored in the primary Temperature Result register.

By returning before reading the Temperature Result register and calling
sensor->fault_handler(), does this code silently ignore sensor faults? This
might be problematic for sub-ohm copper traces, which only expose the
IIO_RESISTANCE channel, leaving users with no mechanism to detect a broken
trace.

> +	}
> +
>  	if (!(LTC2983_RES_VALID_MASK & *val)) {
>  		dev_err(dev, "Invalid conversion detected\n");
>  		return -EIO;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260521164323.770626-1-liviu.stan@analog.com?part=8

  reply	other threads:[~2026-05-21 19:18 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 16:42 [PATCH v3 0/8] iio: temperature: ltc2983: Add support for ADT7604 Liviu Stan
2026-05-21 16:42 ` [PATCH v3 1/8] iio: temperature: ltc2983: Fix macro parenthesization and rename Liviu Stan
2026-05-22  9:11   ` Joshua Crofts
2026-05-22 12:56     ` Jonathan Cameron
2026-05-21 16:42 ` [PATCH v3 2/8] iio: temperature: ltc2983: Use local device pointer consistently Liviu Stan
2026-05-22  7:37   ` Joshua Crofts
2026-05-22 13:02   ` Jonathan Cameron
2026-05-22 13:56     ` Stan, Liviu
2026-06-02 23:19   ` Andy Shevchenko
2026-05-21 16:42 ` [PATCH v3 3/8] iio: temperature: ltc2983: Fix inconsistent channel wording in messages Liviu Stan
2026-05-22  7:07   ` Joshua Crofts
2026-06-02 23:21   ` Andy Shevchenko
2026-05-21 16:42 ` [PATCH v3 4/8] iio: temperature: ltc2983: Use fwnode_property_present() for optional properties Liviu Stan
2026-06-02 23:23   ` Andy Shevchenko
2026-05-21 16:42 ` [PATCH v3 5/8] iio: temperature: ltc2983: Fix n_wires default bypassing rotation check Liviu Stan
2026-05-22 13:06   ` Jonathan Cameron
2026-05-21 16:42 ` [PATCH v3 6/8] iio: core: Add IIO_COVERAGE channel type Liviu Stan
2026-05-21 18:10   ` sashiko-bot
2026-05-22  9:57   ` Stan, Liviu
2026-05-21 16:43 ` [PATCH v3 7/8] dt-bindings: iio: temperature: Add ADT7604 support to adi,ltc2983 Liviu Stan
2026-05-21 18:23   ` sashiko-bot
2026-05-22 11:42     ` Liviu Stan
2026-05-22 13:17       ` Jonathan Cameron
2026-05-21 16:43 ` [PATCH v3 8/8] iio: temperature: ltc2983: Add support for ADT7604 Liviu Stan
2026-05-21 19:18   ` sashiko-bot [this message]
2026-05-22 13:23     ` Liviu Stan
2026-05-22 14:09       ` David Lechner
2026-05-22 13:34   ` Jonathan Cameron
2026-05-22 14:24     ` Stan, Liviu
2026-05-22 17:31       ` Jonathan Cameron

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=20260521191828.F20931F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=liviu.stan@analog.com \
    --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