From: sashiko-bot@kernel.org
To: "Kyle Hsieh" <kylehsieh1995@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 2/2] iio: adc: ti-ads112c04: Add support for TI ADS112C04
Date: Wed, 05 Aug 2026 05:49:14 +0000 [thread overview]
Message-ID: <20260805054915.D3FE91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-ti-ads112c04-driver-v3-2-49f436829e01@gmail.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Incorrect byte swapping for 16-bit I2C word read causes data corruption on Big-Endian architectures.
- [High] The hardirq handler does not mask the interrupt or clear the hardware interrupt source, leading to an infinite interrupt storm if a level-triggered IRQ is used.
- [Medium] The commit message falsely claims support for dynamic reference voltage scaling via `refn-supply`.
- [Medium] A delayed hardware interrupt from a previously timed-out conversion can prematurely complete the wait for a new conversion, causing a read of stale data.
--
--- Patch [2]: [PATCH v3 2/2] iio: adc: ti-ads112c04: Add support for TI ADS112C04 ---
commit bffeb9c9d9c618f12635f25aeb7cd1053228824c
Author: Kyle Hsieh <kylehsieh1995@gmail.com>
iio: adc: ti-ads112c04: Add support for TI ADS112C04
Add IIO driver support for the Texas Instruments ADS112C04 (16-bit)
delta-sigma ADCs.
> - Single-shot conversions using the IIO raw read interface.
> - Dynamic parsing of single-ended and differential channels from
> device tree child nodes.
> - Hardware interrupt support via the DRDY pin, falling back to
> software polling if no IRQ is provided.
> - Scale calculation based on the internal 2.048V reference.
> - Dynamic reference voltage scaling via the regulator subsystem
> (refp-supply/refn-supply), falling back to the internal 2.048V
[Severity: Medium]
The commit message mentions support for refn-supply, but does the code
actually support it?
Looking at ads112c04_probe(), it seems to explicitly reject refn-supply:
if (device_property_present(dev, "refn-supply") ||
device_property_present(dev, "ti,refp-refn-resistor-ohms"))
return dev_err_probe(dev, -EOPNOTSUPP,
"refn-supply and external resistors are not supported yet\n");
Could the commit message be updated to align with the implementation?
> reference if not specified.
> - Hardware reset fallback using GPIO.
>
> Signed-off-by: Kyle Hsieh <kylehsieh1995@gmail.com>
[ ... ]
> diff --git a/drivers/iio/adc/ti-ads112c04.c b/drivers/iio/adc/ti-ads112c04.c
> new file mode 100644
> index 0000000000000..64af866f615de
> --- /dev/null
> +++ b/drivers/iio/adc/ti-ads112c04.c
[ ... ]
> +static int ads112c04_read_data(struct ads112c04_state *st, int *val)
> +{
> + int ret;
> +
> + ret = i2c_smbus_read_word_data(st->client, ADS112C04_CMD_RDATA);
> + if (ret < 0)
> + return ret;
> +
> + *val = sign_extend32(be16_to_cpu(ret), 15);
[Severity: High]
Does this byte swapping work correctly on big-endian architectures?
i2c_smbus_read_word_data() returns the word already converted to host
endianness based on SMBus little-endian rules. If the device sends
big-endian data, using be16_to_cpu() on the result of
i2c_smbus_read_word_data() can cause data corruption on big-endian systems.
> +
> + return 0;
> +}
> +
> +static int ads112c04_get_adc_result(struct ads112c04_state *st,
> + struct iio_chan_spec const *chan,
> + int *val)
> +{
> + u8 new_config0;
> + int ret;
> +
> + new_config0 = st->config0 & ~ADS112C04_CONFIG0_MUX;
> + new_config0 |= FIELD_PREP(ADS112C04_CONFIG0_MUX, chan->address);
> +
> + if (st->config0 != new_config0) {
> + ret = ads112c04_write_reg(st->client, ADS112C04_REG_CONFIG0, new_config0);
> + if (ret < 0)
> + return ret;
> + st->config0 = new_config0;
> + }
> +
> + reinit_completion(&st->completion);
> +
> + ret = ads112c04_write_cmd(st->client, ADS112C04_CMD_START_SYNC);
> + if (ret < 0)
> + return ret;
> +
> + ret = ads112c04_wait_for_data(st);
[Severity: Medium]
Is there a race condition here if a previous conversion timed out?
If a previous read timed out but the hardware conversion was still running,
a delayed interrupt from that previous conversion could fire immediately after
reinit_completion() is called.
Would this cause ads112c04_wait_for_data() to return prematurely and read
stale data?
> + if (ret < 0)
> + return ret;
> +
> + return ads112c04_read_data(st, val);
> +}
[ ... ]
> +static irqreturn_t ads112c04_irq_handler(int irq, void *private)
> +{
> + struct iio_dev *indio_dev = private;
> + struct ads112c04_state *st = iio_priv(indio_dev);
> +
> + complete(&st->completion);
> +
> + return IRQ_HANDLED;
> +}
[Severity: High]
If the device tree configures this interrupt as level-triggered, could this
handler cause an interrupt storm?
The hardirq handler completes the wait but returns IRQ_HANDLED without
masking the interrupt line or clearing the hardware interrupt source.
Since devm_request_irq() is called in ads112c04_probe() with irqflags=0,
it allows level-triggered configurations from the device tree which would
continually fire until the data is read.
Should this use a threaded interrupt, or mask the IRQ until the data is read?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-ti-ads112c04-driver-v3-0-49f436829e01@gmail.com?part=2
next prev parent reply other threads:[~2026-08-05 5:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 5:38 [PATCH v3 0/2] iio: adc: Add support for Texas Instruments ADS112C04 Kyle Hsieh
2026-08-05 5:38 ` [PATCH v3 1/2] dt-bindings: iio: adc: ti,ads112c04: Add binding for ADS112C04 Kyle Hsieh
2026-08-05 5:50 ` sashiko-bot
2026-08-05 6:24 ` Rob Herring (Arm)
2026-08-07 20:15 ` David Lechner
2026-08-07 20:23 ` David Lechner
2026-08-05 5:38 ` [PATCH v3 2/2] iio: adc: ti-ads112c04: Add support for TI ADS112C04 Kyle Hsieh
2026-08-05 5:49 ` sashiko-bot [this message]
2026-08-07 21:01 ` David Lechner
2026-08-05 6:43 ` [PATCH v3 0/2] iio: adc: Add support for Texas Instruments ADS112C04 Krzysztof Kozlowski
2026-08-05 6:46 ` Krzysztof Kozlowski
2026-08-05 7:44 ` Kyle Hsieh
2026-08-07 20:28 ` David Lechner
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=20260805054915.D3FE91F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kylehsieh1995@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.