From: Sakari Ailus <sakari.ailus@iki.fi>
To: Rob Herring <robh@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
"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>
Subject: Re: [PATCH 06/15] device property: Add support for remote endpoints
Date: Tue, 31 Jan 2017 11:58:27 +0200 [thread overview]
Message-ID: <20170131095827.GS7139@valkosipuli.retiisi.org.uk> (raw)
In-Reply-To: <CAL_JsqL+avBhLD9jwk-yfCsxYWTBPZo5OrNB0JBLs8Ri6xtOgw@mail.gmail.com>
Hi Rob,
Thank you for the review.
On Fri, Jan 27, 2017 at 03:45:04PM -0600, Rob Herring wrote:
> On Fri, Jan 27, 2017 at 10:03 AM, Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
> > From: Mika Westerberg <mika.westerberg@linux.intel.com>
> >
> > This follows DT implementation of of_graph_* APIs but we call them
> > fwnode_graph_* instead. For DT nodes the existing of_graph_* implementation
> > will be used. For ACPI we use the new ACPI graph implementation instead.
> >
> > This commit includes code from Sakari Ailus.
>
> Then it should have your S-o-b. Actually, either way it should have it.
I'll add that.
>
> Whether or not copying DT graphs is a good idea or not, I'll let
> someone else chime in on that...
>
> > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > ---
> > drivers/base/property.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++
> > include/linux/property.h | 9 ++++
> > 2 files changed, 131 insertions(+)
> >
> > diff --git a/drivers/base/property.c b/drivers/base/property.c
> > index c0011cf..cf602c3 100644
> > --- a/drivers/base/property.c
> > +++ b/drivers/base/property.c
> > @@ -15,6 +15,7 @@
> > #include <linux/kernel.h>
> > #include <linux/of.h>
> > #include <linux/of_address.h>
> > +#include <linux/of_graph.h>
> > #include <linux/property.h>
> > #include <linux/etherdevice.h>
> > #include <linux/phy.h>
> > @@ -1111,3 +1112,124 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen)
> > return device_get_mac_addr(dev, "address", addr, alen);
> > }
> > EXPORT_SYMBOL(device_get_mac_address);
> > +
> > +/**
> > + * device_graph_get_next_endpoint - Get next endpoint firmware node
> > + * @fwnode: Pointer to the parent firmware node
> > + * @prev: Previous endpoint node or %NULL to get the first
> > + *
> > + * Returns an endpoint firmware node pointer or %NULL if no more endpoints
> > + * are available.
> > + */
> > +struct fwnode_handle *
> > +fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
> > + struct fwnode_handle *prev)
> > +{
> > + struct fwnode_handle *endpoint = NULL;
> > +
> > + if (is_of_node(fwnode)) {
> > + struct device_node *node;
> > +
> > + node = of_graph_get_next_endpoint(to_of_node(fwnode),
> > + to_of_node(prev));
> > +
> > + if (node)
> > + endpoint = &node->fwnode;
> > + } else if (is_acpi_node(fwnode)) {
> > + endpoint = acpi_graph_get_next_endpoint(fwnode, prev);
> > + if (IS_ERR(endpoint))
> > + endpoint = NULL;
> > + }
>
> This is an ugly pattern IMO. Why not define an ops struct and set it
> to OF or ACPI rather than check on every function call with
> is_{of,acpi}_node()?
That appears to be an established practice in the implementation of the
device / fwnode property API.
One option could be to choose the relevant ops struct based on fwnode type
in each function operating on the fwnode.
Alternatively it could be set at the time when the fwnode field is set. A
large number of drivers are manipulating their OF nodes, some do that for
fwnodes as well. Manually setting the ops struct pointer in those cases
might not be robust enough: sometimes one could simply forget. Also, adding
a pointer to struct fwnode_handle would increase the size of the struct
significantly without much gain.
The number of functions operating on fwnode_handle is rather limited. I
wonder if it'd be simply better to keep it as-is.
>
> The of_graph_* functions need some better helpers too, so duplicating
> them 2 more times is not ideal. Basically, drivers are left to do too
> much of the walking of nodes themselves.
I have to admit my experience in using them is limited to V4L2, but I have
to say they've been working pretty well for what they're used for. Actually
the graph functionality was originally specific for V4L2, that could be the
reason why the current API is a good fit for V4L2. :-)
The current use ACPI use case is related to V4L2 as well (I'll post a new
version in the near future):
<URL:http://www.spinics.net/lists/linux-media/msg106160.html>
Are there any particular pain points that should be addressed?
I noticed Kunimori Morimoto's patchset adding of_graph_get_remote_endpoint()
which is just a new convenience function to the current API.
--
Kind regards,
Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
next prev parent reply other threads:[~2017-01-31 9:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-27 16:02 [PATCH 00/15] ACPI graph support Sakari Ailus
2017-01-27 16:02 ` [PATCH 01/15] ACPI / property: Add possiblity to retrieve parent firmware node Sakari Ailus
2017-01-27 16:02 ` [PATCH 02/15] device property: Add fwnode_get_parent() Sakari Ailus
2017-01-27 16:02 ` [PATCH 03/15] ACPI / property: Add fwnode_get_next_child_node() Sakari Ailus
2017-01-27 16:02 ` [PATCH 04/15] device property: Add fwnode_get_named_child_node() Sakari Ailus
[not found] ` <1485532990-8431-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-27 16:03 ` [PATCH 05/15] ACPI / property: Add support for remote endpoints Sakari Ailus
2017-01-27 16:03 ` [PATCH 06/15] device " Sakari Ailus
2017-01-27 21:45 ` Rob Herring
2017-01-31 9:58 ` Sakari Ailus [this message]
[not found] ` <20170131095827.GS7139-S+BSfZ9RZZmRSg0ZkenSGLdO1Tsj/99ntUK59QYPAWc@public.gmane.org>
2017-02-02 17:19 ` Rob Herring
2017-02-03 9:59 ` Sakari Ailus
2017-01-27 16:03 ` [PATCH 09/15] driver core: Arrange headers alphabetically Sakari Ailus
2017-01-27 16:03 ` [PATCH 12/15] device property: Add support for fwnode endpoints Sakari Ailus
2017-01-27 16:03 ` [PATCH 14/15] device property: Add fwnode_get_next_parent() Sakari Ailus
2017-01-27 16:03 ` [PATCH 07/15] device property: Add fwnode_handle_get() Sakari Ailus
2017-01-27 16:03 ` [PATCH 08/15] of: Add of_fwnode_handle() to convert device nodes to fwnode_handle Sakari Ailus
2017-01-27 16:03 ` [PATCH 10/15] of: No need to include linux/property.h, linux/fwnode.h is sufficient Sakari Ailus
[not found] ` <1485532990-8431-11-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-28 1:04 ` kbuild test robot
2017-01-31 8:21 ` [PATCH v1.1 10/16] irqchip/gic: Add missing forward declaration for struct device Sakari Ailus
2017-01-27 16:03 ` [PATCH 11/15] device property: Obtain device's fwnode independently of FW type Sakari Ailus
2017-01-27 16:03 ` [PATCH 13/15] of: Add nop implementation of of_get_next_parent() Sakari Ailus
2017-01-27 16:03 ` [PATCH 15/15] ACPI / DSD: Document references, ports and endpoints 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=20170131095827.GS7139@valkosipuli.retiisi.org.uk \
--to=sakari.ailus@iki.fi \
--cc=ahs3@redhat.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--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=sakari.ailus@linux.intel.com \
--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