From: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
jic23@kernel.org, nuno.sa@analog.com, dlechner@baylibre.com,
andy@kernel.org, Michael.Hennerich@analog.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, corbet@lwn.net
Subject: Re: [PATCH v3 2/3] iio: adc: Initial support for AD4134
Date: Thu, 4 Dec 2025 11:58:34 -0300 [thread overview]
Message-ID: <aTGhmgsRmphZY92X@debian-BULLSEYE-live-builder-AMD64> (raw)
In-Reply-To: <CAHp75Vf7p=aPy2ofC_zVz1PURA3R9i0WZCG63-dCEXO=xKJ0FA@mail.gmail.com>
On 12/02, Andy Shevchenko wrote:
> On Tue, Dec 2, 2025 at 10:55 PM Marcelo Schmitt
> <marcelo.schmitt@analog.com> wrote:
> >
> > AD4134 is a 24-bit, 4-channel, simultaneous sampling, precision
> > analog-to-digital converter (ADC). The device can be managed through SPI or
> > direct control of pin logical levels (pin control mode). The AD4134 design
> > also features a dedicated bus for ADC sample data output. Though, this
> > initial driver for AD4134 only supports usual SPI connections.
> >
> > Add basic support for AD4134 that enables single-shot ADC sample read.
>
...
>
> Bart converted it to be an aux driver and it should work. Please, give
> a try after v6.19-rc1 is out.
>
Ok, from yesterday's disscussion I see I should give rest framework another try.
For now, I'll rebase on top of linux-next to experiment with the new reset gpio aux device.
...
>
> > + * interface. Now we read data from all channels but keep only the bits
> > + * from the requested one.
> > + */
> > + for (i = 0; i < ARRAY_SIZE(ad4134_chan_set); i++) {
> > + ret = spi_write_then_read(st->spi, NULL, 0, st->rx_buf,
> > + BITS_TO_BYTES(AD4134_CHAN_PRECISION_BITS));
> > + if (ret)
> > + return ret;
> > +
> > + if (i != AD4134_VREG_CH(reg))
> > + continue;
> > + *val = get_unaligned_be24(st->rx_buf);
>
> Hmm...
>
> In this case it might be better to use
>
> if (i == ...)
> *val = ...
>
> but it's still unclear on how many times the conditional can be true
> in the loop.
The if != ... condition was true on three iterations of the loop and false
in only one iteration. Updated to if (i == ...), the conditional is now true
only on one iteration.
The AD4134 has a built-in feature that flags when data trasnfers don't run
enough clock cycles to read the entire data frame (i.e. the data from all 4
channels in this case).
Since this is not expected to be a time critical method for acquiring data,
I coded it to avoid that error flag. I added a comment about that for v4.
Thanks,
Marcelo
next prev parent reply other threads:[~2025-12-04 14:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 20:54 [PATCH v3 0/3] iio: adc: Add AD4134 minimum I/O support Marcelo Schmitt
2025-12-02 20:55 ` [PATCH v3 1/3] dt-bindings: iio: adc: Add AD4134 Marcelo Schmitt
2025-12-05 7:52 ` Tomas Melin
2025-12-05 12:50 ` Marcelo Schmitt
2025-12-07 13:13 ` Jonathan Cameron
2025-12-07 13:22 ` Jonathan Cameron
2025-12-02 20:55 ` [PATCH v3 2/3] iio: adc: Initial support for AD4134 Marcelo Schmitt
2025-12-02 21:26 ` Andy Shevchenko
2025-12-03 11:02 ` Nuno Sá
2025-12-03 12:59 ` Andy Shevchenko
2025-12-03 14:48 ` Nuno Sá
2025-12-03 14:56 ` Andy Shevchenko
2025-12-04 14:58 ` Marcelo Schmitt [this message]
2025-12-07 13:41 ` Jonathan Cameron
2025-12-02 20:55 ` [PATCH v3 3/3] Docs: iio: Add AD4134 Marcelo Schmitt
2025-12-03 11:57 ` Tomas Melin
2025-12-04 15:32 ` Marcelo Schmitt
2025-12-05 7:58 ` Tomas Melin
2025-12-05 12:32 ` Marcelo Schmitt
2025-12-07 13:28 ` Jonathan Cameron
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=aTGhmgsRmphZY92X@debian-BULLSEYE-live-builder-AMD64 \
--to=marcelo.schmitt1@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy.shevchenko@gmail.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-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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