phy: rockchip-inno-usb2: release mutex lock if otg in host mode
authorWu Liang feng <wulf@rock-chips.com>
Mon, 19 Sep 2016 10:43:54 +0000 (18:43 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 21 Sep 2016 06:02:48 +0000 (14:02 +0800)
We add a mutex lock in rockchip_usb2phy_init(), but foget to
release it if otg port work in host only mode.

Change-Id: I45abf173097be4463b668b51eece99a72047fb18
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
drivers/phy/phy-rockchip-inno-usb2.c

index f19bfe9525a64d593c258e3fb5c9332ca6caf30d..3a530eb442ea64836865fffa4735520263702afd 100644 (file)
@@ -410,43 +410,45 @@ static int rockchip_usb2phy_init(struct phy *phy)
 {
        struct rockchip_usb2phy_port *rport = phy_get_drvdata(phy);
        struct rockchip_usb2phy *rphy = dev_get_drvdata(phy->dev.parent);
-       int ret;
+       int ret = 0;
 
        mutex_lock(&rport->mutex);
 
-       if (rport->port_id == USB2PHY_PORT_OTG &&
-           rport->mode != USB_DR_MODE_HOST) {
-               /* clear bvalid status and enable bvalid detect irq */
-               ret = property_enable(rphy,
-                                     &rport->port_cfg->bvalid_det_clr, true);
-               if (ret)
-                       goto err;
-
-               ret = property_enable(rphy,
-                                     &rport->port_cfg->bvalid_det_en, true);
-               if (ret)
-                       goto err;
+       if (rport->port_id == USB2PHY_PORT_OTG) {
+               if (rport->mode != USB_DR_MODE_HOST) {
+                       /* clear bvalid status and enable bvalid detect irq */
+                       ret = property_enable(rphy,
+                                             &rport->port_cfg->bvalid_det_clr,
+                                             true);
+                       if (ret)
+                               goto out;
 
-               mutex_unlock(&rport->mutex);
-               schedule_delayed_work(&rport->otg_sm_work, OTG_SCHEDULE_DELAY);
+                       ret = property_enable(rphy,
+                                             &rport->port_cfg->bvalid_det_en,
+                                             true);
+                       if (ret)
+                               goto out;
 
+                       schedule_delayed_work(&rport->otg_sm_work,
+                                             OTG_SCHEDULE_DELAY);
+               } else {
+                       /* If OTG works in host only mode, do nothing. */
+                       dev_dbg(&rport->phy->dev, "mode %d\n", rport->mode);
+               }
        } else if (rport->port_id == USB2PHY_PORT_HOST) {
                /* clear linestate and enable linestate detect irq */
                ret = property_enable(rphy, &rport->port_cfg->ls_det_clr, true);
                if (ret)
-                       goto err;
+                       goto out;
 
                ret = property_enable(rphy, &rport->port_cfg->ls_det_en, true);
                if (ret)
-                       goto err;
+                       goto out;
 
-               mutex_unlock(&rport->mutex);
                schedule_delayed_work(&rport->sm_work, SCHEDULE_DELAY);
        }
 
-       return 0;
-
-err:
+out:
        mutex_unlock(&rport->mutex);
        return ret;
 }