Re: [PATCH 5/9] of: property: implement the .property_get_names() fwnode operation
From: Andy Shevchenko
Date: Wed Nov 04 2026 - 17:57:25 EST
On Wed, Nov 04, 2026 at 03:03:47PM +0100, Bartosz Golaszewski wrote:
> Implement the property_get_names() callback from the fwnode interface
> for OF nodes.
...
> #include <linux/string.h>
> +#include <linux/string_helpers.h>
Same comment as per fwnode patch.
...
> +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++;
Hmm... Don't we have a helper for that already?
> + 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);
Can property be statically defined somewhere? We might want to also optimize
these duplications with const variant (here or elsewhere, for fwnode generic
path, I believe).
> + if (!names[i]) {
> + kfree_strarray(names, i);
> + return -ENOMEM;
> + }
> + i++;
> + }
> +
> + *props = names;
> + return count;
> +}
--
With Best Regards,
Andy Shevchenko