Re: [PATCH v3 2/2] mfd: rohm-bd718x7: Use software nodes for gpio-keys
From: Dmitry Torokhov
Date: Fri Mar 27 2026 - 12:14:57 EST
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.
Thanks.
--
Dmitry