diff options
author | Axel Lin <axel.lin@ingics.com> | 2015-03-06 02:55:10 -0500 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2015-03-13 07:44:38 -0400 |
commit | 736b67a32062240592aad49033859f9712dd18ca (patch) | |
tree | e36f4f7794a6f770e18b0f49f0846884993185fb | |
parent | 018e6ff3c09f32b8743e06870c4dd6ed9a0b7ff5 (diff) |
phy: core: Fixup return value of phy_exit when !pm_runtime_enabled
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 <axel.lin@ingics.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
-rw-r--r-- | drivers/phy/phy-core.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 04fc84f2b289..3791838f4bd4 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c | |||
@@ -225,6 +225,7 @@ int phy_init(struct phy *phy) | |||
225 | ret = phy_pm_runtime_get_sync(phy); | 225 | ret = phy_pm_runtime_get_sync(phy); |
226 | if (ret < 0 && ret != -ENOTSUPP) | 226 | if (ret < 0 && ret != -ENOTSUPP) |
227 | return ret; | 227 | return ret; |
228 | ret = 0; /* Override possible ret == -ENOTSUPP */ | ||
228 | 229 | ||
229 | mutex_lock(&phy->mutex); | 230 | mutex_lock(&phy->mutex); |
230 | if (phy->init_count == 0 && phy->ops->init) { | 231 | if (phy->init_count == 0 && phy->ops->init) { |
@@ -233,8 +234,6 @@ int phy_init(struct phy *phy) | |||
233 | dev_err(&phy->dev, "phy init failed --> %d\n", ret); | 234 | dev_err(&phy->dev, "phy init failed --> %d\n", ret); |
234 | goto out; | 235 | goto out; |
235 | } | 236 | } |
236 | } else { | ||
237 | ret = 0; /* Override possible ret == -ENOTSUPP */ | ||
238 | } | 237 | } |
239 | ++phy->init_count; | 238 | ++phy->init_count; |
240 | 239 | ||
@@ -255,6 +254,7 @@ int phy_exit(struct phy *phy) | |||
255 | ret = phy_pm_runtime_get_sync(phy); | 254 | ret = phy_pm_runtime_get_sync(phy); |
256 | if (ret < 0 && ret != -ENOTSUPP) | 255 | if (ret < 0 && ret != -ENOTSUPP) |
257 | return ret; | 256 | return ret; |
257 | ret = 0; /* Override possible ret == -ENOTSUPP */ | ||
258 | 258 | ||
259 | mutex_lock(&phy->mutex); | 259 | mutex_lock(&phy->mutex); |
260 | if (phy->init_count == 1 && phy->ops->exit) { | 260 | if (phy->init_count == 1 && phy->ops->exit) { |
@@ -289,6 +289,7 @@ int phy_power_on(struct phy *phy) | |||
289 | ret = phy_pm_runtime_get_sync(phy); | 289 | ret = phy_pm_runtime_get_sync(phy); |
290 | if (ret < 0 && ret != -ENOTSUPP) | 290 | if (ret < 0 && ret != -ENOTSUPP) |
291 | return ret; | 291 | return ret; |
292 | ret = 0; /* Override possible ret == -ENOTSUPP */ | ||
292 | 293 | ||
293 | mutex_lock(&phy->mutex); | 294 | mutex_lock(&phy->mutex); |
294 | if (phy->power_count == 0 && phy->ops->power_on) { | 295 | if (phy->power_count == 0 && phy->ops->power_on) { |
@@ -297,8 +298,6 @@ int phy_power_on(struct phy *phy) | |||
297 | dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); | 298 | dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); |
298 | goto out; | 299 | goto out; |
299 | } | 300 | } |
300 | } else { | ||
301 | ret = 0; /* Override possible ret == -ENOTSUPP */ | ||
302 | } | 301 | } |
303 | ++phy->power_count; | 302 | ++phy->power_count; |
304 | mutex_unlock(&phy->mutex); | 303 | mutex_unlock(&phy->mutex); |