usb: dwc3: fix logical error during controller probe
authorMeng Dongyang <daniel.meng@rock-chips.com>
Sun, 11 Sep 2016 08:27:57 +0000 (16:27 +0800)
committerKever Yang <kever.yang@rock-chips.com>
Fri, 23 Sep 2016 10:26:06 +0000 (18:26 +0800)
The probe function of usb controller will remove hcd struct in host
or otg mode, while the hcd is alloced after xhci driver registed. So
there is a logical error if xhci driver is registed after usb
controller and it results in the pointer of hcd point to NULL. This
patch make usb controller probe again if hcd point to NULL.

Change-Id: I659f86decac59fca610b355356fc971b3a86d4be
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
drivers/usb/dwc3/dwc3-rockchip.c

index 90c34c699e7ef502e5ad591c847ea7dc6f63ef2b..6f549b58b209fb0d8b6fb3350fce81a4133f11f7 100644 (file)
@@ -332,7 +332,11 @@ static int dwc3_rockchip_probe(struct platform_device *pdev)
                    rockchip->dwc->dr_mode == USB_DR_MODE_OTG) {
                        struct usb_hcd *hcd =
                                dev_get_drvdata(&rockchip->dwc->xhci->dev);
-
+                       if (!hcd) {
+                               dev_err(dev, "fail to get drvdata hcd\n");
+                               ret = -EPROBE_DEFER;
+                               goto err2;
+                       }
                        if (hcd->state != HC_STATE_HALT) {
                                usb_remove_hcd(hcd->shared_hcd);
                                usb_remove_hcd(hcd);