[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230201145845.2312060-22-o.rempel@pengutronix.de>
Date: Wed, 1 Feb 2023 15:58:43 +0100
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: Woojung Huh <woojung.huh@...rochip.com>,
UNGLinuxDriver@...rochip.com, Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Wei Fang <wei.fang@....com>,
Heiner Kallweit <hkallweit1@...il.com>
Cc: Oleksij Rempel <o.rempel@...gutronix.de>, kernel@...gutronix.de,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
Arun.Ramadoss@...rochip.com, intel-wired-lan@...ts.osuosl.org
Subject: [PATCH net-next v4 21/23] r8152: replace EEE ethtool helpers to linkmode variants
Replace EEE ethtool helpers with linkmode variants. This will
reduce similar code snippets and prepare ethtool EEE interface to linkmode
migration.
Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
---
drivers/net/usb/r8152.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index decb5ba56a25..dbfde0aec003 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -8745,17 +8745,23 @@ static void rtl8152_get_strings(struct net_device *dev, u32 stringset, u8 *data)
static int r8152_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
{
- u32 lp, adv, supported = 0;
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_able) = {};
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_adv) = {};
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_lp) = {};
+ u32 lp, adv, supported;
u16 val;
val = r8152_mmd_read(tp, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
- supported = mmd_eee_cap_to_ethtool_sup_t(val);
+ mii_eee_100_10000_adv_mod_linkmode_t(lm_able, val);
+ ethtool_convert_link_mode_to_legacy_u32(&supported, lm_able);
val = r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
- adv = mmd_eee_adv_to_ethtool_adv_t(val);
+ mii_eee_100_10000_adv_mod_linkmode_t(lm_adv, val);
+ ethtool_convert_link_mode_to_legacy_u32(&adv, lm_adv);
val = r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE);
- lp = mmd_eee_adv_to_ethtool_adv_t(val);
+ mii_eee_100_10000_adv_mod_linkmode_t(lm_lp, val);
+ ethtool_convert_link_mode_to_legacy_u32(&lp, lm_lp);
eee->eee_enabled = tp->eee_en;
eee->eee_active = !!(supported & adv & lp);
@@ -8768,7 +8774,11 @@ static int r8152_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
static int r8152_set_eee(struct r8152 *tp, struct ethtool_eee *eee)
{
- u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised);
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {};
+ u16 val;
+
+ adv[0] = eee->advertised;
+ val = linkmode_adv_to_mii_eee_100_10000_adv_t(adv);
tp->eee_en = eee->eee_enabled;
tp->eee_adv = val;
@@ -8780,17 +8790,23 @@ static int r8152_set_eee(struct r8152 *tp, struct ethtool_eee *eee)
static int r8153_get_eee(struct r8152 *tp, struct ethtool_eee *eee)
{
- u32 lp, adv, supported = 0;
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_able) = {};
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_adv) = {};
+ __ETHTOOL_DECLARE_LINK_MODE_MASK(lm_lp) = {};
+ u32 lp, adv, supported;
u16 val;
val = ocp_reg_read(tp, OCP_EEE_ABLE);
- supported = mmd_eee_cap_to_ethtool_sup_t(val);
+ mii_eee_100_10000_adv_mod_linkmode_t(lm_able, val);
+ ethtool_convert_link_mode_to_legacy_u32(&supported, lm_able);
val = ocp_reg_read(tp, OCP_EEE_ADV);
- adv = mmd_eee_adv_to_ethtool_adv_t(val);
+ mii_eee_100_10000_adv_mod_linkmode_t(lm_adv, val);
+ ethtool_convert_link_mode_to_legacy_u32(&adv, lm_adv);
val = ocp_reg_read(tp, OCP_EEE_LPABLE);
- lp = mmd_eee_adv_to_ethtool_adv_t(val);
+ mii_eee_100_10000_adv_mod_linkmode_t(lm_lp, val);
+ ethtool_convert_link_mode_to_legacy_u32(&lp, lm_lp);
eee->eee_enabled = tp->eee_en;
eee->eee_active = !!(supported & adv & lp);
--
2.30.2
Powered by blists - more mailing lists