Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1330925

[PATCH 2/4] phy: core: fix wrong err handle for phy_power_on

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Kishon Vijay Abraham I <kishon@ti.com>
Newsgroups linux.kernel
Subject [PATCH 2/4] phy: core: fix wrong err handle for phy_power_on
Date Wed, 10 Feb 2016 07:50:02 +0100
Message-ID <r0wL8-76e-5@gated-at.bofh.it> (permalink)
References <r0wL8-76e-3@gated-at.bofh.it>
X-Mailer git-send-email 1.7.9.5
MIME-Version 1.0
Content-Type text/plain
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 73
Organization linux.* mail to news gateway
X-Original-Cc <linux-kernel@vger.kernel.org>
X-Original-Date Wed, 10 Feb 2016 12:15:06 +0530
X-Original-Message-ID <1455086708-31253-3-git-send-email-kishon@ti.com>
X-Original-References <1455086708-31253-1-git-send-email-kishon@ti.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1330925

Show key headers only | View raw


From: Shawn Lin <shawn.lin@rock-chips.com>

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>
---
 drivers/phy/phy-core.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 8c7f27d..e7e574d 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -275,20 +275,21 @@ EXPORT_SYMBOL_GPL(phy_exit);
 
 int phy_power_on(struct phy *phy)
 {
-	int ret;
+	int ret = 0;
 
 	if (!phy)
-		return 0;
+		goto out;
 
 	if (phy->pwr) {
 		ret = regulator_enable(phy->pwr);
 		if (ret)
-			return ret;
+			goto out;
 	}
 
 	ret = phy_pm_runtime_get_sync(phy);
 	if (ret < 0 && ret != -ENOTSUPP)
-		return ret;
+		goto err_pm_sync;
+
 	ret = 0; /* Override possible ret == -ENOTSUPP */
 
 	mutex_lock(&phy->mutex);
@@ -296,19 +297,20 @@ int phy_power_on(struct phy *phy)
 		ret = phy->ops->power_on(phy);
 		if (ret < 0) {
 			dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
-			goto out;
+			goto err_pwr_on;
 		}
 	}
 	++phy->power_count;
 	mutex_unlock(&phy->mutex);
 	return 0;
 
-out:
+err_pwr_on:
 	mutex_unlock(&phy->mutex);
 	phy_pm_runtime_put_sync(phy);
+err_pm_sync:
 	if (phy->pwr)
 		regulator_disable(phy->pwr);
-
+out:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(phy_power_on);
-- 
1.7.9.5

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL] phy: for-4.5 -rc cycle Kishon Vijay Abraham I <kishon@ti.com> - 2016-02-10 07:50 +0100
  [PATCH 2/4] phy: core: fix wrong err handle for phy_power_on Kishon Vijay Abraham I <kishon@ti.com> - 2016-02-10 07:50 +0100
  [PATCH 3/4] phy: twl4030-usb: Relase usb phy on unload Kishon Vijay Abraham I <kishon@ti.com> - 2016-02-10 07:50 +0100
  [PATCH 4/4] phy: twl4030-usb: Fix unbalanced pm_runtime_enable on module reload Kishon Vijay Abraham I <kishon@ti.com> - 2016-02-10 07:50 +0100
  [PATCH 1/4] phy: Restrict phy-hi6220-usb to HiSilicon arm64 Kishon Vijay Abraham I <kishon@ti.com> - 2016-02-10 07:50 +0100
  Re: [GIT PULL] phy: for-4.5 -rc cycle Greg KH <gregkh@linuxfoundation.org> - 2016-02-12 05:20 +0100

csiph-web