Skip to content

Commit 02545aa

Browse files
quic-bjorandevinodkoul
authored andcommitted
phy: qcom-qmp-combo: Move phy_mutex out of com_init/exit
With the upcoming introduction of USB Type-C orientation switching the region of mutual exclusion needs to be extended to cover both the common init/exit as well as the individual functions. So move the phy_mutex one step up the stack. Reviewed-by: Johan Hovold <[email protected]> Tested-by: Abel Vesa <[email protected]> Tested-by: Steev Klimaszewski <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on HDK8450 Tested-by: Johan Hovold <[email protected]> # X13s Signed-off-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 6c0237d commit 02545aa

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

drivers/phy/qualcomm/phy-qcom-qmp-combo.c

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,11 +2463,8 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
24632463
void __iomem *com = qmp->com;
24642464
int ret;
24652465

2466-
mutex_lock(&qmp->phy_mutex);
2467-
if (qmp->init_count++) {
2468-
mutex_unlock(&qmp->phy_mutex);
2466+
if (qmp->init_count++)
24692467
return 0;
2470-
}
24712468

24722469
ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs);
24732470
if (ret) {
@@ -2514,8 +2511,6 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
25142511
qphy_setbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL],
25152512
SW_PWRDN);
25162513

2517-
mutex_unlock(&qmp->phy_mutex);
2518-
25192514
return 0;
25202515

25212516
err_assert_reset:
@@ -2524,7 +2519,6 @@ static int qmp_combo_com_init(struct qmp_combo *qmp)
25242519
regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
25252520
err_decrement_count:
25262521
qmp->init_count--;
2527-
mutex_unlock(&qmp->phy_mutex);
25282522

25292523
return ret;
25302524
}
@@ -2533,20 +2527,15 @@ static int qmp_combo_com_exit(struct qmp_combo *qmp)
25332527
{
25342528
const struct qmp_phy_cfg *cfg = qmp->cfg;
25352529

2536-
mutex_lock(&qmp->phy_mutex);
2537-
if (--qmp->init_count) {
2538-
mutex_unlock(&qmp->phy_mutex);
2530+
if (--qmp->init_count)
25392531
return 0;
2540-
}
25412532

25422533
reset_control_bulk_assert(cfg->num_resets, qmp->resets);
25432534

25442535
clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks);
25452536

25462537
regulator_bulk_disable(cfg->num_vregs, qmp->vregs);
25472538

2548-
mutex_unlock(&qmp->phy_mutex);
2549-
25502539
return 0;
25512540
}
25522541

@@ -2556,21 +2545,29 @@ static int qmp_combo_dp_init(struct phy *phy)
25562545
const struct qmp_phy_cfg *cfg = qmp->cfg;
25572546
int ret;
25582547

2548+
mutex_lock(&qmp->phy_mutex);
2549+
25592550
ret = qmp_combo_com_init(qmp);
25602551
if (ret)
2561-
return ret;
2552+
goto out_unlock;
25622553

25632554
cfg->dp_aux_init(qmp);
25642555

2565-
return 0;
2556+
out_unlock:
2557+
mutex_unlock(&qmp->phy_mutex);
2558+
return ret;
25662559
}
25672560

25682561
static int qmp_combo_dp_exit(struct phy *phy)
25692562
{
25702563
struct qmp_combo *qmp = phy_get_drvdata(phy);
25712564

2565+
mutex_lock(&qmp->phy_mutex);
2566+
25722567
qmp_combo_com_exit(qmp);
25732568

2569+
mutex_unlock(&qmp->phy_mutex);
2570+
25742571
return 0;
25752572
}
25762573

@@ -2687,14 +2684,19 @@ static int qmp_combo_usb_init(struct phy *phy)
26872684
struct qmp_combo *qmp = phy_get_drvdata(phy);
26882685
int ret;
26892686

2687+
mutex_lock(&qmp->phy_mutex);
26902688
ret = qmp_combo_com_init(qmp);
26912689
if (ret)
2692-
return ret;
2690+
goto out_unlock;
26932691

26942692
ret = qmp_combo_usb_power_on(phy);
2695-
if (ret)
2693+
if (ret) {
26962694
qmp_combo_com_exit(qmp);
2695+
goto out_unlock;
2696+
}
26972697

2698+
out_unlock:
2699+
mutex_unlock(&qmp->phy_mutex);
26982700
return ret;
26992701
}
27002702

@@ -2703,11 +2705,18 @@ static int qmp_combo_usb_exit(struct phy *phy)
27032705
struct qmp_combo *qmp = phy_get_drvdata(phy);
27042706
int ret;
27052707

2708+
mutex_lock(&qmp->phy_mutex);
27062709
ret = qmp_combo_usb_power_off(phy);
27072710
if (ret)
2708-
return ret;
2711+
goto out_unlock;
27092712

2710-
return qmp_combo_com_exit(qmp);
2713+
ret = qmp_combo_com_exit(qmp);
2714+
if (ret)
2715+
goto out_unlock;
2716+
2717+
out_unlock:
2718+
mutex_unlock(&qmp->phy_mutex);
2719+
return ret;
27112720
}
27122721

27132722
static int qmp_combo_usb_set_mode(struct phy *phy, enum phy_mode mode, int submode)

0 commit comments

Comments
 (0)