aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2015-01-27 01:05:39 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-27 03:16:51 -0500
commit8a477a6fb6a33651adda772360b85fd813569743 (patch)
treeb9b22fb33dbeecda77bb31d3cbb0b0fe0b9547cd
parentaae88261abd58fffef7ee0e00160ce4ea105b0f3 (diff)
net: phy: keep track of the PHY suspend state
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> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/phy/phy_device.c22
-rw-r--r--include/linux/phy.h2
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)
699{ 699{
700 struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver); 700 struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
701 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; 701 struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
702 int ret = 0;
702 703
703 /* If the device has WOL enabled, we cannot suspend the PHY */ 704 /* If the device has WOL enabled, we cannot suspend the PHY */
704 phy_ethtool_get_wol(phydev, &wol); 705 phy_ethtool_get_wol(phydev, &wol);
@@ -706,18 +707,31 @@ int phy_suspend(struct phy_device *phydev)
706 return -EBUSY; 707 return -EBUSY;
707 708
708 if (phydrv->suspend) 709 if (phydrv->suspend)
709 return phydrv->suspend(phydev); 710 ret = phydrv->suspend(phydev);
710 return 0; 711
712 if (ret)
713 return ret;
714
715 phydev->suspended = true;
716
717 return ret;
711} 718}
712EXPORT_SYMBOL(phy_suspend); 719EXPORT_SYMBOL(phy_suspend);
713 720
714int phy_resume(struct phy_device *phydev) 721int phy_resume(struct phy_device *phydev)
715{ 722{
716 struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver); 723 struct phy_driver *phydrv = to_phy_driver(phydev->dev.driver);
724 int ret = 0;
717 725
718 if (phydrv->resume) 726 if (phydrv->resume)
719 return phydrv->resume(phydev); 727 ret = phydrv->resume(phydev);
720 return 0; 728
729 if (ret)
730 return ret;
731
732 phydev->suspended = false;
733
734 return ret;
721} 735}
722EXPORT_SYMBOL(phy_resume); 736EXPORT_SYMBOL(phy_resume);
723 737
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 {
328 * is_c45: Set to true if this phy uses clause 45 addressing. 328 * is_c45: Set to true if this phy uses clause 45 addressing.
329 * is_internal: Set to true if this phy is internal to a MAC. 329 * is_internal: Set to true if this phy is internal to a MAC.
330 * has_fixups: Set to true if this phy has fixups/quirks. 330 * has_fixups: Set to true if this phy has fixups/quirks.
331 * suspended: Set to true if this phy has been suspended successfully.
331 * state: state of the PHY for management purposes 332 * state: state of the PHY for management purposes
332 * dev_flags: Device-specific flags used by the PHY driver. 333 * dev_flags: Device-specific flags used by the PHY driver.
333 * addr: Bus address of PHY 334 * addr: Bus address of PHY
@@ -365,6 +366,7 @@ struct phy_device {
365 bool is_c45; 366 bool is_c45;
366 bool is_internal; 367 bool is_internal;
367 bool has_fixups; 368 bool has_fixups;
369 bool suspended;
368 370
369 enum phy_state state; 371 enum phy_state state;
370 372