Re: [RFC PATCH v3 4/9] software_node: Add support for fwnode_graph*() family of functions

From: Sakari Ailus
Date: Tue Oct 20 2020 - 09:33:00 EST


On Tue, Oct 20, 2020 at 03:35:56PM +0300, Sakari Ailus wrote:
> Hi Daniel, Heikki,
>
> Thanks for the patch.
>
> On Mon, Oct 19, 2020 at 11:58:58PM +0100, Daniel Scally wrote:
> > From: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
> >
> > This implements the remaining .graph_* callbacks in the
> > fwnode operations vector for the software nodes. That makes
> > the fwnode_graph*() functions available in the drivers also
> > when software nodes are used.
> >
> > The implementation tries to mimic the "OF graph" as much as
> > possible, but there is no support for the "reg" device
> > property. The ports will need to have the index in their
> > name which starts with "port" (for example "port0", "port1",
> > ...) and endpoints will use the index of the software node
> > that is given to them during creation. The port nodes can
> > also be grouped under a specially named "ports" subnode,
> > just like in DT, if necessary.
> >
> > The remote-endpoints are reference properties under the
> > endpoint nodes that are named "remote-endpoint".
> >
> > Signed-off-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>
> > Co-developed-by: Daniel Scally <djrscally@xxxxxxxxx>
> > Signed-off-by: Daniel Scally <djrscally@xxxxxxxxx>
> > ---
> > changes in v3:
> > - removed software_node_device_is_available
> > - moved the change to software_node_get_next_child to a separate
> > patch
> > - switched to use fwnode_handle_put() in graph_get_next_endpoint()
> > instead of software_node_put()
> >
> > changes in v2:
> > - added software_node_device_is_available
> > - altered software_node_get_next_child to get references
> > - altered software_node_get_next_endpoint to release references
> > to ports and avoid passing invalid combinations of swnodes to
> > software_node_get_next_child
> > - altered swnode_graph_find_next_port to release port rather than
> > old
> > drivers/base/swnode.c | 120 +++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 119 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> > index 741149b90..3732530ce 100644
> > --- a/drivers/base/swnode.c
> > +++ b/drivers/base/swnode.c
> > @@ -536,6 +536,120 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode,
> > return 0;
> > }
> >
> > +static struct fwnode_handle *
> > +swnode_graph_find_next_port(const struct fwnode_handle *parent,
> > + struct fwnode_handle *port)
> > +{
> > + struct fwnode_handle *old = port;
> > +
> > + while ((port = software_node_get_next_child(parent, old))) {
>
> software_node_get_next_child() doesn't drop the reference of the old child
> nor gets a reference to the returned node. Should it?
>
> The function to get a named child node does.
>
> It'd be nice if this was aligned. Or am I missing something?
>
> This isn't really a comment on this patch though.

I didn't get this patch to my @linux.intel.com account so I guess it's our
mail servers again...

Anyway, please see my comments on that and ignore this one.

--
Sakari Ailus