Re: [PATCH v2 2/4] software node: allow passing reference args to PROPERTY_ENTRY_REF

From: Andy Shevchenko

Date: Mon Mar 30 2026 - 06:26:31 EST


On Sun, Mar 29, 2026 at 07:27:49PM -0700, Dmitry Torokhov wrote:
> When dynamically creating software nodes and properties for subsequent
> use with software_node_register() current implementation of
> PROPERTY_ENTRY_REF is not suitable because it creates a temporary

PROPERTY_ENTRY_REF()

> instance of struct software_node_ref_args on stack which will later
> disappear, and software_node_register() only does shallow copy of
> properties.
>
> Fix this by allowing to pass address of reference arguments structure
> directly into PROPERTY_ENTRY_REF(), so that caller can manage lifetime
> of the object properly.

...

> +#define __PROPERTY_ENTRY_REF_ARGS(_ref_, ...) \
> + _Generic(_ref_, \
> + const struct software_node_ref_args *: _ref_, \
> + struct software_node_ref_args *: _ref_, \
> + default: &SOFTWARE_NODE_REFERENCE(_ref_, \
> + ##__VA_ARGS__))

Make it a single line

default: &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__))

AFAICS it has no continuation and fits the given format well.

--
With Best Regards,
Andy Shevchenko