Commit 3eef8689 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

net: phy: simplify genphy_config_advert by using the linkmode_adv_to_xxx_t functions

Using linkmode_adv_to_mii_adv_t and linkmode_adv_to_mii_ctrl1000_t
allows to simplify the code. In addition avoiding the conversion to
the legacy u32 advertisement format allows to remove the warning.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Suggested-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 150e8f8a
...@@ -1564,24 +1564,20 @@ EXPORT_SYMBOL(phy_reset_after_clk_enable); ...@@ -1564,24 +1564,20 @@ EXPORT_SYMBOL(phy_reset_after_clk_enable);
*/ */
static int genphy_config_advert(struct phy_device *phydev) static int genphy_config_advert(struct phy_device *phydev)
{ {
u32 advertise; int err, bmsr, changed = 0;
int bmsr, adv; u32 adv;
int err, changed = 0;
/* Only allow advertising what this PHY supports */ /* Only allow advertising what this PHY supports */
linkmode_and(phydev->advertising, phydev->advertising, linkmode_and(phydev->advertising, phydev->advertising,
phydev->supported); phydev->supported);
if (!ethtool_convert_link_mode_to_legacy_u32(&advertise,
phydev->advertising)) adv = linkmode_adv_to_mii_adv_t(phydev->advertising);
phydev_warn(phydev, "PHY advertising (%*pb) more modes than genphy supports, some modes not advertised.\n",
__ETHTOOL_LINK_MODE_MASK_NBITS,
phydev->advertising);
/* Setup standard advertisement */ /* Setup standard advertisement */
err = phy_modify_changed(phydev, MII_ADVERTISE, err = phy_modify_changed(phydev, MII_ADVERTISE,
ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_ALL | ADVERTISE_100BASE4 |
ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM, ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM,
ethtool_adv_to_mii_adv_t(advertise)); adv);
if (err < 0) if (err < 0)
return err; return err;
if (err > 0) if (err > 0)
...@@ -1598,13 +1594,7 @@ static int genphy_config_advert(struct phy_device *phydev) ...@@ -1598,13 +1594,7 @@ static int genphy_config_advert(struct phy_device *phydev)
if (!(bmsr & BMSR_ESTATEN)) if (!(bmsr & BMSR_ESTATEN))
return changed; return changed;
/* Configure gigabit if it's supported */ adv = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising);
adv = 0;
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
phydev->supported) ||
linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
phydev->supported))
adv = ethtool_adv_to_mii_ctrl1000_t(advertise);
err = phy_modify_changed(phydev, MII_CTRL1000, err = phy_modify_changed(phydev, MII_CTRL1000,
ADVERTISE_1000FULL | ADVERTISE_1000HALF, ADVERTISE_1000FULL | ADVERTISE_1000HALF,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment