Skip to content

Commit c1aa3ca

Browse files
Sakari Ailusrkhuangtao
authored andcommitted
UPSTREAM: device property: Add FW type agnostic fwnode_graph_get_remote_node
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> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 125ee6b3b0fa920c730b0991e6f083a9f5b1e4c3) 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: Ic450222819fb987342af9170872b91b0044a181f Reviewed-on: https://chromium-review.googlesource.com/693679 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 fe88941 commit c1aa3ca

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

drivers/base/property.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,43 @@ fwnode_graph_get_remote_endpoint(struct fwnode_handle *fwnode)
11421142
}
11431143
EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_endpoint);
11441144

1145+
/**
1146+
* fwnode_graph_get_remote_node - get remote parent node for given port/endpoint
1147+
* @fwnode: pointer to parent fwnode_handle containing graph port/endpoint
1148+
* @port_id: identifier of the parent port node
1149+
* @endpoint_id: identifier of the endpoint node
1150+
*
1151+
* Return: Remote fwnode handle associated with remote endpoint node linked
1152+
* to @node. Use fwnode_node_put() on it when done.
1153+
*/
1154+
struct fwnode_handle *fwnode_graph_get_remote_node(struct fwnode_handle *fwnode,
1155+
u32 port_id, u32 endpoint_id)
1156+
{
1157+
struct fwnode_handle *endpoint = NULL;
1158+
1159+
while ((endpoint = fwnode_graph_get_next_endpoint(fwnode, endpoint))) {
1160+
struct fwnode_endpoint fwnode_ep;
1161+
struct fwnode_handle *remote;
1162+
int ret;
1163+
1164+
ret = fwnode_graph_parse_endpoint(endpoint, &fwnode_ep);
1165+
if (ret < 0)
1166+
continue;
1167+
1168+
if (fwnode_ep.port != port_id || fwnode_ep.id != endpoint_id)
1169+
continue;
1170+
1171+
remote = fwnode_graph_get_remote_port_parent(endpoint);
1172+
if (!remote)
1173+
return NULL;
1174+
1175+
return fwnode_device_is_available(remote) ? remote : NULL;
1176+
}
1177+
1178+
return NULL;
1179+
}
1180+
EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_node);
1181+
11451182
/**
11461183
* fwnode_graph_parse_endpoint - parse common endpoint node properties
11471184
* @fwnode: pointer to endpoint fwnode_handle

include/linux/property.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ struct fwnode_handle *fwnode_graph_get_remote_port(
222222
struct fwnode_handle *fwnode);
223223
struct fwnode_handle *fwnode_graph_get_remote_endpoint(
224224
struct fwnode_handle *fwnode);
225+
struct fwnode_handle *fwnode_graph_get_remote_node(struct fwnode_handle *fwnode,
226+
u32 port, u32 endpoint);
225227

226228
int fwnode_graph_parse_endpoint(struct fwnode_handle *fwnode,
227229
struct fwnode_endpoint *endpoint);

0 commit comments

Comments
 (0)