diff mbox

[U-Boot,4/4] usb: host: ohci-generic: initialize PHY only when found

Message ID 1500908825-31658-5-git-send-email-patrice.chotard@st.com
State Accepted
Commit 2080d023d90e2972f82dfde624d209cf5a0c569c
Delegated to: Marek Vasut
Headers show

Commit Message

Patrice CHOTARD July 24, 2017, 3:07 p.m. UTC
From: Patrice Chotard <patrice.chotard@st.com>

Call generic_phy_init() only when a PHY was found.
This will avoid a crash if no "phys" property is found in DT.

Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reported-by: Patrick Delaunay <patrick.delaunay@st.com>
---
 drivers/usb/host/ohci-generic.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Simon Glass Aug. 6, 2017, 5:15 a.m. UTC | #1
On 24 July 2017 at 09:07,  <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> Call generic_phy_init() only when a PHY was found.
> This will avoid a crash if no "phys" property is found in DT.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Reported-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>  drivers/usb/host/ohci-generic.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index 9249039..e22ee97 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -91,12 +91,13 @@  static int ohci_usb_probe(struct udevice *dev)
 			error("failed to get usb phy\n");
 			goto reset_err;
 		}
-	}
+	} else {
 
-	err = generic_phy_init(&priv->phy);
-	if (err) {
-		error("failed to init usb phy\n");
-		goto reset_err;
+		err = generic_phy_init(&priv->phy);
+		if (err) {
+			error("failed to init usb phy\n");
+			goto reset_err;
+		}
 	}
 
 	err = ohci_register(dev, regs);