From: Andy Shevchenko <andy@kernel.org>
To: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Cc: Marcelo Schmitt <marcelo.schmitt@analog.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Ana-Maria Cusco <ana-maria.cusco@analog.com>,
jic23@kernel.org, lars@metafoo.de, Michael.Hennerich@analog.com,
dlechner@baylibre.com, nuno.sa@analog.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org,
linus.walleij@linaro.org, brgl@bgdev.pl
Subject: Re: [PATCH v4 02/11] iio: adc: Add basic support for AD4170
Date: Tue, 3 Jun 2025 11:27:05 +0300 [thread overview]
Message-ID: <aD6x2caTMd1eBInM@smile.fi.intel.com> (raw)
In-Reply-To: <aD3XQfUfxIiz62ZU@debian-BULLSEYE-live-builder-AMD64>
On Mon, Jun 02, 2025 at 01:54:25PM -0300, Marcelo Schmitt wrote:
...
> > > +static bool ad4170_setup_eq(struct ad4170_setup *a, struct ad4170_setup *b)
> > > +{
> > > + /*
> > > + * The use of static_assert() here is to make sure that the comparison
> > > + * is adapted whenever struct ad4170_setup is changed.
> > > + */
> > > + static_assert(sizeof(*a) ==
> > > + sizeof(struct {
> > > + u16 misc;
> > > + u16 afe;
> > > + u16 filter;
> > > + u16 filter_fs;
> > > + u32 offset;
> > > + u32 gain;
> > > + }));
> >
> > I think it doesn't make much sense unless one uses memcpy().
>
> memcpy() is used to update the setups after reg write succeeds.
> Also, previously, memcmp() was used to compare setups.
> Since struct ad4170_setup has only unsigned integers (no floating point fields
> like ad7124 had [1]), ad4170 works properly when comparing setups with memcmp().
> Though, it was asked to do explicit field matching on previous reviews [2] so
> that's how it had been since then. Well, both ways work for ad4170. We can
> compare setup with memcmp(), or do the comparison field by field. I don't mind
> changing it again if requested. I guess we only need to reach an agreement about
> what to go with.
The question was "why do you need the static_assert() now?"
> [1]: https://lore.kernel.org/all/20250303114659.1672695-13-u.kleine-koenig@baylibre.com/
> [2]: https://lore.kernel.org/linux-iio/20250504192117.5e19f44b@jic23-huawei/
>
> > > + if (a->misc != b->misc ||
> > > + a->afe != b->afe ||
> > > + a->filter != b->filter ||
> > > + a->filter_fs != b->filter_fs ||
> > > + a->offset != b->offset ||
> > > + a->gain != b->gain)
> > > + return false;
> > > +
> > > + return true;
> > > +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-06-03 8:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 11:34 [PATCH v4 00/11] iio: adc: Add support for AD4170 series of ADCs Marcelo Schmitt
2025-06-02 11:36 ` [PATCH v4 01/11] dt-bindings: iio: adc: Add AD4170 Marcelo Schmitt
2025-06-02 12:23 ` Rob Herring (Arm)
2025-06-02 20:52 ` Marcelo Schmitt
2025-06-07 16:33 ` Jonathan Cameron
2025-06-07 16:45 ` Jonathan Cameron
2025-06-09 15:28 ` Marcelo Schmitt
2025-06-09 15:44 ` Jonathan Cameron
2025-06-02 11:36 ` [PATCH v4 02/11] iio: adc: Add basic support for AD4170 Marcelo Schmitt
2025-06-02 14:55 ` Andy Shevchenko
2025-06-02 16:54 ` Marcelo Schmitt
2025-06-03 8:27 ` Andy Shevchenko [this message]
2025-06-03 12:02 ` Marcelo Schmitt
2025-06-03 13:43 ` Andy Shevchenko
2025-06-07 16:59 ` Jonathan Cameron
2025-06-03 14:00 ` kernel test robot
2025-06-02 11:37 ` [PATCH v4 03/11] iio: adc: ad4170: Add support for calibration gain Marcelo Schmitt
2025-06-02 12:54 ` Andy Shevchenko
2025-06-02 11:37 ` [PATCH v4 04/11] iio: adc: ad4170: Add support for calibration bias Marcelo Schmitt
2025-06-02 11:38 ` [PATCH v4 05/11] iio: adc: ad4170: Add digital filter and sample frequency config support Marcelo Schmitt
2025-06-02 11:38 ` [PATCH v4 06/11] iio: adc: ad4170: Add support for buffered data capture Marcelo Schmitt
2025-06-07 17:06 ` Jonathan Cameron
2025-06-09 20:39 ` Marcelo Schmitt
2025-06-02 11:39 ` [PATCH v4 07/11] iio: adc: ad4170: Add clock provider support Marcelo Schmitt
2025-06-02 11:39 ` [PATCH v4 08/11] iio: adc: ad4170: Add GPIO controller support Marcelo Schmitt
2025-06-02 11:39 ` [PATCH v4 09/11] iio: adc: ad4170: Add support for internal temperature sensor Marcelo Schmitt
2025-06-02 11:40 ` [PATCH v4 10/11] iio: adc: ad4170: Add support for weigh scale and RTD sensors Marcelo Schmitt
2025-06-07 17:15 ` Jonathan Cameron
2025-06-02 11:40 ` [PATCH v4 11/11] iio: adc: ad4170: Add timestamp channel 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=aD6x2caTMd1eBInM@smile.fi.intel.com \
--to=andy@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=ana-maria.cusco@analog.com \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.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;
as well as URLs for NNTP newsgroup(s).