usb: dwc3: rockchip: fix xhci NULL pointer dereference

If DWC3 works as peripheral only mode, XHCI HCD will
not be created and added, so we should only get XHCI
HCD in host mode.

Change-Id: Iefb02431d6a973050986963bbabe0a943283f4b3
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
This commit is contained in:
Wu Liang feng
2016-10-13 14:08:52 +08:00
committed by Huang, Tao
parent 3300229ada
commit 499fcb657a

View File

@@ -81,7 +81,7 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
container_of(work, struct dwc3_rockchip, otg_work);
struct dwc3 *dwc = rockchip->dwc;
struct extcon_dev *edev = rockchip->edev;
struct usb_hcd *hcd = dev_get_drvdata(&dwc->xhci->dev);
struct usb_hcd *hcd;
unsigned long flags;
int ret;
u32 reg;
@@ -180,6 +180,8 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
*/
usleep_range(10000, 11000);
hcd = dev_get_drvdata(&dwc->xhci->dev);
if (hcd->state == HC_STATE_HALT) {
usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
usb_add_hcd(hcd->shared_hcd, hcd->irq, IRQF_SHARED);