usb: dwc3: fix PHY error handling
authorFelipe Balbi <balbi@ti.com>
Fri, 15 Mar 2013 08:52:08 +0000 (10:52 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 18 Mar 2013 09:18:28 +0000 (11:18 +0200)
PHY layer no longer returns NULL. It will
return -ENXIO when PHY layer isn't enabled
and we can use that to bail out instead of
request a probe deferral.

Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc3/core.c

index c845e7087069fc6407f09d54c3b463f786daf6df..e2325adf9c14f92e9e7789239e42a7d9fb72d877 100644 (file)
@@ -434,12 +434,32 @@ static int dwc3_probe(struct platform_device *pdev)
                dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3);
        }
 
-       if (IS_ERR_OR_NULL(dwc->usb2_phy)) {
+       if (IS_ERR(dwc->usb2_phy)) {
+               ret = PTR_ERR(dwc->usb2_phy);
+
+               /*
+                * if -ENXIO is returned, it means PHY layer wasn't
+                * enabled, so it makes no sense to return -EPROBE_DEFER
+                * in that case, since no PHY driver will ever probe.
+                */
+               if (ret == -ENXIO)
+                       return ret;
+
                dev_err(dev, "no usb2 phy configured\n");
                return -EPROBE_DEFER;
        }
 
-       if (IS_ERR_OR_NULL(dwc->usb3_phy)) {
+       if (IS_ERR(dwc->usb3_phy)) {
+               ret = PTR_ERR(dwc->usb2_phy);
+
+               /*
+                * if -ENXIO is returned, it means PHY layer wasn't
+                * enabled, so it makes no sense to return -EPROBE_DEFER
+                * in that case, since no PHY driver will ever probe.
+                */
+               if (ret == -ENXIO)
+                       return ret;
+
                dev_err(dev, "no usb3 phy configured\n");
                return -EPROBE_DEFER;
        }