From: sashiko-bot@kernel.org
To: "Jakub Szczudlo" <jakubszczudlo40@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v5 2/3] dt-bindings: iio: adc: ti,ads1100: add support for ADS1110
Date: Sun, 28 Jun 2026 19:54:34 +0000 [thread overview]
Message-ID: <20260628195435.7480D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260628194341.66752-3-jakubszczudlo40@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The `ads1100_set_data_rate` function ignores the requested data rate and unconditionally applies the first entry.
- [High] `ads1100_poll_data_ready` uses an inverted break condition for polling, causing it to exit immediately when the device is busy.
--
commit 94cd92aafbd37136e109b12cbe69b760dcdb10a5
Author: Jakub Szczudlo <jakubszczudlo40@gmail.com>
iio: adc: Fix incorrect reading when datarate changed in single mode
This commit addresses an issue where changing the datarate in single mode
while the device is suspended does not wait for a new measurement. Functions
modifying datarate and gain are updated to wait for new data.
> diff --git a/drivers/iio/adc/ti-ads1100.c b/drivers/iio/adc/ti-ads1100.c
> index 9fe8d54cce83c..71b31adeba3c6 100644
> --- a/drivers/iio/adc/ti-ads1100.c
> +++ b/drivers/iio/adc/ti-ads1100.c
[ ... ]
> @@ -123,10 +128,46 @@ static int ads1100_get_adc_result(struct ads1100_data *data, int chan, int *val)
> return 0;
> }
>
> +static bool ads1100_new_data_not_ready(struct ads1100_data *data)
> +{
> + u8 buffer[3];
> + int ret;
> +
> + ret = i2c_master_recv(data->client, buffer, sizeof(buffer));
> + if (ret < 0) {
> + dev_err(&data->client->dev, "I2C read fail: %d\n", ret);
> + return true;
> + }
> +
> + return FIELD_GET(ADS1100_CFG_ST_BSY, buffer[2]);
> +}
> +
> +static int ads1100_poll_data_ready(struct ads1100_data *data)
> +{
> + int data_rate_hz = ads1100_data_rate[FIELD_GET(ADS1100_DR_MASK, data->config)];
> + /* To be sure we wait 5 times more than data rate */
> + unsigned long wait_time_us = DIV_ROUND_CLOSEST(USEC_PER_SEC, 5 * data_rate_hz);
> + bool data_ready;
> + u8 buffer[3];
> + int ret;
> +
> + /* To be sure that polled value will have value after config change */
> + ret = i2c_master_recv(data->client, buffer, sizeof(buffer));
> + if (ret < 0) {
> + dev_err(&data->client->dev, "I2C read fail: %d\n", ret);
> + return ret;
> + }
> +
> + return readx_poll_timeout(ads1100_new_data_not_ready, data,
> + data_ready, data_ready != 0, wait_time_us,
> + ADS1100_MAX_DRDY_TIMEOUT_US);
[Severity: High]
Does this use an inverted break condition for polling?
When ads1100_new_data_not_ready() is called, it returns 1 if the device
is busy. The readx_poll_timeout() macro assigns this to data_ready and
evaluates data_ready != 0 to determine if it should break out of the loop.
Since the condition is data_ready != 0, the loop will exit immediately when
the device is busy, rather than waiting for the device to become ready.
> +}
[ ... ]
> @@ -149,19 +195,31 @@ static int ads1100_set_scale(struct ads1100_data *data, int val, int val2)
>
> ads1100_set_config_bits(data, ADS1100_PGA_MASK, ffs(gain) - 1);
>
> - return 0;
> + return ads1100_poll_data_ready(data);
> }
>
> static int ads1100_set_data_rate(struct ads1100_data *data, int chan, int rate)
> {
> unsigned int i;
> unsigned int size;
> + int ret;
>
> size = data->supports_data_rate ? ARRAY_SIZE(ads1100_data_rate) : 1;
> for (i = 0; i < size; i++) {
> - if (ads1100_data_rate[i] == rate)
> - return ads1100_set_config_bits(data, ADS1100_DR_MASK,
> - FIELD_PREP(ADS1100_DR_MASK, i));
> + if (i == size)
> + return -EINVAL;
> +
> + PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(&data->client->dev, pm);
> + ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
> + if (ret)
> + return ret;
> +
> + ret = ads1100_set_config_bits(data, ADS1100_DR_MASK,
> + FIELD_PREP(ADS1100_DR_MASK, i));
[Severity: High]
Will this ignore the requested data rate and unconditionally apply the first
entry?
The previous check against the user's requested rate:
if (ads1100_data_rate[i] == rate)
was removed.
As a result, on the very first iteration (i = 0), this configures the device
to the first available data rate and immediately returns, ignoring the value
the user actually requested.
> + if (ret)
> + return ret;
> +
> + return ads1100_poll_data_ready(data);
> }
>
> return -EINVAL;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260628194341.66752-1-jakubszczudlo40@gmail.com?part=2
next prev parent reply other threads:[~2026-06-28 19:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-28 19:43 [PATCH v5 0/3] iio: adc: Add support for TI ADS1110 to ti-ads1100 driver Jakub Szczudlo
2026-06-28 19:43 ` [PATCH v5 1/3] iio: adc: Fix incorrect reading when datarate changed in single mode Jakub Szczudlo
2026-06-28 19:57 ` sashiko-bot
2026-06-28 19:43 ` [PATCH v5 2/3] dt-bindings: iio: adc: ti,ads1100: add support for ADS1110 Jakub Szczudlo
2026-06-28 19:54 ` sashiko-bot [this message]
2026-06-28 19:43 ` [PATCH v5 3/3] iio: adc: Add ti-ads1110 support to ti-ads1100 driver Jakub Szczudlo
2026-06-28 19:57 ` 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=20260628195435.7480D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jakubszczudlo40@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox