diff mbox series

[net-next,v4,2/9] net: usb: ax88179_178a: Use linkmode helpers for EEE

Message ID 20240218-keee-u32-cleanup-v4-2-71f13b7c3e60@lunn.ch (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series drivers: net: Convert EEE handling to use linkmode bitmaps | 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: 940 this patch: 940
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: jtornosm@redhat.com hkallweit1@gmail.com
netdev/build_clang success Errors and warnings before: 957 this patch: 957
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: 957 this patch: 957
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 39 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
netdev/contest success net-next-2024-02-19--18-00 (tests: 1449)

Commit Message

Andrew Lunn Feb. 18, 2024, 5:06 p.m. UTC
Make use of the existing linkmode helpers for converting PHY EEE
register values into links modes, now that ethtool_keee uses link
modes, rather than u32 values.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/usb/ax88179_178a.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Simon Horman Feb. 20, 2024, 12:39 p.m. UTC | #1
On Sun, Feb 18, 2024 at 11:06:59AM -0600, Andrew Lunn wrote:
> Make use of the existing linkmode helpers for converting PHY EEE
> register values into links modes, now that ethtool_keee uses link
> modes, rather than u32 values.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>  drivers/net/usb/ax88179_178a.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> index d6168eaa286f..d4bf9865d87b 100644
> --- a/drivers/net/usb/ax88179_178a.c
> +++ b/drivers/net/usb/ax88179_178a.c
> @@ -676,21 +676,21 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
>  					    MDIO_MMD_PCS);
>  	if (val < 0)
>  		return val;
> -	data->supported_u32 = mmd_eee_cap_to_ethtool_sup_t(val);
> +	mii_eee_cap1_mod_linkmode_t(data->supported, val);
>  
>  	/* Get advertisement EEE */
>  	val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV,
>  					    MDIO_MMD_AN);
>  	if (val < 0)
>  		return val;
> -	data->advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(val);
> +	mii_eee_cap1_mod_linkmode_t(data->advertised, val);
>  
>  	/* Get LP advertisement EEE */
>  	val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE,
>  					    MDIO_MMD_AN);
>  	if (val < 0)
>  		return val;
> -	data->lp_advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(val);
> +	mii_eee_cap1_mod_linkmode_t(data->lp_advertised, val);
>  
>  	return 0;
>  }
> @@ -698,7 +698,7 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
>  static int
>  ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_keee *data)
>  {
> -	u16 tmp16 = ethtool_adv_to_mmd_eee_adv_t(data->advertised_u32);
> +	u16 tmp16 = linkmode_to_mii_eee_cap1_t(data->advertised);
>  
>  	return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV,
>  					      MDIO_MMD_AN, tmp16);
> @@ -1663,7 +1663,6 @@ static int ax88179_reset(struct usbnet *dev)
>  	ax88179_disable_eee(dev);
>  
>  	ax88179_ethtool_get_eee(dev, &eee_data);
> -	eee_data.advertised_u32 = 0;

Hi Andrew,

could you clarify why advertised no longer needs to be cleared?

