提交 4f9744ed 编写于 作者: H Heiner Kallweit 提交者: David S. Miller

net: phy: use phy_modify_changed in genphy_config_advert

Use phy_modify_changed() to simplify the code.
Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b06d8e5a
...@@ -1516,7 +1516,7 @@ EXPORT_SYMBOL(phy_reset_after_clk_enable); ...@@ -1516,7 +1516,7 @@ 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; u32 advertise;
int oldadv, adv, bmsr; int bmsr, adv;
int err, changed = 0; int err, changed = 0;
/* Only allow advertising what this PHY supports */ /* Only allow advertising what this PHY supports */
...@@ -1529,22 +1529,14 @@ static int genphy_config_advert(struct phy_device *phydev) ...@@ -1529,22 +1529,14 @@ static int genphy_config_advert(struct phy_device *phydev)
phydev->advertising); phydev->advertising);
/* Setup standard advertisement */ /* Setup standard advertisement */
adv = phy_read(phydev, MII_ADVERTISE); err = phy_modify_changed(phydev, MII_ADVERTISE,
if (adv < 0) ADVERTISE_ALL | ADVERTISE_100BASE4 |
return adv; ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM,
ethtool_adv_to_mii_adv_t(advertise));
oldadv = adv; if (err < 0)
adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | return err;
ADVERTISE_PAUSE_ASYM); if (err > 0)
adv |= ethtool_adv_to_mii_adv_t(advertise);
if (adv != oldadv) {
err = phy_write(phydev, MII_ADVERTISE, adv);
if (err < 0)
return err;
changed = 1; changed = 1;
}
bmsr = phy_read(phydev, MII_BMSR); bmsr = phy_read(phydev, MII_BMSR);
if (bmsr < 0) if (bmsr < 0)
...@@ -1558,25 +1550,20 @@ static int genphy_config_advert(struct phy_device *phydev) ...@@ -1558,25 +1550,20 @@ static int genphy_config_advert(struct phy_device *phydev)
return changed; return changed;
/* Configure gigabit if it's supported */ /* Configure gigabit if it's supported */
adv = phy_read(phydev, MII_CTRL1000); adv = 0;
if (adv < 0)
return adv;
oldadv = adv;
adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
phydev->supported) || phydev->supported) ||
linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
phydev->supported)) phydev->supported))
adv |= ethtool_adv_to_mii_ctrl1000_t(advertise); adv = ethtool_adv_to_mii_ctrl1000_t(advertise);
if (adv != oldadv) err = phy_modify_changed(phydev, MII_CTRL1000,
changed = 1; ADVERTISE_1000FULL | ADVERTISE_1000HALF,
adv);
err = phy_write(phydev, MII_CTRL1000, adv);
if (err < 0) if (err < 0)
return err; return err;
if (err > 0)
changed = 1;
return changed; return changed;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册