From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Tomas Melin <tomas.melin@vaisala.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Nuno Sa <nuno.sa@analog.com>, Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Alexandru Ardelean <alexandru.ardelean@analog.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: adc: ad9467: support write/read offset
Date: Tue, 2 Dec 2025 16:36:07 +0200 [thread overview]
Message-ID: <aS75V9Zb3xu5RTU6@smile.fi.intel.com> (raw)
In-Reply-To: <44a38485-ce29-45c8-8892-5000abb8d44e@vaisala.com>
On Tue, Dec 02, 2025 at 12:03:21PM +0200, Tomas Melin wrote:
> On 01/12/2025 15:59, Andy Shevchenko wrote:
> > On Mon, Dec 1, 2025 at 2:00 PM Tomas Melin <tomas.melin@vaisala.com> wrote:
...
> >> +#define AD9434_CHAN(_chan, avai_mask, _si, _bits, _sign) \
> >> +{ \
> >> + .type = IIO_VOLTAGE, \
> >> + .indexed = 1, \
> >> + .channel = _chan, \
> >> + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
> >> + BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
> >> + BIT(IIO_CHAN_INFO_OFFSET), \
> >> + .info_mask_shared_by_type_available = avai_mask, \
> >
> > Okay, this macro uses parameterized avai_mask (which should be spelled
> > correctly and probably in parentheses, but it's not the point) and
> > it's being called only once. Why can't we just embed it for now?
>
> Sure, I'm ok with embedding if that is preferred.
I meant to embed the one of the _chan/_si parameter, not the entire macro.
And with comment about index vs. channel, it seems one of them is not needed
at all.
> >> + .scan_index = _si, \
> >> + .scan_type = { \
> >> + .sign = _sign, \
> >> + .realbits = _bits, \
> >> + .storagebits = 16, \
> >> + }, \
> >> +}
> >
> > Also, looking at the existing macro below, I think you should have a
> > common, parameterised macro and then 3 different on top of it for this
> > case, and for the existing two.
> >
> > Does it make sense?
> Keeping this and embedding the ad9434 declaration.
Answered to v2. I think the macro approach is better due to consistency.
> >> #define AD9467_CHAN(_chan, avai_mask, _si, _bits, _sign) \
...
> >> static const struct iio_chan_spec ad9434_channels[] = {
> >> - AD9467_CHAN(0, BIT(IIO_CHAN_INFO_SCALE), 0, 12, 's'),
> >> + AD9434_CHAN(0, BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OFFSET),
> >> + 0, 12, 's'),
> >> };
> >
> > Also the first and third parameters are identical in all cases, can we
> > for now just make them using a single parameter?
...
> >> + if (val < st->info->offset_range[0] || val > st->info->offset_range[2])
> >> + return -EINVAL;
> >
> > Wondering if at some point we can switch to in_range(). And we perhaps
> > need a new generic macro to supply start/end instead of start/size.
> Atleast drop-in usage of in_range() does not seems feasible?
I know, that's why it starts with "wondering" and continues with "perhaps".
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-12-02 14:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 11:59 [PATCH 0/2] iio: adc: ad9467: fixes for ad9434 Tomas Melin
2025-12-01 11:59 ` [PATCH 1/2] iio: adc: ad9467: fix ad9434 vref mask Tomas Melin
2025-12-01 13:49 ` Andy Shevchenko
2025-12-01 11:59 ` [PATCH 2/2] iio: adc: ad9467: support write/read offset Tomas Melin
2025-12-01 13:59 ` Andy Shevchenko
2025-12-02 10:03 ` Tomas Melin
2025-12-02 14:36 ` Andy Shevchenko [this message]
2025-12-01 17:40 ` David Lechner
2025-12-02 10:20 ` Tomas Melin
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=aS75V9Zb3xu5RTU6@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.ardelean@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=tomas.melin@vaisala.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;
as well as URLs for NNTP newsgroup(s).