From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-acpi@vger.kernel.org
Cc: devicetree@vger.kernel.org, sudeep.holla@arm.com,
lorenzo.pieralisi@arm.com, mika.westerberg@linux.intel.com,
rafael@kernel.org, mark.rutland@arm.com, broonie@kernel.org,
robh@kernel.org, ahs3@redhat.com, frowand.list@gmail.com
Subject: [PATCH v4 5/5] device property: Add FW type agnostic fwnode_graph_get_remote_node
Date: Mon, 22 May 2017 11:53:22 +0300 [thread overview]
Message-ID: <1495443202-22817-6-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1495443202-22817-1-git-send-email-sakari.ailus@linux.intel.com>
Add fwnode_graph_get_remote_node() function which is equivalent to
of_graph_get_remote_node() on OF.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/base/property.c | 37 +++++++++++++++++++++++++++++++++++++
include/linux/property.h | 2 ++
2 files changed, 39 insertions(+)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index f5ac4cc..b311a6f 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1214,6 +1214,43 @@ fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
/**
+ * fwnode_graph_get_remote_node - get remote parent node for given port/endpoint
+ * @fwnode: pointer to parent fwnode_handle containing graph port/endpoint
+ * @port_id: identifier of the parent port node
+ * @endpoint_id: identifier of the endpoint node
+ *
+ * Return: Remote fwnode handle associated with remote endpoint node linked
+ * to @node. Use fwnode_node_put() on it when done.
+ */
+struct fwnode_handle *fwnode_graph_get_remote_node(
+ struct fwnode_handle *fwnode, u32 port_id, u32 endpoint_id)
+{
+ struct fwnode_handle *endpoint = NULL;
+
+ while ((endpoint = fwnode_graph_get_next_endpoint(fwnode, endpoint))) {
+ struct fwnode_endpoint fwnode_ep;
+ struct fwnode_handle *remote;
+ int ret;
+
+ ret = fwnode_graph_parse_endpoint(endpoint, &fwnode_ep);
+ if (ret < 0)
+ continue;
+
+ if (fwnode_ep.port != port_id || fwnode_ep.id != endpoint_id)
+ continue;
+
+ remote = fwnode_graph_get_remote_port_parent(endpoint);
+ if (!remote)
+ return NULL;
+
+ return fwnode_device_is_available(remote) ? remote : NULL;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_node);
+
+/**
* fwnode_graph_parse_endpoint - parse common endpoint node properties
* @fwnode: pointer to endpoint fwnode_handle
* @endpoint: pointer to the fwnode endpoint data structure
diff --git a/include/linux/property.h b/include/linux/property.h
index 7be014a..b9f4838 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -281,6 +281,8 @@ struct fwnode_handle *fwnode_graph_get_remote_port(
struct fwnode_handle *fwnode);
struct fwnode_handle *fwnode_graph_get_remote_endpoint(
struct fwnode_handle *fwnode);
+struct fwnode_handle *fwnode_graph_get_remote_node(
+ struct fwnode_handle *fwnode, u32 port, u32 endpoint);
int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
struct fwnode_endpoint *endpoint);
--
2.7.4
next prev parent reply other threads:[~2017-05-22 8:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-22 8:53 [PATCH v4 0/5] Move firmware specific code to firmware specific locations Sakari Ailus
[not found] ` <1495443202-22817-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-05-22 8:53 ` [PATCH v4 1/5] ACPI: Constify argument to acpi_device_is_present() Sakari Ailus
2017-05-22 8:53 ` [PATCH v4 3/5] device property: Move fwnode graph ops to firmware specific locations Sakari Ailus
2017-05-22 8:53 ` [PATCH v4 2/5] device property: Move FW type specific functionality to FW specific files Sakari Ailus
2017-05-31 9:44 ` Mika Westerberg
2017-05-31 10:08 ` Sakari Ailus
2017-05-22 8:53 ` [PATCH v4 4/5] device property: Introduce fwnode_device_is_available() Sakari Ailus
2017-05-31 9:58 ` Mika Westerberg
2017-05-31 10:12 ` Sakari Ailus
2017-05-31 10:17 ` Mika Westerberg
2017-05-22 8:53 ` Sakari Ailus [this message]
[not found] ` <1495443202-22817-6-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-05-31 10:02 ` [PATCH v4 5/5] device property: Add FW type agnostic fwnode_graph_get_remote_node Mika Westerberg
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=1495443202-22817-6-git-send-email-sakari.ailus@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).