Skip to content

Commit

Permalink
phy: core: Fixup return value of phy_exit when !pm_runtime_enabled
Browse files Browse the repository at this point in the history
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: Axel Lin <[email protected]>
Acked-by: Roger Quadros <[email protected]>
Signed-off-by: Kishon Vijay Abraham I <[email protected]>
  • Loading branch information
AxelLin authored and kishon committed Mar 13, 2015
1 parent 018e6ff commit 736b67a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ int phy_init(struct phy *phy)
ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP)
return ret;
ret = 0; /* Override possible ret == -ENOTSUPP */

mutex_lock(&phy->mutex);
if (phy->init_count == 0 && phy->ops->init) {
Expand All @@ -233,8 +234,6 @@ int phy_init(struct phy *phy)
dev_err(&phy->dev, "phy init failed --> %d\n", ret);
goto out;
}
} else {
ret = 0; /* Override possible ret == -ENOTSUPP */
}
++phy->init_count;

Expand All @@ -255,6 +254,7 @@ int phy_exit(struct phy *phy)
ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP)
return ret;
ret = 0; /* Override possible ret == -ENOTSUPP */

mutex_lock(&phy->mutex);
if (phy->init_count == 1 && phy->ops->exit) {
Expand Down Expand Up @@ -289,6 +289,7 @@ int phy_power_on(struct phy *phy)
ret = phy_pm_runtime_get_sync(phy);
if (ret < 0 && ret != -ENOTSUPP)
return ret;
ret = 0; /* Override possible ret == -ENOTSUPP */

mutex_lock(&phy->mutex);
if (phy->power_count == 0 && phy->ops->power_on) {
Expand All @@ -297,8 +298,6 @@ int phy_power_on(struct phy *phy)
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
goto out;
}
} else {
ret = 0; /* Override possible ret == -ENOTSUPP */
}
++phy->power_count;
mutex_unlock(&phy->mutex);
Expand Down

0 comments on commit 736b67a

Please sign in to comment.