aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/phy/phy-core.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2013-12-20 16:00:48 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2013-12-24 13:22:58 -0500
commitcedb7f89d1e1f631b7e5d920fe1ea7f742d07f79 (patch)
tree77d10767ded08d3d950f33b3f500abf2f7e1fd0d /drivers/phy/phy-core.c
parent413541dd66d51f791a0b169d9b9014e4f56be13c (diff)
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>
Diffstat (limited to 'drivers/phy/phy-core.c')
-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 58e0e9739028..8797bb7d9c48 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)
94 94
95int phy_pm_runtime_get(struct phy *phy) 95int phy_pm_runtime_get(struct phy *phy)
96{ 96{
97 int ret;
98
97 if (!pm_runtime_enabled(&phy->dev)) 99 if (!pm_runtime_enabled(&phy->dev))
98 return -ENOTSUPP; 100 return -ENOTSUPP;
99 101
100 return pm_runtime_get(&phy->dev); 102 ret = pm_runtime_get(&phy->dev);
103 if (ret < 0 && ret != -EINPROGRESS)
104 pm_runtime_put_noidle(&phy->dev);
105
106 return ret;
101} 107}
102EXPORT_SYMBOL_GPL(phy_pm_runtime_get); 108EXPORT_SYMBOL_GPL(phy_pm_runtime_get);
103 109
104int phy_pm_runtime_get_sync(struct phy *phy) 110int phy_pm_runtime_get_sync(struct phy *phy)
105{ 111{
112 int ret;
113
106 if (!pm_runtime_enabled(&phy->dev)) 114 if (!pm_runtime_enabled(&phy->dev))
107 return -ENOTSUPP; 115 return -ENOTSUPP;
108 116
109 return pm_runtime_get_sync(&phy->dev); 117 ret = pm_runtime_get_sync(&phy->dev);
118 if (ret < 0)
119 pm_runtime_put_sync(&phy->dev);
120
121 return ret;
110} 122}
111EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync); 123EXPORT_SYMBOL_GPL(phy_pm_runtime_get_sync);
112 124