Skip to content

Commit 6a71d8d

Browse files
kbinghamrafaeljw
authored andcommitted
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>
1 parent 125ee6b commit 6a71d8d

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

drivers/base/property.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,26 @@ fwnode_graph_get_next_endpoint(struct fwnode_handle *fwnode,
11701170
}
11711171
EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
11721172

1173+
/**
1174+
* fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint
1175+
* @endpoint: Endpoint firmware node of the port
1176+
*
1177+
* Return: the firmware node of the device the @endpoint belongs to.
1178+
*/
1179+
struct fwnode_handle *
1180+
fwnode_graph_get_port_parent(struct fwnode_handle *endpoint)
1181+
{
1182+
struct fwnode_handle *port, *parent;
1183+
1184+
port = fwnode_get_parent(endpoint);
1185+
parent = fwnode_call_ptr_op(port, graph_get_port_parent);
1186+
1187+
fwnode_handle_put(port);
1188+
1189+
return parent;
1190+
}
1191+
EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);
1192+
11731193
/**
11741194
* fwnode_graph_get_remote_port_parent - Return fwnode of a remote device
11751195
* @fwnode: Endpoint firmware node pointing to the remote endpoint
@@ -1179,12 +1199,12 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
11791199
struct fwnode_handle *
11801200
fwnode_graph_get_remote_port_parent(struct fwnode_handle *fwnode)
11811201
{
1182-
struct fwnode_handle *port, *parent;
1202+
struct fwnode_handle *endpoint, *parent;
11831203

1184-
port = fwnode_graph_get_remote_port(fwnode);
1185-
parent = fwnode_call_ptr_op(port, graph_get_port_parent);
1204+
endpoint = fwnode_graph_get_remote_endpoint(fwnode);
1205+
parent = fwnode_graph_get_port_parent(endpoint);
11861206

1187-
fwnode_handle_put(port);
1207+
fwnode_handle_put(endpoint);
11881208

11891209
return parent;
11901210
}

include/linux/property.h

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

276276
struct fwnode_handle *fwnode_graph_get_next_endpoint(
277277
struct fwnode_handle *fwnode, struct fwnode_handle *prev);
278+
struct fwnode_handle *
279+
fwnode_graph_get_port_parent(struct fwnode_handle *fwnode);
278280
struct fwnode_handle *fwnode_graph_get_remote_port_parent(
279281
struct fwnode_handle *fwnode);
280282
struct fwnode_handle *fwnode_graph_get_remote_port(

0 commit comments

Comments
 (0)