From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, s.hauer@pengutronix.de,
b38611@freescale.com, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next v2 3/4] net: phy: keep track of the PHY suspend state
Date: Mon, 26 Jan 2015 22:05:39 -0800 [thread overview]
Message-ID: <1422338740-18418-4-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1422338740-18418-1-git-send-email-f.fainelli@gmail.com>
In order to avoid double calls to phydev->drv->suspend and resume, keep
track of whether the PHY has already been suspended as a consequence of
a successful call to phy_suspend(). We will use this in our MDIO bus
suspend/resume hooks to avoid a double suspend call.
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v3:
- added missing ret initialization reported by Fugang
drivers/net/phy/phy_device.c | 22 ++++++++++++++++++----
include/linux/phy.h | 2 ++
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 3fc91e89f5a5..bdfe51fc3a65 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -699,6 +699,7 @@ int phy_suspend(struct phy_device *phydev)
{
struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
+ int ret = 0;
/* If the device has WOL enabled, we cannot suspend the PHY */
phy_ethtool_get_wol(phydev, &wol);
@@ -706,18 +707,31 @@ int phy_suspend(struct phy_device *phydev)
return -EBUSY;
if (phydrv->suspend)
- return phydrv->suspend(phydev);
- return 0;
+ ret = phydrv->suspend(phydev);
+
+ if (ret)
+ return ret;
+
+ phydev->suspended = true;
+
+ return ret;
}
EXPORT_SYMBOL(phy_suspend);
int phy_resume(struct phy_device *phydev)
{
struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
+ int ret = 0;
if (phydrv->resume)
- return phydrv->resume(phydev);
- return 0;
+ ret = phydrv->resume(phydev);
+
+ if (ret)
+ return ret;
+
+ phydev->suspended = false;
+
+ return ret;
}
EXPORT_SYMBOL(phy_resume);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 1b3690b597d5..685809835b5c 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -328,6 +328,7 @@ struct phy_c45_device_ids {
* is_c45: Set to true if this phy uses clause 45 addressing.
* is_internal: Set to true if this phy is internal to a MAC.
* has_fixups: Set to true if this phy has fixups/quirks.
+ * suspended: Set to true if this phy has been suspended successfully.
* state: state of the PHY for management purposes
* dev_flags: Device-specific flags used by the PHY driver.
* addr: Bus address of PHY
@@ -365,6 +366,7 @@ struct phy_device {
bool is_c45;
bool is_internal;
bool has_fixups;
+ bool suspended;
enum phy_state state;
--
2.1.0
next prev parent reply other threads:[~2015-01-27 6:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-27 6:05 [PATCH net-next v2 0/4] net: phy: prevent double suspend Florian Fainelli
2015-01-27 6:05 ` [PATCH net-next v2 1/4] net: phy: utilize phy_suspend and phy_resume Florian Fainelli
2015-01-27 6:05 ` [PATCH net-next v2 2/4] net: phy: document has_fixups field Florian Fainelli
2015-01-27 6:05 ` Florian Fainelli [this message]
2015-01-27 6:05 ` [PATCH net-next v2 4/4] net: phy: avoid suspending twice a PHY Florian Fainelli
2015-01-27 8:17 ` [PATCH net-next v2 0/4] net: phy: prevent double suspend David Miller
2015-01-27 19:04 ` Sergei Shtylyov
2015-01-27 19:16 ` Florian Fainelli
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=1422338740-18418-4-git-send-email-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=b38611@freescale.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).