diff mbox

[v2,1/2] device property: Add fwnode_graph_get_port_parent

Message ID 6d3ca9a2f4af281191b6672489f6d2a6d036d372.1495210364.git-series.kieran.bingham+renesas@ideasonboard.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Kieran Bingham May 19, 2017, 4:16 p.m. UTC
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

Provide a helper to obtain the parent device fwnode without first
parsing the remote-endpoint as per fwnode_graph_get_remote_port_parent.

Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

---
v2:
 - Rebase on top of Sakari's acpi-graph-clean branch and simplify

 drivers/base/property.c  | 13 +++++++++++++
 include/linux/property.h |  2 ++
 2 files changed, 15 insertions(+)

Comments

Sakari Ailus May 19, 2017, 9:51 p.m. UTC | #1
Hi Kieran,

On Fri, May 19, 2017 at 05:16:02PM +0100, Kieran Bingham wrote:
> +struct fwnode_handle *
> +fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
> +{
> +	return fwnode_call_ptr_op(endpoint, graph_get_port_parent);

graph_get_port_parent op will actually get the parent of the port. But it
expects a port node, not an endpoint node. This is implemented so in order
to center the ops around primitives rather than end user APIs that may
change over time.

I think you'll need:

	return fwnode_call_ptr_op(fwnode_graph_get_next_parent(endpoint),
				  graph_get_port_parent);

Or something like that.
Kieran Bingham May 22, 2017, 5:03 p.m. UTC | #2
Hi Sakari,

On 19/05/17 22:51, Sakari Ailus wrote:
> Hi Kieran,
> 
> On Fri, May 19, 2017 at 05:16:02PM +0100, Kieran Bingham wrote:
>> +struct fwnode_handle *
>> +fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
>> +{
>> +	return fwnode_call_ptr_op(endpoint, graph_get_port_parent);
> 
> graph_get_port_parent op will actually get the parent of the port. But it
> expects a port node, not an endpoint node. This is implemented so in order
> to center the ops around primitives rather than end user APIs that may
> change over time.
> 
> I think you'll need:
> 
> 	return fwnode_call_ptr_op(fwnode_graph_get_next_parent(endpoint),
> 				  graph_get_port_parent);
> 
> Or something like that.

Aha - that explains why I remember thinking to ask you if the implementation of
graph_get_port_parent checked enough levels up :)

I've added the fwnode_graph_get_next_parent() call, but separated it out so that
the code fits cleanly:

struct fwnode_handle *
fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
{
	struct fwnode_handle *port = fwnode_get_next_parent(endpoint);

	return fwnode_call_ptr_op(port, graph_get_port_parent);
}
EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);

I will include this in my testing and rebasing before I repost.
--
Regards

Kieran
diff mbox

Patch

diff --git a/drivers/base/property.c b/drivers/base/property.c
index b311a6fa7d0c..310c53b6b7fc 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1169,6 +1169,19 @@  fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
 EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
 
 /**
+ * fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
+ * @endpoint: Endpoint firmware node of the port
+ *
+ * Returns firmware node of the device the @endpoint belongs to.
+ */
+struct fwnode_handle *
+fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
+{
+	return fwnode_call_ptr_op(endpoint, graph_get_port_parent);
+}
+EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
+
+/**
  * fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
  * @fwnode: Endpoint firmware node pointing to the remote endpoint
  *
diff --git a/include/linux/property.h b/include/linux/property.h
index b9f4838d9882..af95d5d84192 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -275,6 +275,8 @@  void *device_get_mac_address(struct device *dev, char *addr, int alen);
 
 struct fwnode_handle *fwnode_graph_get_next_endpoint(
 	struct fwnode_handle *fwnode, struct fwnode_handle *prev);
+struct fwnode_handle *fwnode_graph_get_port_parent(
+	struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_graph_get_remote_port_parent(
 	struct fwnode_handle *fwnode);
 struct fwnode_handle *fwnode_graph_get_remote_port(