[PATCH] usb: dwc3: Fix the return value of gpio_request_by_name()

Venkatesh Yadav Abbarapu venkatesh.abbarapu at amd.com
Fri Jan 6 04:51:10 CET 2023


As the "reset-gpios" property is optional, don't return the
error and just skip the gpio reset sequence.

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu at amd.com>
---

 drivers/usb/dwc3/dwc3-generic.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 78966718d0..e88e0b2e5a 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -93,21 +93,21 @@ static int dwc3_generic_probe(struct udevice *dev,
 	    device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) {
 		rc = gpio_request_by_name(dev->parent, "reset-gpios", 0,
 					  &priv->ulpi_reset, GPIOD_ACTIVE_LOW);
-		if (rc)
-			return rc;
+		/* property is optional, don't return error! */
+		if (rc != -ENOENT) {
+			/* Toggle ulpi to reset the phy. */
+			rc = dm_gpio_set_value(&priv->ulpi_reset, 1);
+			if (rc)
+				return rc;
 
-		/* Toggle ulpi to reset the phy. */
-		rc = dm_gpio_set_value(&priv->ulpi_reset, 1);
-		if (rc)
-			return rc;
+			mdelay(5);
 
-		mdelay(5);
+			rc = dm_gpio_set_value(&priv->ulpi_reset, 0);
+			if (rc)
+				return rc;
 
-		rc = dm_gpio_set_value(&priv->ulpi_reset, 0);
-		if (rc)
-			return rc;
-
-		mdelay(5);
+			mdelay(5);
+		}
 	}
 
 	if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3"))
-- 
2.17.1



More information about the U-Boot mailing list