From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: "Nuno Sá" <nuno.sa@analog.com>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux@analog.com, jic23@kernel.org,
dlechner@baylibre.com, andy@kernel.org,
Michael.Hennerich@analog.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, corbet@lwn.net,
skhan@linuxfoundation.org
Subject: Re: [PATCH v4 10/13] iio: adc: ad4134: Support SPI 4-wire mode
Date: Fri, 16 Oct 2026 21:57:02 -0300 [thread overview]
Message-ID: <atLH3iWLXQqyctu7@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <179199692830.658576.14049229425648931434.b4-review@b4>
On 10/14, Nuno Sá wrote:
> On Tue, 06 Oct 2026 15:19:00 -0300, Marcelo Schmitt <marcelo.schmitt@analog.com> wrote:
> > diff --git a/drivers/iio/adc/ad4134.c b/drivers/iio/adc/ad4134.c
> > index b5207f16054e..debc2ff02705 100644
> > --- a/drivers/iio/adc/ad4134.c
> > +++ b/drivers/iio/adc/ad4134.c
> > @@ -308,14 +423,18 @@ static int ad4134_register_read(struct ad4134_state *st, unsigned int reg,
> > .len = st->crc_en ? AD4134_SPI_MAX_XFER_LEN : 2,
> > };
> > unsigned int inst;
> > - int ret;
> > + int access_ret, ret;
> > +
> > + ret = ad4134_claim_reg_access(st);
> > + if (ret)
> > + return ret;
>
> Do we really need to claim/release for every register read? Can't we
> just select register mode at probe and leave it in that position by
> default?
Yeah, we could have it that way but then the error paths get trickier to handle.
For example, we might deselect reg mode and then fail to select sample mode.
Because of that, we would need to keep track of what mux_states we hold lock to
avoid deselecting a state that is not selected.
After sample read, we are susceptible to succeed sample mode deselect and fail
reg mode select, so we actually also need to check we have reg mode selected
before register access anyway.
Not to mention we would need a driver .remove callback to check which (if any)
mode we have selected to correctly deselect any multiplexer state on driver detach.
> Then when starting to buffer, we deselect + select sample mode
> and when exiting do the reverse. Seems even more appropriate when the dt
> mode property does not want to use DOUT at all which means that all this
> select + deselect is really unneeded.
>
The select/deselect dance is not needed for minimum I/O mode (no CS wiring) so
I made it skip the multiplexer switching entirely for that mode.
Thanks,
Marcelo
next prev parent reply other threads:[~2026-10-17 0:55 UTC|newest]
Thread overview: 32+ 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-14 16:55 ` Nuno Sá
2026-10-06 18:16 ` [PATCH v4 02/13] iio: adc: ad4134: Sign extend sample data Marcelo Schmitt
[not found] ` <sashiko-outbox-162349@kernel.org>
2026-10-13 20:52 ` Marcelo Schmitt
2026-10-14 16:55 ` Nuno Sá
2026-10-06 18:16 ` [PATCH v4 03/13] iio: adc: ad4134: Update include list to comply with IWYU principles Marcelo Schmitt
2026-10-14 16:55 ` Nuno Sá
2026-10-06 18:17 ` [PATCH v4 04/13] iio: adc: ad4134: Serialize single-read operations Marcelo Schmitt
2026-10-14 16:55 ` Nuno Sá
2026-10-06 18:17 ` [PATCH v4 05/13] iio: adc: ad4134: Run shorter transfers when CRC is disabled Marcelo Schmitt
[not found] ` <sashiko-outbox-162348@kernel.org>
2026-10-13 20:56 ` Marcelo Schmitt
2026-10-14 16:00 ` Nuno Sá
2026-10-14 16:55 ` Nuno Sá
2026-10-06 18:17 ` [PATCH v4 06/13] iio: adc: ad4134: Add support for digital filter type selection Marcelo Schmitt
2026-10-14 16:55 ` Nuno Sá
2026-10-06 18:17 ` [PATCH v4 07/13] iio: adc: ad4134: Support buffered data read Marcelo Schmitt
2026-10-13 7:20 ` Andy Shevchenko
2026-10-13 21:14 ` Marcelo Schmitt
2026-10-14 16:55 ` Nuno Sá
2026-10-06 18:18 ` [PATCH v4 08/13] dt-bindings: iio: adc: adi,ad4134: Document SPI connection mode Marcelo Schmitt
2026-10-07 10:14 ` Conor Dooley
[not found] ` <sashiko-outbox-162344@kernel.org>
2026-10-13 21:06 ` Marcelo Schmitt
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:19 ` [PATCH v4 10/13] iio: adc: ad4134: Support SPI 4-wire mode Marcelo Schmitt
[not found] ` <sashiko-outbox-162354@kernel.org>
2026-10-13 21:10 ` Marcelo Schmitt
2026-10-14 16:57 ` Nuno Sá
2026-10-14 16:55 ` Nuno Sá
2026-10-17 0:57 ` Marcelo Schmitt [this message]
2026-10-06 18:19 ` [PATCH v4 11/13] dt-bindings: iio: adc: adi,ad4134: Document PWM usage Marcelo Schmitt
2026-10-06 18:19 ` [PATCH v4 12/13] iio: adc: ad4134: Support high-speed data capture Marcelo Schmitt
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=atLH3iWLXQqyctu7@debian-BULLSEYE-live-builder-AMD64 \
--to=marcelo.schmitt1@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.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 \
--cc=skhan@linuxfoundation.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
all inboxes | Powered by JetHome®