Re: [PATCH] of: make for_each_property_of_node() available to to !OF

From: Rob Herring
Date: Wed Mar 06 2024 - 14:34:11 EST


On Tue, Mar 5, 2024 at 12:46 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>
> On Tue, 5 Mar 2024 18:56:04 +0100, Rob Herring <robh+dt@xxxxxxxxxx> said:
> >
> > Long term, I want to make struct device_node opaque. So if we really
> > want to fix this, I think we'd want to convert this to use an iterator
> > function. Though I guess any user would be mucking with struct
> > property too, so the whole loop would need to be reworked. So in
> > conclusion, don't use for_each_property_of_node(). :) Shrug.
> >
>
> I basically just need to get the list of all properties of a node. Even just
> names. I'm working on a testing driver that needs to request all GPIOs assigned
> to it over DT so it must find all `foo-gpios` properties.
>
> How about:
>
> int of_node_for_each_property(struct device_node *dn, int
> (*func)(struct property *, void *), void *data)
>
> as the iterator?

Why would we make the caller provide the iterator? We just need a
function call like the other iterators rather than directly
dereferencing the pointers: of_next_property_iter(node, last_prop)

> You didn't say if you want to make struct property opaque as
> well but even then it can be used with provided interfaces.

Yes, I'd like to make struct property opaque as well. That's probably
the first step.

Rob