summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-12-20 21:00:48 (GMT)
committerMarek Szyprowski <m.szyprowski@samsung.com>2014-05-15 05:29:17 (GMT)
commitc668359a608067364be7a2a9325a09cc6fe7835e (patch)
tree281e178c2881255d7d7610854ab139e08eb2b18e
parent0865e22f6a7287a79e6f62c34b116f9acb5ff293 (diff)
downloadlinux-3.10-c668359a608067364be7a2a9325a09cc6fe7835e.zip
linux-3.10-c668359a608067364be7a2a9325a09cc6fe7835e.tar.gz
linux-3.10-c668359a608067364be7a2a9325a09cc6fe7835e.tar.bz2
phy: core: properly handle failure of pm_runtime_get functions
In case pm_runtime_get*() fails, it still increments pm usage counter, so we *must* make sure to pm_runtime_put() even in those cases. This patch fixes that mistake the same way usbcore treats those possible failures. Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> [backport from upstream commit cedb7f89d1e1f631b7e5d920fe1ea7f742d07f79] Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Change-Id: I8de0a4c76c5ad3de2d45996504f3f1aa716dc017
-rw-r--r--drivers/phy/phy-core.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 58e0e97..8797bb7 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -94,19 +94,31 @@ static struct phy_provider *of_phy_provider_lookup(struct device_node *node)
int phy_pm_runtime_get(struct phy *phy)
{
+ int ret;
+
if (!pm_runtime_enabled(&phy->dev))
return -ENOTSUPP;
- return pm_runtime_get(&phy->dev);
+ ret = pm_runtime_get(&phy->dev);
+ if (ret < 0 && ret != -EINPROGRESS)
+ pm_runtime_put_noidle(&phy->dev);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(phy_pm_runtime_get);
int phy_pm_runtime_get_sync(struct phy *phy)
{
+ int ret;
+
if (!pm_runtime_enabled(&phy->dev))
return -ENOTSUPP;
- return pm_runtime_get_sync(&phy->dev);
+ ret = pm_runtime_get_sync(&phy->dev);
+ if (ret < 0)
+ pm_runtime_put_sync(&phy->dev);
+
+ return ret;
}
EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync);