Commit 532c6150 authored by Axel Lin's avatar Axel Lin Committed by Sasha Levin

phy: core: Fixup return value of phy_exit when !pm_runtime_enabled

[ Upstream commit 736b67a3 ]

When phy_pm_runtime_get_sync() returns -ENOTSUPP, phy_exit() also returns
-ENOTSUPP if !phy->ops->exit. Fix it.
Also move the code to override ret close to the code we got ret.
I think it is less error prone this way.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 0f97e402
...@@ -179,6 +179,7 @@ int phy_init(struct phy *phy) ...@@ -179,6 +179,7 @@ int phy_init(struct phy *phy)
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; return ret;
ret = 0; /* Override possible ret == -ENOTSUPP */
mutex_lock(&phy->mutex); mutex_lock(&phy->mutex);
if (phy->init_count == 0 && phy->ops->init) { if (phy->init_count == 0 && phy->ops->init) {
...@@ -187,8 +188,6 @@ int phy_init(struct phy *phy) ...@@ -187,8 +188,6 @@ int phy_init(struct phy *phy)
dev_err(&phy->dev, "phy init failed --> %d\n", ret); dev_err(&phy->dev, "phy init failed --> %d\n", ret);
goto out; goto out;
} }
} else {
ret = 0; /* Override possible ret == -ENOTSUPP */
} }
++phy->init_count; ++phy->init_count;
...@@ -209,6 +208,7 @@ int phy_exit(struct phy *phy) ...@@ -209,6 +208,7 @@ int phy_exit(struct phy *phy)
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; return ret;
ret = 0; /* Override possible ret == -ENOTSUPP */
mutex_lock(&phy->mutex); mutex_lock(&phy->mutex);
if (phy->init_count == 1 && phy->ops->exit) { if (phy->init_count == 1 && phy->ops->exit) {
...@@ -243,6 +243,7 @@ int phy_power_on(struct phy *phy) ...@@ -243,6 +243,7 @@ int phy_power_on(struct phy *phy)
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; return ret;
ret = 0; /* Override possible ret == -ENOTSUPP */
mutex_lock(&phy->mutex); mutex_lock(&phy->mutex);
if (phy->power_count == 0 && phy->ops->power_on) { if (phy->power_count == 0 && phy->ops->power_on) {
...@@ -251,8 +252,6 @@ int phy_power_on(struct phy *phy) ...@@ -251,8 +252,6 @@ int phy_power_on(struct phy *phy)
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
goto out; goto out;
} }
} else {
ret = 0; /* Override possible ret == -ENOTSUPP */
} }
++phy->power_count; ++phy->power_count;
mutex_unlock(&phy->mutex); mutex_unlock(&phy->mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment