diff mbox series

[net-next,4/5] net: phy: c45: prepare genphy_c45_ethtool_set_eee for follow-up extension

Message ID ccd1dc6a-5dc8-46de-a881-ebd2eda6dcee@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ethtool: add support for EEE linkmodes beyond bit 32 | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1113 this patch: 1113
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 52 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Heiner Kallweit Jan. 1, 2024, 9:26 p.m. UTC
This prepares genphy_c45_ethtool_set_eee() for functional changes in a
follow-up patch. No functional change intended.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy-c45.c | 41 +++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 747d14bf1..9d8b2b5eb 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -1492,32 +1492,31 @@  EXPORT_SYMBOL(genphy_c45_ethtool_get_eee);
 int genphy_c45_ethtool_set_eee(struct phy_device *phydev,
 			       struct ethtool_eee *data)
 {
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(adv);
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp);
+	bool unsupported;
 	int ret;
 
-	if (data->eee_enabled) {
-		if (data->advertised) {
-			__ETHTOOL_DECLARE_LINK_MODE_MASK(adv);
-
-			ethtool_convert_legacy_u32_to_link_mode(adv,
-								data->advertised);
-			linkmode_andnot(adv, adv, phydev->supported_eee);
-			if (!linkmode_empty(adv)) {
-				phydev_warn(phydev, "At least some EEE link modes are not supported.\n");
-				return -EINVAL;
-			}
-
-			ethtool_convert_legacy_u32_to_link_mode(phydev->advertising_eee,
-								data->advertised);
-		} else {
-			linkmode_copy(phydev->advertising_eee,
-				      phydev->supported_eee);
-		}
+	phydev->eee_enabled = data->eee_enabled;
+	if (!data->eee_enabled)
+		goto eee_aneg;
 
-		phydev->eee_enabled = true;
-	} else {
-		phydev->eee_enabled = false;
+	ethtool_convert_legacy_u32_to_link_mode(adv, data->advertised);
+
+	if (linkmode_empty(adv)) {
+		linkmode_copy(phydev->advertising_eee, phydev->supported_eee);
+		goto eee_aneg;
 	}
 
+	unsupported = linkmode_andnot(tmp, adv, phydev->supported_eee);
+	if (unsupported) {
+		phydev_warn(phydev, "At least some EEE link modes are not supported.\n");
+		return -EINVAL;
+	}
+
+	linkmode_copy(phydev->advertising_eee, adv);
+
+eee_aneg:
 	ret = genphy_c45_an_config_eee_aneg(phydev);
 	if (ret < 0)
 		return ret;