Re: [PATCH v3 2/2] mfd: rohm-bd718x7: Use software nodes for gpio-keys

From: Dmitry Torokhov

Date: Wed Apr 01 2026 - 15:42:43 EST


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