Skip to content

Commit b5b41ab

Browse files
djrscallyrafaeljw
authored andcommitted
device property: Check fwnode->secondary in fwnode_graph_get_next_endpoint()
Sensor drivers often check for an endpoint to make sure that they're connected to a consuming device like a CIO2 during .probe(). Some of those endpoints might be in the form of software_nodes assigned as a secondary to the device's fwnode_handle. Account for this possibility in fwnode_graph_get_next_endpoint() to avoid having to do it in the sensor drivers themselves. Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Daniel Scally <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 7c60610 commit b5b41ab

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

drivers/base/property.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,26 @@ struct fwnode_handle *
10331033
fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
10341034
struct fwnode_handle *prev)
10351035
{
1036-
return fwnode_call_ptr_op(fwnode, graph_get_next_endpoint, prev);
1036+
const struct fwnode_handle *parent;
1037+
struct fwnode_handle *ep;
1038+
1039+
/*
1040+
* If this function is in a loop and the previous iteration returned
1041+
* an endpoint from fwnode->secondary, then we need to use the secondary
1042+
* as parent rather than @fwnode.
1043+
*/
1044+
if (prev)
1045+
parent = fwnode_graph_get_port_parent(prev);
1046+
else
1047+
parent = fwnode;
1048+
1049+
ep = fwnode_call_ptr_op(parent, graph_get_next_endpoint, prev);
1050+
1051+
if (IS_ERR_OR_NULL(ep) &&
1052+
!IS_ERR_OR_NULL(parent) && !IS_ERR_OR_NULL(parent->secondary))
1053+
ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL);
1054+
1055+
return ep;
10371056
}
10381057
EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);
10391058

0 commit comments

Comments
 (0)