usb: dwc3: rockchip: remove unused NULL pointer handle otg_work
authorWilliam wu <wulf@rock-chips.com>
Mon, 10 Oct 2016 04:37:51 +0000 (12:37 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 13 Oct 2016 01:51:58 +0000 (09:51 +0800)
We make sure that get drvdata dwc before register extcon
notifier and schedule otg_work, so we can remove the dwc
NULL pointer handle safely.

Also, change the WARN_ON to dev_warn, and avoid log noise.

Change-Id: Icececf3bb5ad510b91d2c3a50e2126225673605e
Signed-off-by: William wu <wulf@rock-chips.com>
drivers/usb/dwc3/dwc3-rockchip.c

index 401eb1bfbcf84833ec2ba2626c092e8d93a7725a..03cea80d93f3b0e669b40cfe1e1b96fc9aa4ac6c 100644 (file)
@@ -86,9 +86,6 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
        int                     ret;
        u32                     reg;
 
-       if (!dwc)
-               return;
-
        mutex_lock(&rockchip->lock);
 
        if (extcon_get_cable_state_(edev, EXTCON_USB) > 0) {
@@ -99,8 +96,10 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
                 * If dr_mode is host only, never to set
                 * the mode to the peripheral mode.
                 */
-               if (WARN_ON(dwc->dr_mode == USB_DR_MODE_HOST))
+               if (dwc->dr_mode == USB_DR_MODE_HOST) {
+                       dev_warn(rockchip->dev, "USB peripheral not support!\n");
                        goto out;
+               }
 
                /*
                 * Assert otg reset can put the dwc in P2 state, it's
@@ -133,8 +132,10 @@ static void dwc3_rockchip_otg_extcon_evt_work(struct work_struct *work)
                 * If dr_mode is device only, never to
                 * set the mode to the host mode.
                 */
-               if (WARN_ON(dwc->dr_mode == USB_DR_MODE_PERIPHERAL))
+               if (dwc->dr_mode == USB_DR_MODE_PERIPHERAL) {
+                       dev_warn(rockchip->dev, "USB HOST not support!\n");
                        goto out;
+               }
 
                /*
                 * Assert otg reset can put the dwc in P2 state, it's