Re: [PATCH 5/9] of: property: implement the .property_get_names() fwnode operation
From: Bartosz Golaszewski
Date: Mon Nov 09 2026 - 08:08:58 EST
On Wed, Nov 04, 2026 at 11:21:15PM +0200, Andy Shevchenko wrote:
> 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?
>
I haven't found one. Though I'm thinking that maybe
fwnode_property_get_names() with props == NULL could serve that purpose?
Possibly wrapped in a static inline fwnode_property_count()? Would
anyone use it though?
> > + 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).
>
Please rephrase because I'm not quite following what you're saying.
Bart
> > + if (!names[i]) {
> > + kfree_strarray(names, i);
> > + return -ENOMEM;
> > + }
> > + i++;
> > + }
> > +
> > + *props = names;
> > + return count;
> > +}
>
> --
> With Best Regards,
> Andy Shevchenko
>
>