[PATCH 2/5] usb: cdns3: avoid error messages if phys don't exist

Roger Quadros rogerq at kernel.org
Fri Jan 12 13:49:48 CET 2024


The phys property is optional so don't complain
if it doesn't exist in device tree.

Signed-off-by: Roger Quadros <rogerq at kernel.org>
---
 drivers/usb/cdns3/core.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
index 644a9791b9..12a741c6ea 100644
--- a/drivers/usb/cdns3/core.c
+++ b/drivers/usb/cdns3/core.c
@@ -333,20 +333,28 @@ static int cdns3_probe(struct cdns3 *cdns)
 	mutex_init(&cdns->mutex);
 
 	ret = generic_phy_get_by_name(dev, "cdns3,usb2-phy", &cdns->usb2_phy);
-	if (ret)
-		dev_warn(dev, "Unable to get USB2 phy (ret %d)\n", ret);
-
-	ret = generic_phy_init(&cdns->usb2_phy);
-	if (ret)
+	if (!ret) {
+		ret = generic_phy_init(&cdns->usb2_phy);
+		if (ret) {
+			dev_err(dev, "USB2 PHY init failed: %d\n", ret);
+			return ret;
+		}
+	} else if (ret != -ENOENT && ret != -ENODATA) {
+		dev_err(dev, "Couldn't get USB2 PHY:  %d\n", ret);
 		return ret;
+	}
 
 	ret = generic_phy_get_by_name(dev, "cdns3,usb3-phy", &cdns->usb3_phy);
-	if (ret)
-		dev_warn(dev, "Unable to get USB3 phy (ret %d)\n", ret);
-
-	ret = generic_phy_init(&cdns->usb3_phy);
-	if (ret)
+	if (!ret) {
+		ret = generic_phy_init(&cdns->usb3_phy);
+		if (ret) {
+			dev_err(dev, "USB3 PHY init failed: %d\n", ret);
+			return ret;
+		}
+	} else if (ret != -ENOENT && ret != -ENODATA) {
+		dev_err(dev, "Couldn't get USB3 PHY:  %d\n", ret);
 		return ret;
+	}
 
 	ret = generic_phy_power_on(&cdns->usb2_phy);
 	if (ret)
-- 
2.34.1



More information about the U-Boot mailing list