From: sashiko-bot@kernel.org
To: "Marcelo Schmitt" <marcelo.schmitt@analog.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v4 05/13] iio: adc: ad4134: Run shorter transfers when CRC is disabled
Date: Tue, 06 Oct 2026 18:32:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-162348@kernel.org> (raw)
In-Reply-To: <e46fd2f9b11ff2b690483bc2ea6489b6d145c773.1791309733.git.marcelo.schmitt@analog.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] iio: adc: ad4134: broken SPI read CRC calculation and ignored failures
- [Medium] iio: adc: missing delay after reset deassertion in probe
--
commit 5284b96efc125640c497213951d3fabe580894ec
Author: Marcelo Schmitt <marcelo.schmitt@analog.com>
iio: adc: ad4134: Run shorter transfers when CRC is disabled
This commit conditionally reduces the SPI transfer length when the AD4134
CRC feature is disabled. It introduces a crc_en flag in the driver state
to skip the CRC validation check and send fewer bytes when CRC is inactive.
> diff --git a/drivers/iio/adc/ad4134.c b/drivers/iio/adc/ad4134.c
> index a0113fff4b715..85fa16321d744 100644
> --- a/drivers/iio/adc/ad4134.c
> +++ b/drivers/iio/adc/ad4134.c
[ ... ]
> @@ -232,7 +233,7 @@ static int ad4134_register_read(struct ad4134_state *st, unsigned int reg,
> *val = st->rx_buf[1];
>
> /* Check CRC */
> - if (st->rx_buf[2] != st->tx_buf[2])
> + if (st->crc_en && st->rx_buf[2] != st->tx_buf[2])
> dev_dbg(&st->spi->dev, "reg read CRC check failed\n");
>
> return 0;
[Severity: Medium]
Does this CRC validation logic reliably verify the read data?
In ad4134_register_read(), the master's CRC (st->tx_buf[2]) is computed using
the command byte and a dummy payload (0x00). However, the slave returns its CRC
(st->rx_buf[2]) computed over the command byte and the actual register value
being read (st->rx_buf[1]). Comparing st->rx_buf[2] != st->tx_buf[2] will
spuriously fail for any read where the register value is non-zero.
Additionally, both the read and write paths merely log a dev_dbg() message on
CRC mismatch and return success (0) instead of returning an error code (such
as -EIO). Can this allow corrupted data to be used by the caller, rendering
the CRC feature ineffective for data integrity?
[ ... ]
> @@ -313,6 +314,7 @@ static int ad4134_min_io_mode_setup(struct ad4134_state *st)
> struct device *dev = &st->spi->dev;
> int ret;
>
> + st->crc_en = true; /* In minimum I/O mode CRC cannot be disabled */
> st->odr_gpio = devm_gpiod_get(dev, "odr", GPIOD_OUT_LOW);
[Severity: Medium]
Does the AD4134 device require a stabilization delay before interacting with it
over SPI?
In ad4134_probe(), devm_reset_control_get_optional_exclusive_deasserted() is
called to deassert the reset line. Execution then proceeds directly to regmap
initialization and SPI transfers without any hardware stabilization delay:
rst = devm_reset_control_get_optional_exclusive_deasserted(dev, NULL);
if (IS_ERR(rst))
return dev_err_probe(dev, PTR_ERR(rst),
"failed to get and deassert reset\n");
crc8_populate_msb(ad4134_spi_crc_table, AD4134_SPI_CRC_POLYNOM);
ret = devm_mutex_init(dev, &st->sync_lock);
if (ret)
return ret;
st->regmap = devm_regmap_init(dev, NULL, st, &ad4134_regmap_config);
Without a delay, could the first SPI transactions during probe drop or return
invalid data, causing initialization to fail?
The driver defines AD4134_RESET_TIME_US as 10 seconds (10 * USEC_PER_SEC) but
never uses it to invoke any sleep function.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1791309733.git.marcelo.schmitt@analog.com?part=5
next prev parent reply other threads:[~2026-10-06 18:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 18:15 [PATCH v4 00/13] iio: adc: ad4134: Enable greater sample rate data capture Marcelo Schmitt
2026-10-06 18:16 ` [PATCH v4 01/13] iio: adc: ad4134: Adjust register map range Marcelo Schmitt
2026-10-06 18:16 ` [PATCH v4 02/13] iio: adc: ad4134: Sign extend sample data Marcelo Schmitt
2026-10-06 18:32 ` sashiko-bot
2026-10-06 18:16 ` [PATCH v4 03/13] iio: adc: ad4134: Update include list to comply with IWYU principles Marcelo Schmitt
2026-10-06 18:17 ` [PATCH v4 04/13] iio: adc: ad4134: Serialize single-read operations Marcelo Schmitt
2026-10-06 18:17 ` [PATCH v4 05/13] iio: adc: ad4134: Run shorter transfers when CRC is disabled Marcelo Schmitt
2026-10-06 18:32 ` sashiko-bot [this message]
2026-10-06 18:17 ` [PATCH v4 06/13] iio: adc: ad4134: Add support for digital filter type selection Marcelo Schmitt
2026-10-06 18:17 ` [PATCH v4 07/13] iio: adc: ad4134: Support buffered data read Marcelo Schmitt
2026-10-06 18:36 ` sashiko-bot
2026-10-06 18:18 ` [PATCH v4 08/13] dt-bindings: iio: adc: adi,ad4134: Document SPI connection mode Marcelo Schmitt
2026-10-06 18:29 ` sashiko-bot
2026-10-07 10:14 ` Conor Dooley
2026-10-06 18:18 ` [PATCH v4 09/13] dt-bindings: iio: adc: adi,ad4134: Document external multiplexer usage Marcelo Schmitt
2026-10-06 18:32 ` sashiko-bot
2026-10-06 18:19 ` [PATCH v4 10/13] iio: adc: ad4134: Support SPI 4-wire mode Marcelo Schmitt
2026-10-06 18:35 ` sashiko-bot
2026-10-06 18:19 ` [PATCH v4 11/13] dt-bindings: iio: adc: adi,ad4134: Document PWM usage Marcelo Schmitt
2026-10-06 18:27 ` sashiko-bot
2026-10-06 18:19 ` [PATCH v4 12/13] iio: adc: ad4134: Support high-speed data capture Marcelo Schmitt
2026-10-06 18:35 ` sashiko-bot
2026-10-06 18:19 ` [PATCH v4 13/13] Docs: iio: Add AD4134 Marcelo Schmitt
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-162348@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=marcelo.schmitt@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