>  	ax88179_ethtool_set_eee(dev, &eee_data);
>  
>  	/* Restart autoneg */
> 
> -- 
> 2.43.0
> 
>
Andrew Lunn Feb. 20, 2024, 2:40 p.m. UTC | #2
On Tue, Feb 20, 2024 at 12:39:24PM +0000, Simon Horman wrote:
> On Sun, Feb 18, 2024 at 11:06:59AM -0600, Andrew Lunn wrote:
> > Make use of the existing linkmode helpers for converting PHY EEE
> > register values into links modes, now that ethtool_keee uses link
> > modes, rather than u32 values.
> > 
> > Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> > ---
> >  drivers/net/usb/ax88179_178a.c | 9 ++++-----
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
> > index d6168eaa286f..d4bf9865d87b 100644
> > --- a/drivers/net/usb/ax88179_178a.c
> > +++ b/drivers/net/usb/ax88179_178a.c
> > @@ -676,21 +676,21 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
> >  					    MDIO_MMD_PCS);
> >  	if (val < 0)
> >  		return val;
> > -	data->supported_u32 = mmd_eee_cap_to_ethtool_sup_t(val);
> > +	mii_eee_cap1_mod_linkmode_t(data->supported, val);
> >  
> >  	/* Get advertisement EEE */
> >  	val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV,
> >  					    MDIO_MMD_AN);
> >  	if (val < 0)
> >  		return val;
> > -	data->advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(val);
> > +	mii_eee_cap1_mod_linkmode_t(data->advertised, val);
> >  
> >  	/* Get LP advertisement EEE */
> >  	val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE,
> >  					    MDIO_MMD_AN);
> >  	if (val < 0)
> >  		return val;
> > -	data->lp_advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(val);
> > +	mii_eee_cap1_mod_linkmode_t(data->lp_advertised, val);
> >  
> >  	return 0;
> >  }
> > @@ -698,7 +698,7 @@ ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
> >  static int
> >  ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_keee *data)
> >  {
> > -	u16 tmp16 = ethtool_adv_to_mmd_eee_adv_t(data->advertised_u32);
> > +	u16 tmp16 = linkmode_to_mii_eee_cap1_t(data->advertised);
> >  
> >  	return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV,
> >  					      MDIO_MMD_AN, tmp16);
> > @@ -1663,7 +1663,6 @@ static int ax88179_reset(struct usbnet *dev)
> >  	ax88179_disable_eee(dev);
> >  
> >  	ax88179_ethtool_get_eee(dev, &eee_data);
> > -	eee_data.advertised_u32 = 0;
> 
> Hi Andrew,
> 
> could you clarify why advertised no longer needs to be cleared?

Ah, that is me being too delete happy. When the ethtool core calls
into the driver for eee_get(), it first zeros the structure passed
in. Some drivers than again zeroed members, so i deleted them.

However, this is not a eee_get() call, eee_data is actually a stack
variable. ax88179_ethtool_get_eee() has set it, so it is at least not
random junk. But the intention here is to not advertise any EEE link
modes until the user calls set_eee(). So this zero'ing is needed.

Good catch, thanks.

    Andrew

---
pw-bot: cr
diff mbox series

Patch

diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index d6168eaa286f..d4bf9865d87b 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -676,21 +676,21 @@  ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
 					    MDIO_MMD_PCS);
 	if (val < 0)
 		return val;
-	data->supported_u32 = mmd_eee_cap_to_ethtool_sup_t(val);
+	mii_eee_cap1_mod_linkmode_t(data->supported, val);
 
 	/* Get advertisement EEE */
 	val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV,
 					    MDIO_MMD_AN);
 	if (val < 0)
 		return val;
-	data->advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(val);
+	mii_eee_cap1_mod_linkmode_t(data->advertised, val);
 
 	/* Get LP advertisement EEE */
 	val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE,
 					    MDIO_MMD_AN);
 	if (val < 0)
 		return val;
-	data->lp_advertised_u32 = mmd_eee_adv_to_ethtool_adv_t(val);
+	mii_eee_cap1_mod_linkmode_t(data->lp_advertised, val);
 
 	return 0;
 }
@@ -698,7 +698,7 @@  ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_keee *data)
 static int
 ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_keee *data)
 {
-	u16 tmp16 = ethtool_adv_to_mmd_eee_adv_t(data->advertised_u32);
+	u16 tmp16 = linkmode_to_mii_eee_cap1_t(data->advertised);
 
 	return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV,
 					      MDIO_MMD_AN, tmp16);
@@ -1663,7 +1663,6 @@  static int ax88179_reset(struct usbnet *dev)
 	ax88179_disable_eee(dev);
 
 	ax88179_ethtool_get_eee(dev, &eee_data);
-	eee_data.advertised_u32 = 0;
 	ax88179_ethtool_set_eee(dev, &eee_data);
 
 	/* Restart autoneg */