Skip to content

Commit

Permalink
net: phy: keep track of the PHY suspend state
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Jan 27, 2015
1 parent aae8826 commit 8a477a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 18 additions & 4 deletions drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,25 +699,39 @@ 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);
if (wol.wolopts)
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);

Expand Down
2 changes: 2 additions & 0 deletions include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -365,6 +366,7 @@ struct phy_device {
bool is_c45;
bool is_internal;
bool has_fixups;
bool suspended;

enum phy_state state;

Expand Down

0 comments on commit 8a477a6

Please sign in to comment.