diff options
author | Shawn Lin <shawn.lin@rock-chips.com> | 2016-01-28 03:14:18 -0500 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2016-02-10 01:15:41 -0500 |
commit | b82fcabe212a11698fd4b3e604d2f81d929d22f6 (patch) | |
tree | b41eac1f9d5cc25472d465092744cc0b30d6800b | |
parent | d896910f381737a139686eb3fa9e1c7ce8f59e52 (diff) |
phy: core: fix wrong err handle for phy_power_on
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: <stable@vger.kernel.org> # v3.18+
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>
-rw-r--r-- | drivers/phy/phy-core.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 8c7f27db6ad3..e7e574dc667a 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c | |||
@@ -275,20 +275,21 @@ EXPORT_SYMBOL_GPL(phy_exit); | |||
275 | 275 | ||
276 | int phy_power_on(struct phy *phy) | 276 | int phy_power_on(struct phy *phy) |
277 | { | 277 | { |
278 | int ret; | 278 | int ret = 0; |
279 | 279 | ||
280 | if (!phy) | 280 | if (!phy) |
281 | return 0; | 281 | goto out; |
282 | 282 | ||
283 | if (phy->pwr) { | 283 | if (phy->pwr) { |
284 | ret = regulator_enable(phy->pwr); | 284 | ret = regulator_enable(phy->pwr); |
285 | if (ret) | 285 | if (ret) |
286 | return ret; | 286 | goto out; |
287 | } | 287 | } |
288 | 288 | ||
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 | goto err_pm_sync; |
292 | |||
292 | ret = 0; /* Override possible ret == -ENOTSUPP */ | 293 | ret = 0; /* Override possible ret == -ENOTSUPP */ |
293 | 294 | ||
294 | mutex_lock(&phy->mutex); | 295 | mutex_lock(&phy->mutex); |
@@ -296,19 +297,20 @@ int phy_power_on(struct phy *phy) | |||
296 | ret = phy->ops->power_on(phy); | 297 | ret = phy->ops->power_on(phy); |
297 | if (ret < 0) { | 298 | if (ret < 0) { |
298 | dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); | 299 | dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); |
299 | goto out; | 300 | goto err_pwr_on; |
300 | } | 301 | } |
301 | } | 302 | } |
302 | ++phy->power_count; | 303 | ++phy->power_count; |
303 | mutex_unlock(&phy->mutex); | 304 | mutex_unlock(&phy->mutex); |
304 | return 0; | 305 | return 0; |
305 | 306 | ||
306 | out: | 307 | err_pwr_on: |
307 | mutex_unlock(&phy->mutex); | 308 | mutex_unlock(&phy->mutex); |
308 | phy_pm_runtime_put_sync(phy); | 309 | phy_pm_runtime_put_sync(phy); |
310 | err_pm_sync: | ||
309 | if (phy->pwr) | 311 | if (phy->pwr) |
310 | regulator_disable(phy->pwr); | 312 | regulator_disable(phy->pwr); |
311 | 313 | out: | |
312 | return ret; | 314 | return ret; |
313 | } | 315 | } |
314 | EXPORT_SYMBOL_GPL(phy_power_on); | 316 | EXPORT_SYMBOL_GPL(phy_power_on); |