[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <82538eaeb9bfc8dffe0b67d7dd00826b96ed573c.camel@microchip.com>
Date: Thu, 22 May 2025 09:18:06 +0000
From: <Victor.Duicu@...rochip.com>
To: <andy.shevchenko@...il.com>
CC: <Marius.Cristea@...rochip.com>, <jic23@...nel.org>, <andy@...nel.org>,
<dlechner@...libre.com>, <linux-iio@...r.kernel.org>, <nuno.sa@...log.com>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v1 2/2] iio: temperature: add support for MCP998X
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@...rochip.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
Powered by blists - more mailing lists