Skip to content

Commit

Permalink
phy: core: fix wrong err handle for phy_power_on
Browse files Browse the repository at this point in the history
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: 3be8812 ("phy: core: Support regulator ...")
Cc: <[email protected]> # v3.18+
Cc: Roger Quadros <[email protected]>
Cc: Axel Lin <[email protected]>
Signed-off-by: Shawn Lin <[email protected]>
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
  • Loading branch information
shawn1221 authored and kishon committed Feb 10, 2016
1 parent d896910 commit b82fcab
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions drivers/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,40 +275,42 @@ EXPORT_SYMBOL_GPL(phy_exit);

int phy_power_on(struct phy *phy)
{
int ret;
int ret = 0;

if (!phy)
return 0;
goto out;

if (phy->pwr) {
ret = regulator_enable(phy->pwr);
if (ret)
return ret;
goto out;
}

ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP)
return ret;
goto err_pm_sync;

ret = 0; /* Override possible ret == -ENOTSUPP */

mutex_lock(&phy->mutex);
if (phy->power_count == 0 && phy->ops->power_on) {
ret = phy->ops->power_on(phy);
if (ret < 0) {
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
goto out;
goto err_pwr_on;
}
}
++phy->power_count;
mutex_unlock(&phy->mutex);
return 0;

out:
err_pwr_on:
mutex_unlock(&phy->mutex);
phy_pm_runtime_put_sync(phy);
err_pm_sync:
if (phy->pwr)
regulator_disable(phy->pwr);

out:
return ret;
}
EXPORT_SYMBOL_GPL(phy_power_on);
Expand Down

0 comments on commit b82fcab

Please sign in to comment.