summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2026-06-06 20:51:29 -0700
committerDanilo Krummrich <dakr@kernel.org>2026-06-10 00:58:04 +0200
commitfe221742e388bea3f5856b5d9b2cb0a037020ea4 (patch)
tree87a34f54958f60ee71e1e0912675e6e5f2adc6bc /include/linux
parenta7a7dc5c46a036e8a581a4269839d92aded0e0ea (diff)
software node: allow passing reference args to PROPERTY_ENTRY_REF()refs/merge-window/87cffa2fc43294966d89248a021b5cb1fe318000
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 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. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/aiTo4dvKu8pyimHA@google.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/property.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/property.h b/include/linux/property.h
index e30ef23a9af3..14c304db4664 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -471,12 +471,18 @@ struct property_entry {
#define PROPERTY_ENTRY_STRING(_name_, _val_) \
__PROPERTY_ENTRY_ELEMENT(_name_, str, STRING, _val_)
+#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__))
+
#define PROPERTY_ENTRY_REF(_name_, _ref_, ...) \
(struct property_entry) { \
.name = _name_, \
.length = sizeof(struct software_node_ref_args), \
.type = DEV_PROP_REF, \
- { .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), }, \
+ { .pointer = __PROPERTY_ENTRY_REF_ARGS(_ref_, ##__VA_ARGS__) }, \
}
#define PROPERTY_ENTRY_BOOL(_name_) \