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

net: phy: marvell: use phy_modify_changed() for marvell_set_polarity()

Rather than open-coding the phy_modify_changed() sequence, use this
helper in marvell_set_polarity().
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarMarek Behún <kabel@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e5118f57
...@@ -367,39 +367,24 @@ static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev) ...@@ -367,39 +367,24 @@ static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev)
static int marvell_set_polarity(struct phy_device *phydev, int polarity) static int marvell_set_polarity(struct phy_device *phydev, int polarity)
{ {
int reg; u16 val;
int err;
int val;
/* get the current settings */
reg = phy_read(phydev, MII_M1011_PHY_SCR);
if (reg < 0)
return reg;
val = reg;
val &= ~MII_M1011_PHY_SCR_AUTO_CROSS;
switch (polarity) { switch (polarity) {
case ETH_TP_MDI: case ETH_TP_MDI:
val |= MII_M1011_PHY_SCR_MDI; val = MII_M1011_PHY_SCR_MDI;
break; break;
case ETH_TP_MDI_X: case ETH_TP_MDI_X:
val |= MII_M1011_PHY_SCR_MDI_X; val = MII_M1011_PHY_SCR_MDI_X;
break; break;
case ETH_TP_MDI_AUTO: case ETH_TP_MDI_AUTO:
case ETH_TP_MDI_INVALID: case ETH_TP_MDI_INVALID:
default: default:
val |= MII_M1011_PHY_SCR_AUTO_CROSS; val = MII_M1011_PHY_SCR_AUTO_CROSS;
break; break;
} }
if (val != reg) { return phy_modify_changed(phydev, MII_M1011_PHY_SCR,
/* Set the new polarity value in the register */ MII_M1011_PHY_SCR_AUTO_CROSS, val);
err = phy_write(phydev, MII_M1011_PHY_SCR, val);
if (err)
return err;
}
return val != reg;
} }
static int marvell_config_aneg(struct phy_device *phydev) static int marvell_config_aneg(struct phy_device *phydev)
......
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