From 787f11f0cfedbafcebe20f847f4f775de683419a Mon Sep 17 00:00:00 2001 From: Wu Liang feng Date: Mon, 19 Sep 2016 18:43:54 +0800 Subject: [PATCH] phy: rockchip-inno-usb2: release mutex lock if otg in host mode 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 --- drivers/phy/phy-rockchip-inno-usb2.c | 44 +++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/phy/phy-rockchip-inno-usb2.c b/drivers/phy/phy-rockchip-inno-usb2.c index f19bfe9525a6..3a530eb442ea 100644 --- a/drivers/phy/phy-rockchip-inno-usb2.c +++ b/drivers/phy/phy-rockchip-inno-usb2.c @@ -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; } -- 2.34.1