aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Lin <shawn.lin@rock-chips.com>2016-01-28 03:14:18 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2016-02-10 01:15:41 -0500
commitb82fcabe212a11698fd4b3e604d2f81d929d22f6 (patch)
treeb41eac1f9d5cc25472d465092744cc0b30d6800b
parentd896910f381737a139686eb3fa9e1c7ce8f59e52 (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.c16
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
276int phy_power_on(struct phy *phy) 276int 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
306out: 307err_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);
310err_pm_sync:
309 if (phy->pwr) 311 if (phy->pwr)
310 regulator_disable(phy->pwr); 312 regulator_disable(phy->pwr);
311 313out:
312 return ret; 314 return ret;
313} 315}
314EXPORT_SYMBOL_GPL(phy_power_on); 316EXPORT_SYMBOL_GPL(phy_power_on);