/* Description: If auto-negotiation is enabled, we configure the advertising, and then restart auto-negotiation. If it is not enabled, then we write the BMCR.  */
int genphy_config_aneg(struct phy_device *phydev)
/* Description: If auto-negotiation is enabled, we configure the advertising, and then restart auto-negotiation. If it is not enabled, then we write the BMCR.  */
int genphy_config_aneg(struct phy_device *phydev)
{
    int result;
    if (AUTONEG_ENABLE != phydev->autoneg)
        return genphy_setup_forced(phydev);
    result = genphy_config_advert(phydev);
    if (result < 0)
        return result;
    if (result == 0) {
        int ctl = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMCR);
        if (ctl < 0)
            return ctl;
        if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE))
            result = 1;
    }
    if (result > 0)
        result = genphy_restart_aneg(phydev);
    return result;
}