From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Lee Jones <lee@kernel.org>
Cc: Matti Vaittinen <mazziesaccount@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] mfd: rohm-bd718x7: Use software nodes for gpio-keys
Date: Wed, 1 Apr 2026 12:42:31 -0700 [thread overview]
Message-ID: <ac10-zLCP5wsf_cx@google.com> (raw)
In-Reply-To: <20260401105930.GL3795166@google.com>
On Wed, Apr 01, 2026 at 11:59:30AM +0100, Lee Jones wrote:
> On Wed, 01 Apr 2026, Matti Vaittinen wrote:
>
> > On 27/03/2026 18:10, Dmitry Torokhov wrote:
> > > On Fri, Mar 27, 2026 at 12:55:55PM +0200, Matti Vaittinen wrote:
> > > > On 25/03/2026 02:54, Dmitry Torokhov wrote:
> > > > > +
> > > > > + node_group = (const struct software_node *[]){
> > > > > + &nodes[0],
> > > > > + &nodes[1],
> > > > > + NULL
> > > > > + };
> > > >
> > > > Hmm. I suppose I was not explaining myself well. When I asked for a
> > > > temporary variable, I was hoping to get rid of this syntax. Something like:
> > > > const struct software_node *node_group[3];
> > > >
> > > > node_group[0] = &nodes[0];
> > > > node_group[1] = &nodes[1];
> > > > node_group[2] = NULL;
> > > >
> > > > would look more familiar to me. Well, I suppose I can live with this if it
> > > > is Ok to Lee though. Let's see if he has an opinion.
> > >
> > > This is simply a compound literal, part of the C standard since C99. It
> > > allows skip explicitly declaring the dimensions of the node_group[]
> > > array (which is "far" away from where we initialize it and it
> > > potentially may get out of sync).
> > >
> > > We have quite a few in the kernel, DEFINE_RES_IRQ() and others for
> > > example are compound literals under the hood.
> >
> > Yes. But ones I've seen have been wrapped in macros. I don't think I've seen
> > open-coded one written directly to a call-site (although that's what the
> > macros end up). Hence, this is not something I see typically when reading
> > drivers.
> >
> > But as I said, if this is fine with Lee, I can live with this too :)
>
> My personal preference is to avoid the use of compound literals for
> structs inside functions.
>
I assume use of macros like DEFINE_RES_IRQ() is still OK?
Thanks.
--
Dmitry
prev parent reply other threads:[~2026-04-01 19:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-25 0:54 [PATCH v3 0/2] rohm-bdi718x7/71828: Use software nodes for gpio-keys Dmitry Torokhov
2026-03-25 0:54 ` [PATCH v3 1/2] mfd: rohm-bd71828: " Dmitry Torokhov
2026-03-27 10:58 ` Matti Vaittinen
2026-03-25 0:54 ` [PATCH v3 2/2] mfd: rohm-bd718x7: " Dmitry Torokhov
2026-03-27 10:55 ` Matti Vaittinen
2026-03-27 16:10 ` Dmitry Torokhov
2026-04-01 5:29 ` Matti Vaittinen
2026-04-01 10:59 ` Lee Jones
2026-04-01 19:42 ` Dmitry Torokhov [this message]
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=ac10-zLCP5wsf_cx@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.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