Skip to content

Commit c824c73

Browse files
Sam Protsenkogregkh
authored andcommitted
usb: dwc3: drd: Avoid error when extcon is missing
If "port" node is missing in PHY controller node, dwc3_get_extcon() isn't able to find extcon devices. This is perfectly fine in case when "usb-role-switch" or OTG is used, but next misleading error message is printed in that case, from of_graph_get_remote_node(): OF: graph: no port node found in /phy@1234abcd Avoid printing that message by checking if the port node exists in PHY node before calling of_graph_get_remote_node(). While at it, add the comment from mentioned code block, explaining how checking the port availability helps to avoid the misleading error. Cc: Andy Shevchenko <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Sam Protsenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 614b388 commit c824c73

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/usb/dwc3/drd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,18 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
462462
return edev;
463463
}
464464

465+
/*
466+
* Try to get an extcon device from the USB PHY controller's "port"
467+
* node. Check if it has the "port" node first, to avoid printing the
468+
* error message from underlying code, as it's a valid case: extcon
469+
* device (and "port" node) may be missing in case of "usb-role-switch"
470+
* or OTG mode.
471+
*/
465472
np_phy = of_parse_phandle(dev->of_node, "phys", 0);
466-
np_conn = of_graph_get_remote_node(np_phy, -1, -1);
473+
if (of_graph_is_present(np_phy))
474+
np_conn = of_graph_get_remote_node(np_phy, -1, -1);
475+
else
476+
np_conn = NULL;
467477

468478
if (np_conn)
469479
edev = extcon_find_edev_by_node(np_conn);

0 commit comments

Comments
 (0)