commit
b82fcabe212a11698fd4b3e604d2f81d929d22f6 upstream.
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: 3be88125d85d ("phy: core: Support regulator ...")
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
int phy_power_on(struct phy *phy)
{
int phy_power_on(struct phy *phy)
{
if (phy->pwr) {
ret = regulator_enable(phy->pwr);
if (ret)
if (phy->pwr) {
ret = regulator_enable(phy->pwr);
if (ret)
}
ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP)
}
ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP)
ret = 0; /* Override possible ret == -ENOTSUPP */
mutex_lock(&phy->mutex);
ret = 0; /* Override possible ret == -ENOTSUPP */
mutex_lock(&phy->mutex);
ret = phy->ops->power_on(phy);
if (ret < 0) {
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
ret = phy->ops->power_on(phy);
if (ret < 0) {
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
}
}
++phy->power_count;
mutex_unlock(&phy->mutex);
return 0;
}
}
++phy->power_count;
mutex_unlock(&phy->mutex);
return 0;
mutex_unlock(&phy->mutex);
phy_pm_runtime_put_sync(phy);
mutex_unlock(&phy->mutex);
phy_pm_runtime_put_sync(phy);
if (phy->pwr)
regulator_disable(phy->pwr);
if (phy->pwr)
regulator_disable(phy->pwr);
return ret;
}
EXPORT_SYMBOL_GPL(phy_power_on);
return ret;
}
EXPORT_SYMBOL_GPL(phy_power_on);