mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-07 21:53:44 +00:00
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: Russell King <rmk+kernel@armlinux.org.uk> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Marek Behún <kabel@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e5118f5723
commit
feb938fad6
@ -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)
|
||||
{
|
||||
int reg;
|
||||
int err;
|
||||
int val;
|
||||
u16 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) {
|
||||
case ETH_TP_MDI:
|
||||
val |= MII_M1011_PHY_SCR_MDI;
|
||||
val = MII_M1011_PHY_SCR_MDI;
|
||||
break;
|
||||
case ETH_TP_MDI_X:
|
||||
val |= MII_M1011_PHY_SCR_MDI_X;
|
||||
val = MII_M1011_PHY_SCR_MDI_X;
|
||||
break;
|
||||
case ETH_TP_MDI_AUTO:
|
||||
case ETH_TP_MDI_INVALID:
|
||||
default:
|
||||
val |= MII_M1011_PHY_SCR_AUTO_CROSS;
|
||||
val = MII_M1011_PHY_SCR_AUTO_CROSS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (val != reg) {
|
||||
/* Set the new polarity value in the register */
|
||||
err = phy_write(phydev, MII_M1011_PHY_SCR, val);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
return val != reg;
|
||||
return phy_modify_changed(phydev, MII_M1011_PHY_SCR,
|
||||
MII_M1011_PHY_SCR_AUTO_CROSS, val);
|
||||
}
|
||||
|
||||
static int marvell_config_aneg(struct phy_device *phydev)
|
||||
|
Loading…
Reference in New Issue
Block a user