From: Stephan Costa Barros <stephanbrrs8@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Mike Looijmans" <mike.looijmans@topic.nl>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/6] iio: adc: ti-ads1298: fix the data read path
Date: Tue, 27 Oct 2026 23:39:51 -0300 [thread overview]
Message-ID: <20261028023951.33149-1-stephanbrrs8@gmail.com> (raw)
In-Reply-To: <at5jL47A-6vQJYOX@ashevche-desk.local>
On Sun, Oct 25, 2026 at 10:14:39PM +0200, Andy Shevchenko wrote:
> > + /* Only changes while no transfer is in flight */
> > + scoped_guard(spinlock_irqsave, &priv->irq_busy_lock)
> > + buffered = priv->buffered;
>
> Strictly speaking you need to assign buffered to make any compiler not being
> confused by the scoped_guard(), which cases IIRC we used to have the past.
OK, I'll initialise it.
> > + ret = ads1298_write_cmd(priv, ADS1298_CMD_START);
> > + if (ret) {
> > + scoped_guard(spinlock_irqsave, &priv->irq_busy_lock)
> > + priv->buffered = false;
> > + }
> > +
> > + return ret;
>
> Before write_cmd is called the buffered might have been triggered. Is it okay?
Yes, and on purpose. By postenable the core has set up the scan mask and
the buffer, so a sample arriving before START is pushed like any other.
The chip does not convert before START anyway, unless its START pin is
tied high. The other order is the problem: a DRDY between START and
setting the flag would be taken as a single-shot read.
> > + scoped_guard(spinlock_irqsave, &priv->irq_busy_lock)
> > + priv->buffered = false;
> > +
> > + return ret ?: ret2;
> > }
>
> The code lacks of comments on why in all error cases (either first one, or
> second, or both are triggered) it's fine to continue. And what will be the
> meaning of the returned value in all three cases?
The core goes on with the teardown whatever predisable returns
(iio_disable_buffers() says so), so the driver must stop using the scan
in every case. The return value only reaches whoever wrote to
buffer/enable, and it is the first error.
If STOP fails, the chip may keep converting, but once the flag is clear
the completions leave the scan alone. In v2 the flag was cleared only
after the wait, which was wrong, v3 clears it right after STOP. If the
wait times out, a completion that already saw the flag set could still
be pushing. The SPI core completes every message, so I'm inclined to
wait without a limit there, as on unbind, and return only the STOP error.
I'll put that in a comment. Jonathan asked to rework this part, so the
code may change, but the explanation stays.
Thanks,
Stephan
next prev parent reply other threads:[~2026-10-28 2:40 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 23:13 [PATCH v2 0/6] iio: adc: ti-ads1298: fixes, and ADS1299 support Stephan Costa Barros
2026-10-24 23:13 ` [PATCH v2 1/6] iio: adc: ti-ads1298: fix the data read path Stephan Costa Barros
2026-10-25 20:14 ` Andy Shevchenko
2026-10-28 2:39 ` Stephan Costa Barros [this message]
2026-10-25 23:06 ` Jonathan Cameron
2026-10-28 2:19 ` Stephan Costa Barros
2026-10-24 23:13 ` [PATCH v2 2/6] iio: adc: ti-ads1298: fix power-up and clock handling Stephan Costa Barros
2026-10-25 20:18 ` Andy Shevchenko
2026-10-25 23:07 ` Jonathan Cameron
2026-10-26 6:27 ` Mike Looijmans
2026-10-28 2:19 ` Stephan Costa Barros
2026-10-28 6:47 ` Mike Looijmans
2026-10-24 23:13 ` [PATCH v2 3/6] iio: adc: ti-ads1298: fix scale, ID check, regmap and Kconfig Stephan Costa Barros
2026-10-25 23:12 ` Jonathan Cameron
2026-10-24 23:13 ` [PATCH v2 4/6] iio: adc: ti-ads1298: prepare for more chip families Stephan Costa Barros
2026-10-25 20:27 ` Andy Shevchenko
2026-10-28 2:22 ` Stephan Costa Barros
2026-10-25 23:26 ` Jonathan Cameron
2026-10-28 2:22 ` Stephan Costa Barros
2026-10-24 23:13 ` [PATCH v2 5/6] dt-bindings: iio: adc: ti,ads1298: add ADS1299 Stephan Costa Barros
2026-10-27 8:04 ` Krzysztof Kozlowski
2026-10-24 23:13 ` [PATCH v2 6/6] iio: adc: ti-ads1298: add ADS1299 support Stephan Costa Barros
2026-10-25 20:34 ` Andy Shevchenko
2026-10-28 2:30 ` Stephan Costa Barros
2026-10-25 23:34 ` Jonathan Cameron
2026-10-28 2:26 ` Stephan Costa Barros
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=20261028023951.33149-1-stephanbrrs8@gmail.com \
--to=stephanbrrs8@gmail.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.looijmans@topic.nl \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/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
all inboxes | Powered by JetHome®