Commit 9f4bae70 authored by Russell King's avatar Russell King Committed by David S. Miller

net: phy: marvell: use phy_modify_changed()

Use phy_modify_changed() to change the fiber advertisement register
rather than open coding this functionality.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 20ecf424
...@@ -513,7 +513,7 @@ static int marvell_config_aneg_fiber(struct phy_device *phydev) ...@@ -513,7 +513,7 @@ static int marvell_config_aneg_fiber(struct phy_device *phydev)
{ {
int changed = 0; int changed = 0;
int err; int err;
int adv, oldadv; u16 adv;
if (phydev->autoneg != AUTONEG_ENABLE) if (phydev->autoneg != AUTONEG_ENABLE)
return genphy_setup_forced(phydev); return genphy_setup_forced(phydev);
...@@ -522,23 +522,17 @@ static int marvell_config_aneg_fiber(struct phy_device *phydev) ...@@ -522,23 +522,17 @@ static int marvell_config_aneg_fiber(struct phy_device *phydev)
linkmode_and(phydev->advertising, phydev->advertising, linkmode_and(phydev->advertising, phydev->advertising,
phydev->supported); phydev->supported);
/* Setup fiber advertisement */ adv = linkmode_adv_to_fiber_adv_t(phydev->advertising);
adv = phy_read(phydev, MII_ADVERTISE);
if (adv < 0)
return adv;
oldadv = adv;
adv &= ~(ADVERTISE_1000XHALF | ADVERTISE_1000XFULL |
ADVERTISE_1000XPAUSE | ADVERTISE_1000XPSE_ASYM);
adv |= linkmode_adv_to_fiber_adv_t(phydev->advertising);
if (adv != oldadv) {
err = phy_write(phydev, MII_ADVERTISE, adv);
if (err < 0)
return err;
/* Setup fiber advertisement */
err = phy_modify_changed(phydev, MII_ADVERTISE,
ADVERTISE_1000XHALF | ADVERTISE_1000XFULL |
ADVERTISE_1000XPAUSE | ADVERTISE_1000XPSE_ASYM,
adv);
if (err < 0)
return err;
if (err > 0)
changed = 1; changed = 1;
}
if (changed == 0) { if (changed == 0) {
/* Advertisement hasn't changed, but maybe aneg was never on to /* Advertisement hasn't changed, but maybe aneg was never on to
......
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