Commit 8a8f8281 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

net: phy: don't touch suspended flag if there's no suspend/resume callback

So far we set phydev->suspended to true in phy_suspend() even if the
PHY driver doesn't implement the suspend callback. This applies
accordingly for the resume path. The current behavior doesn't cause
any issue I'd be aware of, but it's not logical and misleading,
especially considering the description of the flag:
"suspended: Set to true if this phy has been suspended successfully"
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 05cc6c5b
...@@ -1519,23 +1519,22 @@ EXPORT_SYMBOL(phy_detach); ...@@ -1519,23 +1519,22 @@ EXPORT_SYMBOL(phy_detach);
int phy_suspend(struct phy_device *phydev) int phy_suspend(struct phy_device *phydev)
{ {
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
struct net_device *netdev = phydev->attached_dev;
struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
int ret = 0; struct net_device *netdev = phydev->attached_dev;
struct phy_driver *phydrv = phydev->drv;
int ret;
/* If the device has WOL enabled, we cannot suspend the PHY */ /* If the device has WOL enabled, we cannot suspend the PHY */
phy_ethtool_get_wol(phydev, &wol); phy_ethtool_get_wol(phydev, &wol);
if (wol.wolopts || (netdev && netdev->wol_enabled)) if (wol.wolopts || (netdev && netdev->wol_enabled))
return -EBUSY; return -EBUSY;
if (phydev->drv && phydrv->suspend) if (!phydrv || !phydrv->suspend)
ret = phydrv->suspend(phydev); return 0;
if (ret)
return ret;
phydev->suspended = true; ret = phydrv->suspend(phydev);
if (!ret)
phydev->suspended = true;
return ret; return ret;
} }
...@@ -1543,18 +1542,17 @@ EXPORT_SYMBOL(phy_suspend); ...@@ -1543,18 +1542,17 @@ EXPORT_SYMBOL(phy_suspend);
int __phy_resume(struct phy_device *phydev) int __phy_resume(struct phy_device *phydev)
{ {
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver); struct phy_driver *phydrv = phydev->drv;
int ret = 0; int ret;
WARN_ON(!mutex_is_locked(&phydev->lock)); WARN_ON(!mutex_is_locked(&phydev->lock));
if (phydev->drv && phydrv->resume) if (!phydrv || !phydrv->resume)
ret = phydrv->resume(phydev); return 0;
if (ret)
return ret;
phydev->suspended = false; ret = phydrv->resume(phydev);
if (!ret)
phydev->suspended = false;
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment