Skip to content

Commit b82fcab

Browse files
shawn1221kishon
authored andcommitted
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: 3be8812 ("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>
1 parent d896910 commit b82fcab

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/phy/phy-core.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,40 +275,42 @@ EXPORT_SYMBOL_GPL(phy_exit);
275275

276276
int phy_power_on(struct phy *phy)
277277
{
278-
int ret;
278+
int ret = 0;
279279

280280
if (!phy)
281-
return 0;
281+
goto out;
282282

283283
if (phy->pwr) {
284284
ret = regulator_enable(phy->pwr);
285285
if (ret)
286-
return ret;
286+
goto out;
287287
}
288288

289289
ret = phy_pm_runtime_get_sync(phy);
290290
if (ret < 0 && ret != -ENOTSUPP)
291-
return ret;
291+
goto err_pm_sync;
292+
292293
ret = 0; /* Override possible ret == -ENOTSUPP */
293294

294295
mutex_lock(&phy->mutex);
295296
if (phy->power_count == 0 && phy->ops->power_on) {
296297
ret = phy->ops->power_on(phy);
297298
if (ret < 0) {
298299
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
299-
goto out;
300+
goto err_pwr_on;
300301
}
301302
}
302303
++phy->power_count;
303304
mutex_unlock(&phy->mutex);
304305
return 0;
305306

306-
out:
307+
err_pwr_on:
307308
mutex_unlock(&phy->mutex);
308309
phy_pm_runtime_put_sync(phy);
310+
err_pm_sync:
309311
if (phy->pwr)
310312
regulator_disable(phy->pwr);
311-
313+
out:
312314
return ret;
313315
}
314316
EXPORT_SYMBOL_GPL(phy_power_on);

0 commit comments

Comments
 (0)