From: Kishon Vijay Abraham I <kishon@ti.com>
To: <gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>
Cc: <kishon@ti.com>, Felipe Balbi <balbi@ti.com>
Subject: [PATCH 1/4] phy: core: properly handle failure of pm_runtime_get functions
Date: Thu, 26 Dec 2013 22:17:17 +0530 [thread overview]
Message-ID: <1388076440-7620-2-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1388076440-7620-1-git-send-email-kishon@ti.com>
From: Felipe Balbi <balbi@ti.com>
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>
---
drivers/phy/phy-core.c | 16 ++++++++++++++--
1 file 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);
--
1.7.10.4
next prev parent reply other threads:[~2013-12-26 16:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-26 16:47 [GIT PULL 0/4] PHY: for 3.14 Kishon Vijay Abraham I
2013-12-26 16:47 ` Kishon Vijay Abraham I [this message]
2013-12-26 16:47 ` [PATCH 2/4] phy: phy-core: increment refcounting variables only on 'success' Kishon Vijay Abraham I
2013-12-26 16:47 ` [PATCH 3/4] phy: phy-core.c: remove unnecessary initialization of local variables Kishon Vijay Abraham I
2013-12-26 16:47 ` [PATCH 4/4] Phy: Add a PHY driver for Marvell MVEBU SATA PHY Kishon Vijay Abraham I
2014-01-08 5:24 ` [GIT PULL 0/4] PHY: for 3.14 Kishon Vijay Abraham I
2014-01-09 3:36 ` Greg KH
2014-01-09 5:58 ` Kishon Vijay Abraham I
2014-01-09 4:14 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1388076440-7620-2-git-send-email-kishon@ti.com \
--to=kishon@ti.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®