Skip to content

Commit 8a8f828

Browse files
hkallweitdavem330
authored andcommitted
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: Heiner Kallweit <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 05cc6c5 commit 8a8f828

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

drivers/net/phy/phy_device.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,42 +1519,40 @@ EXPORT_SYMBOL(phy_detach);
15191519

15201520
int phy_suspend(struct phy_device *phydev)
15211521
{
1522-
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
1523-
struct net_device *netdev = phydev->attached_dev;
15241522
struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
1525-
int ret = 0;
1523+
struct net_device *netdev = phydev->attached_dev;
1524+
struct phy_driver *phydrv = phydev->drv;
1525+
int ret;
15261526

15271527
/* If the device has WOL enabled, we cannot suspend the PHY */
15281528
phy_ethtool_get_wol(phydev, &wol);
15291529
if (wol.wolopts || (netdev && netdev->wol_enabled))
15301530
return -EBUSY;
15311531

1532-
if (phydev->drv && phydrv->suspend)
1533-
ret = phydrv->suspend(phydev);
1534-
1535-
if (ret)
1536-
return ret;
1532+
if (!phydrv || !phydrv->suspend)
1533+
return 0;
15371534

1538-
phydev->suspended = true;
1535+
ret = phydrv->suspend(phydev);
1536+
if (!ret)
1537+
phydev->suspended = true;
15391538

15401539
return ret;
15411540
}
15421541
EXPORT_SYMBOL(phy_suspend);
15431542

15441543
int __phy_resume(struct phy_device *phydev)
15451544
{
1546-
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
1547-
int ret = 0;
1545+
struct phy_driver *phydrv = phydev->drv;
1546+
int ret;
15481547

15491548
WARN_ON(!mutex_is_locked(&phydev->lock));
15501549

1551-
if (phydev->drv && phydrv->resume)
1552-
ret = phydrv->resume(phydev);
1553-
1554-
if (ret)
1555-
return ret;
1550+
if (!phydrv || !phydrv->resume)
1551+
return 0;
15561552

1557-
phydev->suspended = false;
1553+
ret = phydrv->resume(phydev);
1554+
if (!ret)
1555+
phydev->suspended = false;
15581556

15591557
return ret;
15601558
}

0 commit comments

Comments
 (0)