Skip to content

Commit c36f8b2

Browse files
kbinghamrkhuangtao
authored andcommitted
UPSTREAM: device property: Add fwnode_graph_get_port_parent
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> (cherry picked from commit 6a71d8d77795e0f7d887baa95bfc0d1d2bc74899) Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com> BUG=b:64133998 TEST=media device topology shows subdevs registered successfully TEST=no camera regression Change-Id: I58c0cfd2759aa62ada3d54cfb77f449ff8a0abc3 Reviewed-on: https://chromium-review.googlesource.com/693680 Commit-Ready: Tomasz Figa <tfiga@chromium.org> Tested-by: Hyungwoo Yang <hyungwoo.yang@intel.com> Reviewed-by: Tomasz Figa <tfiga@chromium.org> Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
1 parent c1aa3ca commit c36f8b2

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

drivers/base/property.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,26 @@ fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
10971097
}
10981098
EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
10991099

1100+
/**
1101+
* fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
1102+
* @endpoint: Endpoint firmware node of the port
1103+
*
1104+
* Return: the firmware node of the device the @endpoint belongs to.
1105+
*/
1106+
struct fwnode_handle *
1107+
fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
1108+
{
1109+
struct fwnode_handle *port, *parent;
1110+
1111+
port = fwnode_get_parent(endpoint);
1112+
parent = fwnode_call_ptr_op(port, graph_get_port_parent);
1113+
1114+
fwnode_handle_put(port);
1115+
1116+
return parent;
1117+
}
1118+
EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
1119+
11001120
/**
11011121
* fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
11021122
* @fwnode: Endpoint firmware node pointing to the remote endpoint
@@ -1106,12 +1126,12 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
11061126
struct fwnode_handle *
11071127
fwnode_graph_get_remote_port_parent(struct fwnode_handle *fwnode)
11081128
{
1109-
struct fwnode_handle *port, *parent;
1129+
struct fwnode_handle *endpoint, *parent;
11101130

1111-
port = fwnode_graph_get_remote_port(fwnode);
1112-
parent = fwnode_call_ptr_op(port, graph_get_port_parent);
1131+
endpoint = fwnode_graph_get_remote_endpoint(fwnode);
1132+
parent = fwnode_graph_get_port_parent(endpoint);
11131133

1114-
fwnode_handle_put(port);
1134+
fwnode_handle_put(endpoint);
11151135

11161136
return parent;
11171137
}

include/linux/property.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen);
216216

217217
struct fwnode_handle *fwnode_graph_get_next_endpoint(
218218
struct fwnode_handle *fwnode, struct fwnode_handle *prev);
219+
struct fwnode_handle *
220+
fwnode_graph_get_port_parent(struct fwnode_handle *fwnode);
219221
struct fwnode_handle *fwnode_graph_get_remote_port_parent(
220222
struct fwnode_handle *fwnode);
221223
struct fwnode_handle *fwnode_graph_get_remote_port(

0 commit comments

Comments
 (0)