]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
device property: Add fwnode_graph_get_port_parent
authorKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Tue, 6 Jun 2017 09:37:41 +0000 (12:37 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 22 Jun 2017 00:55:34 +0000 (02:55 +0200)
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>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/property.c
include/linux/property.h

index ac3590b1f93d04251eb6ece7121cab214edb3f03..692007e5a94b10437a537440cc0b5a4f236772fd 100644 (file)
@@ -1170,6 +1170,26 @@ 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
+ *
+ * Return: the firmware node of the device the @endpoint belongs to.
+ */
+struct fwnode_handle *
+fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
+{
+       struct fwnode_handle *port, *parent;
+
+       port = fwnode_get_parent(endpoint);
+       parent = fwnode_call_ptr_op(port, graph_get_port_parent);
+
+       fwnode_handle_put(port);
+
+       return 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
@@ -1179,12 +1199,12 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
 struct fwnode_handle *
 fwnode_graph_get_remote_port_parent(struct fwnode_handle *fwnode)
 {
-       struct fwnode_handle *port, *parent;
+       struct fwnode_handle *endpoint, *parent;
 
-       port = fwnode_graph_get_remote_port(fwnode);
-       parent = fwnode_call_ptr_op(port, graph_get_port_parent);
+       endpoint = fwnode_graph_get_remote_endpoint(fwnode);
+       parent = fwnode_graph_get_port_parent(endpoint);
 
-       fwnode_handle_put(port);
+       fwnode_handle_put(endpoint);
 
        return parent;
 }
index 0597a743aa66fe54a9f24b1d7b64ce372067e415..7e77039e6b81814357493bf02f5a47b47a6f7e8e 100644 (file)
@@ -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(