[PATCH] usb: host: xhci: Find usb-phy by phandle if of_node not supported
From: Anurag Kumar Vulisha
Date: Wed Oct 03 2018 - 08:33:28 EST
There are use cases where the usb phy is created at runtime and
added into sysdev (for example phy-generic.c creates the usb phy
during probe and adds the phy to phy list using usb_add_phy_dev).
In this case, the sysdev may not have the "usb-phy" phandle added.
So, the existing devm_usb_get_phy_by_phandle() doesn't find the
"usb-phy" and returns -ENODEV. This patch modifies the code to search
for usb phy in of_node if "usb-phy" phandle is not found in sysdev.
Signed-off-by: Anurag Kumar Vulisha <anurag.kumar.vulisha@xxxxxxxxxx>
---
drivers/usb/host/xhci-plat.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 94e9392..997836f 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -293,6 +293,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
}
hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
+ if (PTR_ERR(hcd->usb_phy) == -ENODEV)
+ hcd->usb_phy =
+ devm_usb_get_phy_by_node(sysdev, sysdev->of_node, 0);
+
if (IS_ERR(hcd->usb_phy)) {
ret = PTR_ERR(hcd->usb_phy);
if (ret == -EPROBE_DEFER)
--
2.1.1