On 2/16/2019 11:51 AM, Heiner Kallweit wrote:
> From: Andrew Lunn <and...@lunn.ch>
> C45 configuration of 10/100 and multi-giga bit auto negotiation
> advertisement is standardized. Configuration of 1000Base-T however
> appears to be vendor specific. Move the generic code out of the
> Marvell driver into the common phy-c45.c file.
> 
> Signed-off-by: Andrew Lunn <and...@lunn.ch>
> [hkallwe...@gmail.com: use new helper linkmode_adv_to_mii_10gbt_adv_t and 
> split patch]
> Signed-off-by: Heiner Kallweit <hkallwe...@gmail.com>
> ---
>  drivers/net/phy/phy-c45.c | 44 +++++++++++++++++++++++++++++++++++++++
>  include/linux/phy.h       |  1 +
>  2 files changed, 45 insertions(+)
> 
> diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
> index 0374c50b1..bea1b0c6e 100644
> --- a/drivers/net/phy/phy-c45.c
> +++ b/drivers/net/phy/phy-c45.c
> @@ -78,6 +78,50 @@ int genphy_c45_pma_setup_forced(struct phy_device *phydev)
>  }
>  EXPORT_SYMBOL_GPL(genphy_c45_pma_setup_forced);
>  
> +/**
> + * genphy_c45_an_config_an - configure advertisement registers

Nit: are not the two "an" redundant" here? Unless the first one means
something different in which case naming this:
genphy_c45_an_config_aneg() would be clearer?


> + * @phydev: target phy_device struct
> + *
> + * Configure advertisement registers based on modes set in 
> phydev->advertising
> + *
> + * Returns negative errno code on failure, 0 if advertisement didn't change,
> + * or 1 if advertised modes changed.
> + */
> +int genphy_c45_an_config_an(struct phy_device *phydev)
> +{
> +     int changed = 0, ret;
> +     u32 adv;
> +
> +     linkmode_and(phydev->advertising, phydev->advertising,
> +                  phydev->supported);
> +
> +     adv = linkmode_adv_to_mii_adv_t(phydev->advertising);
> +
> +     ret = phy_modify_mmd(phydev, MDIO_MMD_AN, MDIO_AN_ADVERTISE,
> +                          ADVERTISE_ALL | ADVERTISE_100BASE4 |
> +                          ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM,
> +                          adv);
> +     if (ret < 0)
> +             return ret;
> +     if (ret > 0)
> +             changed = 1;

'changed' is essentially a short hand for 'ret >= 0' given it is
initialized to 0 by default and only assigned 1 if 'ret > 0', and since
you do early returns in case 'ret < 0', you might as well drop 'changed'
entirely?

Other than that and the naming:

Reviewed-by: Florian Fainelli <f.faine...@gmail.com>
-- 
Florian

Reply via email to