Subject: Re: [net-next 2/3] net: phy: marvell-88q2xxx: Make register writer function generic

From: Dimitri Fedrau <[email-masked]>
Date: Thu, 12 Sep 2024 18:52:27 +0200

Am Fri, Sep 06, 2024 at 03:39:50PM +0200 schrieb Niklas Söderlund:
> In preparation to adding auto negotiation support to mv88q2110 move and
> rename the helper function used to write an array of register values to
> the PHY.
> 
> Just as for mv88q2220 devices this helper will be needed to for the
> initial configuration of the mv88q2110 to support auto negotiation.
> 
> The function is moved verbatim, there is no change in behavior.
> 
> Signed-off-by: Niklas Söderlund <[email-masked]>
> ---
>  drivers/net/phy/marvell-88q2xxx.c | 40 +++++++++++++++----------------
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/net/phy/marvell-88q2xxx.c b/drivers/net/phy/marvell-88q2xxx.c
> index 850beb4b1722..31f8c976e387 100644
> --- a/drivers/net/phy/marvell-88q2xxx.c
> +++ b/drivers/net/phy/marvell-88q2xxx.c
> @@ -174,6 +174,21 @@ static const struct mmd_val mv88q222x_revb1_revb2_init_seq1[] = {
>  	{ MDIO_MMD_PCS, 0xfe11, 0x1105 },
>  };
>  
> +static int mv88q2xxx_write_mmd_vals(struct phy_device *phydev,
> +				    const struct mmd_val *vals, size_t len)
> +{
> +	int ret;
> +
> +	for (; len; vals++, len--) {
> +		ret = phy_write_mmd(phydev, vals->devad, vals->regnum,
> +				    vals->val);
> +		if (ret < 0)
> +			return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int mv88q2xxx_soft_reset(struct phy_device *phydev)
>  {
>  	int ret;
> @@ -724,33 +739,18 @@ static int mv88q2xxx_probe(struct phy_device *phydev)
>  	return mv88q2xxx_hwmon_probe(phydev);
>  }
>  
> -static int mv88q222x_write_mmd_vals(struct phy_device *phydev,
> -				    const struct mmd_val *vals, size_t len)
> -{
> -	int ret;
> -
> -	for (; len; vals++, len--) {
> -		ret = phy_write_mmd(phydev, vals->devad, vals->regnum,
> -				    vals->val);
> -		if (ret < 0)
> -			return ret;
> -	}
> -
> -	return 0;
> -}
> -
>  static int mv88q222x_revb0_config_init(struct phy_device *phydev)
>  {
>  	int ret;
>  
> -	ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb0_init_seq0,
> +	ret = mv88q2xxx_write_mmd_vals(phydev, mv88q222x_revb0_init_seq0,
>  				       ARRAY_SIZE(mv88q222x_revb0_init_seq0));
>  	if (ret < 0)
>  		return ret;
>  
>  	usleep_range(5000, 10000);
>  
> -	ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb0_init_seq1,
> +	ret = mv88q2xxx_write_mmd_vals(phydev, mv88q222x_revb0_init_seq1,
>  				       ARRAY_SIZE(mv88q222x_revb0_init_seq1));
>  	if (ret < 0)
>  		return ret;
> @@ -764,17 +764,17 @@ static int mv88q222x_revb1_revb2_config_init(struct phy_device *phydev)
>  	int ret;
>  
>  	if (is_rev_b1)
> -		ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb1_init_seq0,
> +		ret = mv88q2xxx_write_mmd_vals(phydev, mv88q222x_revb1_init_seq0,
>  					       ARRAY_SIZE(mv88q222x_revb1_init_seq0));
>  	else
> -		ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb2_init_seq0,
> +		ret = mv88q2xxx_write_mmd_vals(phydev, mv88q222x_revb2_init_seq0,
>  					       ARRAY_SIZE(mv88q222x_revb2_init_seq0));
>  	if (ret < 0)
>  		return ret;
>  
>  	usleep_range(3000, 5000);
>  
> -	ret = mv88q222x_write_mmd_vals(phydev, mv88q222x_revb1_revb2_init_seq1,
> +	ret = mv88q2xxx_write_mmd_vals(phydev, mv88q222x_revb1_revb2_init_seq1,
>  				       ARRAY_SIZE(mv88q222x_revb1_revb2_init_seq1));
>  	if (ret < 0)
>  		return ret;
> -- 
> 2.46.0
>

Hi Niklas,

tested with a mv88q2220 device, worked as expected.

Tested-by: Dimitri Fedrau <[email-masked]>

Best regards,
Dimitri Fedrau