From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-acpi@vger.kernel.org, devicetree@vger.kernel.org
Cc: 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
Subject: [PATCH v2 16/17] device property: Use fwnode_operations for parsing graph endpoint
Date: Mon, 6 Mar 2017 17:43:02 +0200 [thread overview]
Message-ID: <1488814983-25695-17-git-send-email-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <1488814983-25695-1-git-send-email-sakari.ailus@linux.intel.com>
Change the implementation of fwnode_graph_parse_endpoint() function to
use struct fwnode_operations.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/acpi/property.c | 19 +++++++++++++++++++
drivers/base/property.c | 22 +---------------------
drivers/of/base.c | 17 +++++++++++++++++
3 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
index 1790256..23bc12d 100644
--- a/drivers/acpi/property.c
+++ b/drivers/acpi/property.c
@@ -1214,6 +1214,24 @@ static struct fwnode_handle *acpi_fwnode_graph_get_remote_port_parent(
return parent;
}
+static int acpi_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
+ struct fwnode_endpoint *endpoint)
+{
+ struct fwnode_handle *port_fwnode = fwnode_get_parent(fwnode);
+ struct fwnode_handle *iter;
+
+ endpoint->local_fwnode = fwnode;
+
+ fwnode_property_read_u32(port_fwnode, "port", &endpoint->port);
+
+ for (iter = fwnode_get_next_child_node(port_fwnode, NULL);
+ iter != fwnode;
+ iter = fwnode_get_next_child_node(port_fwnode, iter))
+ endpoint->id++;
+
+ return 0;
+}
+
const struct fwnode_operations acpi_fwnode_ops = {
.property_present = acpi_fwnode_property_present,
.property_read_int_array = acpi_fwnode_property_read_int_array,
@@ -1225,4 +1243,5 @@ const struct fwnode_operations acpi_fwnode_ops = {
.graph_get_remote_endpoint = acpi_fwnode_graph_get_remote_endpoint,
.graph_get_remote_port = acpi_fwnode_graph_get_remote_port,
.graph_get_remote_port_parent = acpi_fwnode_graph_get_remote_port_parent,
+ .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint,
};
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 9767a09..c6399cf 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1199,28 +1199,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)) {
- struct fwnode_handle *iter;
-
- fwnode_property_read_u32(port_fwnode, "port", &endpoint->port);
-
- for (iter = fwnode_get_next_child_node(port_fwnode, NULL);
- iter != fwnode;
- iter = fwnode_get_next_child_node(port_fwnode, iter))
- 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/base.c b/drivers/of/base.c
index 8bf3b77..7757aa6 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -2683,6 +2683,22 @@ static struct fwnode_handle *of_fwnode_graph_get_remote_port_parent(
return NULL;
}
+static int of_fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
+ struct fwnode_endpoint *endpoint)
+{
+ struct device_node *node = to_of_node(fwnode);
+ struct device_node *port_node = of_get_parent(node);
+
+ endpoint->local_fwnode = fwnode;
+
+ of_property_read_u32(port_node, "reg", &endpoint->port);
+ of_property_read_u32(node, "reg", &endpoint->id);
+
+ of_node_put(port_node);
+
+ return 0;
+}
+
const struct fwnode_operations of_fwnode_ops = {
.get = of_fwnode_get,
.put = of_fwnode_put,
@@ -2696,4 +2712,5 @@ const struct fwnode_operations of_fwnode_ops = {
.graph_get_remote_endpoint = of_fwnode_graph_get_remote_endpoint,
.graph_get_remote_port = of_fwnode_graph_get_remote_port,
.graph_get_remote_port_parent = of_fwnode_graph_get_remote_port_parent,
+ .graph_parse_endpoint = of_fwnode_graph_parse_endpoint,
};
--
2.7.4
next prev parent reply other threads:[~2017-03-06 15:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 15:42 [PATCH v2 00/17] Move firmware specific code to firmware specific locations Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 01/17] device property: Add operations struct for fwnode operations Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 02/17] device property: Add macros for calling " Sakari Ailus
[not found] ` <1488814983-25695-1-git-send-email-sakari.ailus-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-03-06 15:42 ` [PATCH v2 03/17] device property: Introduce firmware property operations, set them Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 04/17] device property: Use fwnode_operations for fwnode_handle_{get,put} Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 05/17] device property: Use fwnode_operations for fwnode_property_present() Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 06/17] device property: Use fwnode_operations for reading integer arrays Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 09/17] device property: Use fwnode_operations for obtaining parent node Sakari Ailus
2017-03-13 22:27 ` [PATCH v2 00/17] Move firmware specific code to firmware specific locations Rafael J. Wysocki
2017-03-15 14:19 ` Sakari Ailus
2017-03-15 14:23 ` Rafael J. Wysocki
[not found] ` <CAJZ5v0i5o+2FksW+NmYQugD6qL-1QmREd2isATifu9n0g69Q+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-16 22:50 ` Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 07/17] device property: Read strings using string array reading functions Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 08/17] device property: Use fwnode_operations for reading string arrays Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 10/17] device property: Use fwnode_operations for obtaining next child node Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 11/17] device property: Use fwnode_operations for obtaining a named " Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 12/17] device property: Use fwnode_operations for obtaining next graph endpoint Sakari Ailus
2017-03-06 15:42 ` [PATCH v2 13/17] device property: Use fwnode_operations for obtaining the remote endpoint Sakari Ailus
2017-03-06 15:43 ` [PATCH v2 14/17] device property: Use fwnode_operations for obtaining the remote port Sakari Ailus
2017-03-06 15:43 ` [PATCH v2 15/17] device property: Use fwnode_operations for obtaining the remote port parent Sakari Ailus
2017-03-06 15:43 ` Sakari Ailus [this message]
2017-03-06 15:43 ` [PATCH v2 17/17] device property: Implement fwnode_get_next_parent() using fwnode interface 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=1488814983-25695-17-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=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).