From: <Victor.Duicu@microchip.com>
To: <andy.shevchenko@gmail.com>
Cc: <Marius.Cristea@microchip.com>, <jic23@kernel.org>,
<andy@kernel.org>, <dlechner@baylibre.com>,
<linux-iio@vger.kernel.org>, <nuno.sa@analog.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 2/2] iio: temperature: add support for MCP998X
Date: Thu, 22 May 2025 09:18:06 +0000 [thread overview]
Message-ID: <82538eaeb9bfc8dffe0b67d7dd00826b96ed573c.camel@microchip.com> (raw)
In-Reply-To: <CAHp75VdzVzNV1k8RqG6Rxsg06Oqu_p1o-4QFeT10xBjrFOEZHA@mail.gmail.com>
On Tue, 2025-04-15 at 22:05 +0300, Andy Shevchenko wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
Hi Andy,
> On Tue, Apr 15, 2025 at 4:27 PM <victor.duicu@microchip.com> wrote:
> >
> > This is the driver for Microchip MCP998X/33 and MCP998XD/33D
> > Multichannel Automotive Monitor Family.
>
> ...
>
> > +#define MCP9982_CHAN(index, si, __address) ({ \
> > + struct iio_chan_spec __chan = { \
> > + .type = IIO_TEMP, \
> > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> > + .info_mask_shared_by_all_available =
> > BIT(IIO_CHAN_INFO_SAMP_FREQ), \
> > + .info_mask_shared_by_all =
> > BIT(IIO_CHAN_INFO_SAMP_FREQ), \
> > + .channel = index, \
> > + .address = __address, \
> > + .scan_index = si, \
> > + .scan_type = { \
> > + .sign = 'u', \
> > + .realbits = 8, \
> > + .storagebits = 8, \
> > + .endianness = IIO_CPU \
> > + }, \
> > + .indexed = 1, \
> > + }; \
> > + __chan; \
>
> Why in this form and not as a compound literal?
>
I can have up to 5 channels, which have very similar specifications.
I use this define to simplify definition of channels and avoid
repeating code.
Is it now preferable to use compound literal?
I could implement something like this:
#define put_channel_defaults \
.type = IIO_TEMP \
...
priv->iio_chan[0] = ((struct iio_chan_spec){put_channel_defaults,
.channel = x,
...
This way when initializing the channels I don't have
to repeat the common properties.
Do you find this approach agreeable?
Kind regards,
Duicu Victor
next prev parent reply other threads:[~2025-05-22 9:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 13:26 [PATCH v1 0/2] add support for MCP998X victor.duicu
2025-04-15 13:26 ` [PATCH v1 1/2] dt-bindings: iio: temperature: " victor.duicu
2025-04-15 17:52 ` Jonathan Cameron
2025-04-17 11:40 ` Victor.Duicu
2025-04-18 16:01 ` Jonathan Cameron
2025-04-16 6:45 ` Krzysztof Kozlowski
2025-04-15 13:26 ` [PATCH v1 2/2] " victor.duicu
2025-04-15 19:05 ` Andy Shevchenko
2025-05-22 9:18 ` Victor.Duicu [this message]
2025-05-23 16:21 ` Andy Shevchenko
2025-04-18 18:07 ` Jonathan Cameron
2025-04-28 12:57 ` Victor.Duicu
2025-04-30 16:17 ` Jonathan Cameron
2025-04-15 17:43 ` [PATCH v1 0/2] " Jonathan Cameron
2025-04-17 7:30 ` Victor.Duicu
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=82538eaeb9bfc8dffe0b67d7dd00826b96ed573c.camel@microchip.com \
--to=victor.duicu@microchip.com \
--cc=Marius.Cristea@microchip.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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).