phy: core: fix wrong err handle for phy_power_on

If phy_pm_runtime_get_sync failed but we already
enable regulator, current code return directly without
doing regulator_disable. This patch fix this problem
and cleanup err handle of phy_power_on to be more readable.

Fixes: 3be88125d8 ("phy: core: Support regulator ...")
Cc: <stable@vger.kernel.org> # v3.18+
Cc: Roger Quadros <rogerq@ti.com>
Cc: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
This commit is contained in:
Shawn Lin 2016-01-28 16:14:18 +08:00 committed by Kishon Vijay Abraham I
parent d896910f38
commit b82fcabe21
1 changed files with 9 additions and 7 deletions

View File

@ -275,20 +275,21 @@ EXPORT_SYMBOL_GPL(phy_exit);
int phy_power_on(struct phy *phy) int phy_power_on(struct phy *phy)
{ {
int ret; int ret = 0;
if (!phy) if (!phy)
return 0; goto out;
if (phy->pwr) { if (phy->pwr) {
ret = regulator_enable(phy->pwr); ret = regulator_enable(phy->pwr);
if (ret) if (ret)
return ret; goto out;
} }
ret = phy_pm_runtime_get_sync(phy); ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP) if (ret < 0 && ret != -ENOTSUPP)
return ret; goto err_pm_sync;
ret = 0; /* Override possible ret == -ENOTSUPP */ ret = 0; /* Override possible ret == -ENOTSUPP */
mutex_lock(&phy->mutex); mutex_lock(&phy->mutex);
@ -296,19 +297,20 @@ int phy_power_on(struct phy *phy)
ret = phy->ops->power_on(phy); ret = phy->ops->power_on(phy);
if (ret < 0) { if (ret < 0) {
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
goto out; goto err_pwr_on;
} }
} }
++phy->power_count; ++phy->power_count;
mutex_unlock(&phy->mutex); mutex_unlock(&phy->mutex);
return 0; return 0;
out: err_pwr_on:
mutex_unlock(&phy->mutex); mutex_unlock(&phy->mutex);
phy_pm_runtime_put_sync(phy); phy_pm_runtime_put_sync(phy);
err_pm_sync:
if (phy->pwr) if (phy->pwr)
regulator_disable(phy->pwr); regulator_disable(phy->pwr);
out:
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(phy_power_on); EXPORT_SYMBOL_GPL(phy_power_on);