summaryrefslogtreecommitdiff
path: root/drivers/net/phy
diff options
context:
space:
mode:
authorFugang Duan <fugang.duan@nxp.com>2018-01-30 16:22:56 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commitd808d9d6b2105aef9c65813441eddb689bddd1f4 (patch)
treed91bb1571b1c0d1cba944efdf4c31c4d8eb1aa59 /drivers/net/phy
parent3f6a12765bc240e581081454d4b59945826a373e (diff)
MLK-17475-05 net: phy: tja110x: add lock to protect .suspend/.resume()
Add phydev->lock to protect phy register access in .suspend()/.resume(). Reviewed-by: Pandy Gao <pandy.gao@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r--drivers/net/phy/tja110x.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/net/phy/tja110x.c b/drivers/net/phy/tja110x.c
index 5134cecbd78b..bf680ecf3d7b 100644
--- a/drivers/net/phy/tja110x.c
+++ b/drivers/net/phy/tja110x.c
@@ -915,7 +915,7 @@ phy_configure_error:
/* power mode transition to standby */
static int nxp_suspend(struct phy_device *phydev)
{
- int err;
+ int err = 0;
if (verbosity > 0)
dev_alert(&phydev->mdio.dev, "suspending PHY %x\n", phydev->mdio.addr);
@@ -923,16 +923,13 @@ static int nxp_suspend(struct phy_device *phydev)
if (!managed_mode)
goto phy_auto_op_error;
+ mutex_lock(&phydev->lock);
/* set BMCR_PDOWN bit in MII_BMCR register */
err = phy_configure_bit(phydev, MII_BMCR, BMCR_PDOWN, 1);
if (err < 0)
- goto phy_configure_error;
-
- return 0;
+ dev_err(&phydev->mdio.dev, "phy r/w error: resume failed\n");
+ mutex_unlock(&phydev->lock);
-/* error handling */
-phy_configure_error:
- dev_err(&phydev->mdio.dev, "phy r/w error: resume failed\n");
return err;
phy_auto_op_error:
@@ -949,6 +946,7 @@ static int nxp_resume(struct phy_device *phydev)
if (verbosity > 0)
dev_alert(&phydev->mdio.dev, "resuming PHY %x\n", phydev->mdio.addr);
+ mutex_lock(&phydev->lock);
/* clear BMCR_PDOWN bit in MII_BMCR register */
err = phy_configure_bit(phydev, MII_BMCR, BMCR_PDOWN, 0);
if (err < 0)
@@ -976,19 +974,23 @@ static int nxp_resume(struct phy_device *phydev)
/* reenable link control */
set_link_control(phydev, 1);
+ mutex_unlock(&phydev->lock);
return 0;
/* error handling */
phy_configure_error:
+ mutex_unlock(&phydev->lock);
dev_err(&phydev->mdio.dev, "phy r/w error: resume failed\n");
return err;
phy_transition_error:
+ mutex_unlock(&phydev->lock);
dev_err(&phydev->mdio.dev, "power mode transition failed\n");
return err;
phy_pll_error:
+ mutex_unlock(&phydev->lock);
dev_err(&phydev->mdio.dev, "Error: PLL is unstable and not locked\n");
return err;
}