Re: [PATCH v5 05/11] device property: Add fwnode_get_name for returning the name of a node
From: Sakari Ailus
Date: Tue Sep 03 2019 - 07:24:20 EST
Moi,
Thanks for the comments.
On Tue, Sep 03, 2019 at 01:10:13PM +0300, Heikki Krogerus wrote:
> Hi Sakari,
>
> On Mon, Sep 02, 2019 at 04:57:26PM +0300, Sakari Ailus wrote:
> > diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> > index 951e7efd47c23..a4a0f5b80bad3 100644
> > --- a/drivers/base/swnode.c
> > +++ b/drivers/base/swnode.c
> > @@ -515,6 +515,25 @@ static int software_node_read_string_array(const struct fwnode_handle *fwnode,
> > propname, val, nval);
> > }
> >
> > +static const char *
> > +software_node_get_name(const struct fwnode_handle *fwnode)
> > +{
> > + const struct software_node *softnode = to_software_node(fwnode);
> > + const struct swnode *swnode = software_node_to_swnode(softnode);
>
> Why not just:
>
> struct swnode *swnode = to_swnode(fwnode);
Fixed.
>
> > + struct fwnode_handle *parent;
> > +
> > + if (!swnode)
> > + return "(null)";
> > +
> > + parent = fwnode_get_parent(&swnode->fwnode);
> > + if (!parent)
> > + return "";
>
> Please note that there is no root software node object (the kset is
> the root), so you will get "" with most nodes. I'm assuming that is
> not the intention, or is it?
Good point.
In practice this will happen rarely outside the tests, but indeed the root
node would usually not be a software node. I'll drop the above three lines
checking for the parent node, and change nodes created in the test
accordingly.
--
Terveisin,
Sakari Ailus
sakari.ailus@xxxxxxxxxxxxxxx