devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Rob Herring <robh@kernel.org>
Cc: "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	"mika.westerberg@linux.intel.com"
	<mika.westerberg@linux.intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mark Brown <broonie@kernel.org>, Al Stone <ahs3@redhat.com>,
	Frank Rowand <frowand.list@gmail.com>
Subject: Re: [PATCH v5 3/5] device property: Move fwnode graph ops to firmware specific locations
Date: Tue, 9 May 2017 15:36:49 +0300	[thread overview]
Message-ID: <0e2194dc-f056-b405-b4f4-d977b9eacac7@linux.intel.com> (raw)
In-Reply-To: <CAL_JsqLCWnDiAbfvEp8h_USwpCho8Qd9ojCp3ebeG9CGdvPzvQ@mail.gmail.com>

Hi Rob,

Thanks for the review.

On 05/08/17 21:23, Rob Herring wrote:
> On Thu, May 4, 2017 at 2:14 AM, Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
...
>> @@ -1184,24 +1167,11 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
>>  struct fwnode_handle *
>>  fwnode_graph_get_remote_port_parent(struct fwnode_handle *fwnode)
>>  {
>> -       struct fwnode_handle *parent = NULL;
>> -
>> -       if (is_of_node(fwnode)) {
>> -               struct device_node *node;
>> -
>> -               node = of_graph_get_remote_port_parent(to_of_node(fwnode));
>> -               if (node)
>> -                       parent = &node->fwnode;
>> -       } else if (is_acpi_node(fwnode)) {
>> -               int ret;
>> -
>> -               ret = acpi_graph_get_remote_endpoint(fwnode, &parent, NULL,
>> -                                                    NULL);
>> -               if (ret)
>> -                       return NULL;
>> -       }
>> +       fwnode = fwnode_graph_get_remote_port(fwnode);
>> +       if (!fwnode)
>> +               return NULL;
>>
>> -       return parent;
>> +       return fwnode_call_ptr_op(fwnode, graph_get_port_parent);
> 
> Just make fwnode_call_ptr_op(NULL, ...) return NULL.

Hmm. That already appears to be the case... I'll take that account
above, too.

> 
>>  }
>>  EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port_parent);
>>
>> @@ -1213,23 +1183,11 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port_parent);
>>   */
>>  struct fwnode_handle *fwnode_graph_get_remote_port(struct fwnode_handle *fwnode)
>>  {
>> -       struct fwnode_handle *port = NULL;
>> -
>> -       if (is_of_node(fwnode)) {
>> -               struct device_node *node;
>> -
>> -               node = of_graph_get_remote_port(to_of_node(fwnode));
>> -               if (node)
>> -                       port = &node->fwnode;
>> -       } else if (is_acpi_node(fwnode)) {
>> -               int ret;
>> -
>> -               ret = acpi_graph_get_remote_endpoint(fwnode, NULL, &port, NULL);
>> -               if (ret)
>> -                       return NULL;
>> -       }
>> +       fwnode = fwnode_graph_get_remote_endpoint(fwnode);
>> +       if (!fwnode)
>> +               return NULL;
>>
>> -       return port;
>> +       return fwnode_get_parent(fwnode);
> 
> Just make fwnode_get_parent(NULL) return NULL.

The same.

> 
>>  }
>>  EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port);
>>
>> @@ -1242,25 +1200,7 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port);
>>  struct fwnode_handle *
>>  fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
>>  {
>> -       struct fwnode_handle *endpoint = NULL;
>> -
>> -       if (is_of_node(fwnode)) {
>> -               struct device_node *node;
>> -
>> -               node = of_parse_phandle(to_of_node(fwnode), "remote-endpoint",
>> -                                       0);
>> -               if (node)
>> -                       endpoint = &node->fwnode;
>> -       } else if (is_acpi_node(fwnode)) {
>> -               int ret;
>> -
>> -               ret = acpi_graph_get_remote_endpoint(fwnode, NULL, NULL,
>> -                                                    &endpoint);
>> -               if (ret)
>> -                       return NULL;
>> -       }
>> -
>> -       return endpoint;
>> +       return fwnode_call_ptr_op(fwnode, graph_get_remote_endpoint);
>>  }
>>  EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
>>
>> @@ -1276,22 +1216,8 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
>>  int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
>>                                 struct fwnode_endpoint *endpoint)
>>  {
>> -       struct fwnode_handle *port_fwnode = fwnode_get_parent(fwnode);
>> -
>>         memset(endpoint, 0, sizeof(*endpoint));
>>
>> -       endpoint->local_fwnode = fwnode;
>> -
>> -       if (is_acpi_node(port_fwnode)) {
>> -               fwnode_property_read_u32(port_fwnode, "port", &endpoint->port);
>> -               fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);
>> -       } else {
>> -               fwnode_property_read_u32(port_fwnode, "reg", &endpoint->port);
>> -               fwnode_property_read_u32(fwnode, "reg", &endpoint->id);
>> -       }
>> -
>> -       fwnode_handle_put(port_fwnode);
>> -
>> -       return 0;
>> +       return fwnode_call_int_op(fwnode, graph_parse_endpoint, endpoint);
>>  }
>>  EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
>> diff --git a/drivers/of/property.c b/drivers/of/property.c
>> index 984e37e..bb6ac73 100644
>> --- a/drivers/of/property.c
>> +++ b/drivers/of/property.c
>> @@ -869,6 +869,59 @@ static struct fwnode_handle *of_fwnode_get_named_child_node(
>>         return NULL;
>>  }
>>
>> +static struct fwnode_handle *of_fwnode_graph_get_next_endpoint(
>> +       struct fwnode_handle *fwnode, struct fwnode_handle *prev)
>> +{
>> +       struct device_node *node;
>> +
>> +       node = of_graph_get_next_endpoint(to_of_node(fwnode),
>> +                                         to_of_node(prev));
>> +       if (node)
>> +               return of_fwnode_handle(node);
>> +
>> +       return NULL;
> 
> Can't of_fwnode_handle() return NULL when node is NULL? Then these
> functions become one liners:
> 
> return of_fwnode_handle(of_graph_get_next_endpoint(to_of_node(fwnode),
>                                          to_of_node(prev)));

Good point. of_fwnode_handle() is a macro (in order to support const /
non-const cases) and it'll be a little bit more complex but I guess
that's not really an issue.

-- 
Kind regards,

Sakari Ailus
sakari.ailus@linux.intel.com

  reply	other threads:[~2017-05-09 12:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04  7:14 [PATCH v5 0/5] Move firmware specific code to firmware specific locations Sakari Ailus
2017-05-04  7:14 ` [PATCH v5 1/5] of: Add of_graph_get_port_parent() to obtain a port's parent node Sakari Ailus
2017-05-04  7:14 ` [PATCH v5 2/5] device property: Move FW type specific functionality to FW specific files Sakari Ailus
2017-05-04  7:14 ` [PATCH v5 3/5] device property: Move fwnode graph ops to firmware specific locations Sakari Ailus
     [not found]   ` <1493882051-28814-4-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-05-08 18:23     ` Rob Herring
2017-05-09 12:36       ` Sakari Ailus [this message]
2017-05-04  7:14 ` [PATCH v5 4/5] device property: Introduce fwnode_device_is_available() Sakari Ailus
2017-05-04  7:14 ` [PATCH v5 5/5] device property: Add FW type agnostic fwnode_graph_get_remote_node Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0e2194dc-f056-b405-b4f4-d977b9eacac7@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=ahs3@redhat.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).