Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: phy: add phy_may_wakeup()

Add phy_may_wakeup() which uses the driver model's device_may_wakeup()
when the PHY driver has marked the device as wakeup capable in the
driver model, otherwise use phy_drv_wol_enabled().

Replace the sites that used to call phy_drv_wol_enabled() with this
as checking the driver model will be more efficient than checking the
WoL state.

Export phy_may_wakeup() so that phylink can use it.

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vBrQx-0000000BLzO-1RLt@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
b344bfac 330ce8ff

+21 -2
+12 -2
drivers/net/phy/phy_device.c
··· 251 251 return wol.wolopts != 0; 252 252 } 253 253 254 + bool phy_may_wakeup(struct phy_device *phydev) 255 + { 256 + /* If the PHY is using driver-model based wakeup, use that state. */ 257 + if (phy_can_wakeup(phydev)) 258 + return device_may_wakeup(&phydev->mdio.dev); 259 + 260 + return phy_drv_wol_enabled(phydev); 261 + } 262 + EXPORT_SYMBOL_GPL(phy_may_wakeup); 263 + 254 264 static void phy_link_change(struct phy_device *phydev, bool up) 255 265 { 256 266 struct net_device *netdev = phydev->attached_dev; ··· 312 302 /* If the PHY on the mido bus is not attached but has WOL enabled 313 303 * we cannot suspend the PHY. 314 304 */ 315 - if (!netdev && phy_drv_wol_enabled(phydev)) 305 + if (!netdev && phy_may_wakeup(phydev)) 316 306 return false; 317 307 318 308 /* PHY not attached? May suspend if the PHY has not already been ··· 1919 1909 if (phydev->suspended || !phydrv) 1920 1910 return 0; 1921 1911 1922 - phydev->wol_enabled = phy_drv_wol_enabled(phydev) || 1912 + phydev->wol_enabled = phy_may_wakeup(phydev) || 1923 1913 (netdev && netdev->ethtool->wol_enabled); 1924 1914 /* If the device has WOL enabled, we cannot suspend the PHY */ 1925 1915 if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND))
+9
include/linux/phy.h
··· 1391 1391 return device_can_wakeup(&phydev->mdio.dev); 1392 1392 } 1393 1393 1394 + /** 1395 + * phy_may_wakeup() - indicate whether PHY has wakeup enabled 1396 + * @phydev: The phy_device struct 1397 + * 1398 + * Returns: true/false depending on the PHY driver's device_set_wakeup_enabled() 1399 + * setting if using the driver model, otherwise the legacy determination. 1400 + */ 1401 + bool phy_may_wakeup(struct phy_device *phydev); 1402 + 1394 1403 void phy_resolve_aneg_pause(struct phy_device *phydev); 1395 1404 void phy_resolve_aneg_linkmode(struct phy_device *phydev); 1396 1405