aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/dp83640.c
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2015-05-25 05:55:44 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-25 18:21:59 -0400
commita935865c828c8cd20501f618c69f659a5b6d6a5f (patch)
tree3f3527c382a61cb7ab3cfe7d39c30a2d62732667 /drivers/net/phy/dp83640.c
parent397a253af5031de4a4612210055935309af4472c (diff)
net: dp83640: reinforce locking rules.
Callers of the ext_write function are supposed to hold a mutex that protects the state of the dialed page, but one caller was missing the lock from the very start, and over time the code has been changed without following the rule. This patch cleans up the call sites in violation of the rule. Signed-off-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/dp83640.c')
-rw-r--r--drivers/net/phy/dp83640.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 7a068d99ea46..e570036275e2 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -496,7 +496,9 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
496 else 496 else
497 evnt |= EVNT_RISE; 497 evnt |= EVNT_RISE;
498 } 498 }
499 mutex_lock(&clock->extreg_lock);
499 ext_write(0, phydev, PAGE5, PTP_EVNT, evnt); 500 ext_write(0, phydev, PAGE5, PTP_EVNT, evnt);
501 mutex_unlock(&clock->extreg_lock);
500 return 0; 502 return 0;
501 503
502 case PTP_CLK_REQ_PEROUT: 504 case PTP_CLK_REQ_PEROUT:
@@ -532,6 +534,8 @@ static u8 status_frame_src[6] = { 0x08, 0x00, 0x17, 0x0B, 0x6B, 0x0F };
532 534
533static void enable_status_frames(struct phy_device *phydev, bool on) 535static void enable_status_frames(struct phy_device *phydev, bool on)
534{ 536{
537 struct dp83640_private *dp83640 = phydev->priv;
538 struct dp83640_clock *clock = dp83640->clock;
535 u16 cfg0 = 0, ver; 539 u16 cfg0 = 0, ver;
536 540
537 if (on) 541 if (on)
@@ -539,9 +543,13 @@ static void enable_status_frames(struct phy_device *phydev, bool on)
539 543
540 ver = (PSF_PTPVER & VERSIONPTP_MASK) << VERSIONPTP_SHIFT; 544 ver = (PSF_PTPVER & VERSIONPTP_MASK) << VERSIONPTP_SHIFT;
541 545
546 mutex_lock(&clock->extreg_lock);
547
542 ext_write(0, phydev, PAGE5, PSF_CFG0, cfg0); 548 ext_write(0, phydev, PAGE5, PSF_CFG0, cfg0);
543 ext_write(0, phydev, PAGE6, PSF_CFG1, ver); 549 ext_write(0, phydev, PAGE6, PSF_CFG1, ver);
544 550
551 mutex_unlock(&clock->extreg_lock);
552
545 if (!phydev->attached_dev) { 553 if (!phydev->attached_dev) {
546 pr_warn("expected to find an attached netdevice\n"); 554 pr_warn("expected to find an attached netdevice\n");
547 return; 555 return;
@@ -1173,11 +1181,18 @@ static int dp83640_config_init(struct phy_device *phydev)
1173 1181
1174 if (clock->chosen && !list_empty(&clock->phylist)) 1182 if (clock->chosen && !list_empty(&clock->phylist))
1175 recalibrate(clock); 1183 recalibrate(clock);
1176 else 1184 else {
1185 mutex_lock(&clock->extreg_lock);
1177 enable_broadcast(phydev, clock->page, 1); 1186 enable_broadcast(phydev, clock->page, 1);
1187 mutex_unlock(&clock->extreg_lock);
1188 }
1178 1189
1179 enable_status_frames(phydev, true); 1190 enable_status_frames(phydev, true);
1191
1192 mutex_lock(&clock->extreg_lock);
1180 ext_write(0, phydev, PAGE4, PTP_CTL, PTP_ENABLE); 1193 ext_write(0, phydev, PAGE4, PTP_CTL, PTP_ENABLE);
1194 mutex_unlock(&clock->extreg_lock);
1195
1181 return 0; 1196 return 0;
1182} 1197}
1183 1198