Re: [PATCH v5 05/11] device property: Add fwnode_get_name for returning the name of a node
From: Heikki Krogerus
Date: Tue Sep 03 2019 - 06:10:19 EST
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);
> + 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?
> + fwnode_handle_put(parent);
> +
> + return kobject_name(&swnode->kobj);
> +}
> +
> static struct fwnode_handle *
> software_node_get_parent(const struct fwnode_handle *fwnode)
> {
> @@ -615,6 +634,7 @@ static const struct fwnode_operations software_node_ops = {
> .property_present = software_node_property_present,
> .property_read_int_array = software_node_read_int_array,
> .property_read_string_array = software_node_read_string_array,
> + .get_name = software_node_get_name,
> .get_parent = software_node_get_parent,
> .get_next_child_node = software_node_get_next_child,
> .get_named_child_node = software_node_get_named_child_node,
thanks,
--
heikki