From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: ilyas.nhasse@skf.com
Cc: "Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
linux@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: adc: ad_sigma_delta: support devices without RDY interrupt
Date: Fri, 20 Nov 2026 14:24:11 +0200 [thread overview]
Message-ID: <awA769JyWRvSG8PY@ashevche-desk.local> (raw)
In-Reply-To: <20261120-ad7124-no-irq-v1-2-7826c5c3fd25@skf.com>
On Fri, Nov 20, 2026 at 12:26:48PM +0100, ILYAS NHASSE via B4 Relay wrote:
>
> The end of a conversion or of a calibration is detected with the DOUT/RDY
> interrupt, so a device whose DOUT/RDY pin is only wired to the SPI MISO
> line can't be used, although its status register reports the same event
> in its RDY bit.
>
> For devices with registers but without interrupt, wait for RDY in
> ad_sigma_delta_single_conversion() and ad_sd_calibrate() by polling the
> status register, with the same timeouts as the interrupt-driven waits.
> As with the interrupt, the bus stays locked and CS asserted during the
> wait, and ad_sigma_delta_clear_pending_event() has drained any older
> result beforehand, so the RDY bit seen by the poll belongs to the
> operation just started. A timeout is reported as -ETIMEDOUT.
>
> The RDY interrupt is the only trigger source of the triggered buffer, so
> devm_ad_sd_setup_buffer_and_trigger() sets nothing up for these devices
> and they only support direct mode. Registerless devices still require
> the interrupt.
>
> Each poll is a SPI transfer, so poll every 20 ms: this delays the
> detection of the end of a conversion by at most one period, a fifth of
> a conversion at the AD7124 default output data rate of 10 SPS, while
> keeping the bus traffic, and the CPU time of PIO SPI transfers, low.
...
> +#define AD_SD_POLL_PERIOD_US (20 * USEC_PER_MSEC)
The multiplier is defined beneath time.h. Is it included?
...
> +static int ad_sd_poll_rdy(struct ad_sigma_delta *sigma_delta,
> + unsigned int timeout_us)
> +{
> + unsigned int status;
> + int ret, ret_read;
ret_read --> err
It's visible in the code what it's for.
> + ret = read_poll_timeout(ad_sd_read_reg, ret_read,
> + ret_read || !(status & AD_SD_REG_STATUS_RDY),
> + AD_SD_POLL_PERIOD_US, timeout_us, false,
> + sigma_delta, AD_SD_REG_STATUS, 1, &status);
With that, wrap on a logical boundary.
ret = read_poll_timeout(ad_sd_read_reg,
err, err || !(status & AD_SD_REG_STATUS_RDY),
AD_SD_POLL_PERIOD_US, timeout_us, false,
sigma_delta, AD_SD_REG_STATUS, 1, &status);
> + if (ret)
> + return ret;
> +
> + return ret_read;
> +}
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-11-20 12:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 11:26 [PATCH 0/2] iio: adc: ad7124: support boards without RDY interrupt ILYAS NHASSE via B4 Relay
2026-11-20 11:26 ` [PATCH 1/2] dt-bindings: iio: adc: adi,ad7124: make interrupts optional ILYAS NHASSE via B4 Relay
2026-11-20 17:46 ` Conor Dooley
2026-11-20 11:26 ` [PATCH 2/2] iio: adc: ad_sigma_delta: support devices without RDY interrupt ILYAS NHASSE via B4 Relay
2026-11-20 11:45 ` sashiko-bot
2026-11-20 12:24 ` Andy Shevchenko [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=awA769JyWRvSG8PY@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=ilyas.nhasse@skf.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=marcelo.schmitt@analog.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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