[PATCH] net: phy: Prevent reporting advertised modes when autoneg is off

From: Łukasz Stelmach
Date: Wed Oct 14 2020 - 08:57:22 EST


Do not report advertised link modes when autonegotiation is turned
off. mii_ethtool_get_link_ksettings() exhibits the same behaviour.

Signed-off-by: Łukasz Stelmach <l.stelmach@xxxxxxxxxxx>
---
drivers/net/phy/phy.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 35525a671400..3cadf224fdb2 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -315,7 +315,8 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
struct ethtool_link_ksettings *cmd)
{
linkmode_copy(cmd->link_modes.supported, phydev->supported);
- linkmode_copy(cmd->link_modes.advertising, phydev->advertising);
+ if (phydev->autoneg)
+ linkmode_copy(cmd->link_modes.advertising, phydev->advertising);
linkmode_copy(cmd->link_modes.lp_advertising, phydev->lp_advertising);

cmd->base.speed = phydev->speed;
--
2.26.2