[PATCH 5/9] of: property: implement the .property_get_names() fwnode operation

From: Bartosz Golaszewski

Date: Wed Nov 04 2026 - 09:10:59 EST


Implement the property_get_names() callback from the fwnode interface
for OF nodes.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
---
drivers/of/property.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 45e55f61848801ed497702c6cfe501009904c49d..16c9c307633bdc7c9343782b1cd3bdb845552c6a 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -28,6 +28,7 @@
#include <linux/of_graph.h>
#include <linux/of_irq.h>
#include <linux/string.h>
+#include <linux/string_helpers.h>
#include <linux/moduleparam.h>

#include "of_private.h"
@@ -1120,6 +1121,34 @@ of_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
of_property_count_strings(node, propname);
}

+static int of_fwnode_property_get_names(const struct fwnode_handle *fwnode,
+ char ***props)
+{
+ const struct device_node *node = to_of_node(fwnode);
+ struct property *prop;
+ int count = 0, i = 0;
+ char **names;
+
+ for_each_property_of_node(node, prop)
+ count++;
+
+ names = kcalloc(count, sizeof(*names), GFP_KERNEL);
+ if (!names)
+ return -ENOMEM;
+
+ for_each_property_of_node(node, prop) {
+ names[i] = kstrdup(prop->name, GFP_KERNEL);
+ if (!names[i]) {
+ kfree_strarray(names, i);
+ return -ENOMEM;
+ }
+ i++;
+ }
+
+ *props = names;
+ return count;
+}
+
static const char *of_fwnode_get_name(const struct fwnode_handle *fwnode)
{
return kbasename(to_of_node(fwnode)->full_name);
@@ -1712,6 +1741,7 @@ const struct fwnode_operations of_fwnode_ops = {
.property_read_bool = of_fwnode_property_read_bool,
.property_read_int_array = of_fwnode_property_read_int_array,
.property_read_string_array = of_fwnode_property_read_string_array,
+ .property_get_names = of_fwnode_property_get_names,
.get_name = of_fwnode_get_name,
.get_name_prefix = of_fwnode_get_name_prefix,
.get_parent = of_fwnode_get_parent,

--
2.47.3