From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Victor.Duicu@microchip.com
Cc: Marius.Cristea@microchip.com, jic23@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: Fri, 23 May 2025 19:21:29 +0300 [thread overview]
Message-ID: <aDCgiQKL3ySfpkZr@smile.fi.intel.com> (raw)
In-Reply-To: <82538eaeb9bfc8dffe0b67d7dd00826b96ed573c.camel@microchip.com>
On Thu, May 22, 2025 at 09:18:06AM +0000, Victor.Duicu@microchip.com wrote:
> On Tue, 2025-04-15 at 22:05 +0300, Andy Shevchenko wrote:
> > On Tue, Apr 15, 2025 at 4:27 PM <victor.duicu@microchip.com> wrote:
...
> > > +#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?
No, just find how the compound literal macros are written in the kernel,
e.g., PINCTRL_PIN_FUNCTION().
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-05-23 16:21 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
2025-05-23 16:21 ` Andy Shevchenko [this message]
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=aDCgiQKL3ySfpkZr@smile.fi.intel.com \
--to=andy.shevchenko@gmail.com \
--cc=Marius.Cristea@microchip.com \
--cc=Victor.Duicu@microchip.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.