Skip to content

Commit bb70d1a

Browse files
moonlinuxvinodkoul
authored andcommitted
phy: rockchip-pcie: Refactor mutex handling in rockchip_pcie_phy_power_off()
Refactor the mutex handling in the rockchip_pcie_phy_power_off() function to improve code readability and maintainability. The goto statement has been removed, and the mutex_unlock call is now directly within the conditional block. Return the result of reset_control_assert() function, with 0 indicating success and an error code indicating failure Signed-off-by: Anand Moon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent cb0ba26 commit bb70d1a

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

drivers/phy/rockchip/phy-rockchip-pcie.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,24 @@ static int rockchip_pcie_phy_power_off(struct phy *phy)
132132
PHY_LANE_IDLE_MASK,
133133
PHY_LANE_IDLE_A_SHIFT + inst->index));
134134

135-
if (--rk_phy->pwr_cnt)
136-
goto err_out;
135+
if (--rk_phy->pwr_cnt) {
136+
mutex_unlock(&rk_phy->pcie_mutex);
137+
return 0;
138+
}
137139

138140
err = reset_control_assert(rk_phy->phy_rst);
139141
if (err) {
140142
dev_err(&phy->dev, "assert phy_rst err %d\n", err);
141-
goto err_restore;
143+
rk_phy->pwr_cnt++;
144+
regmap_write(rk_phy->reg_base,
145+
rk_phy->phy_data->pcie_laneoff,
146+
HIWORD_UPDATE(!PHY_LANE_IDLE_OFF,
147+
PHY_LANE_IDLE_MASK,
148+
PHY_LANE_IDLE_A_SHIFT + inst->index));
149+
mutex_unlock(&rk_phy->pcie_mutex);
150+
return err;
142151
}
143152

144-
err_out:
145-
mutex_unlock(&rk_phy->pcie_mutex);
146-
return 0;
147-
148-
err_restore:
149-
rk_phy->pwr_cnt++;
150-
regmap_write(rk_phy->reg_base,
151-
rk_phy->phy_data->pcie_laneoff,
152-
HIWORD_UPDATE(!PHY_LANE_IDLE_OFF,
153-
PHY_LANE_IDLE_MASK,
154-
PHY_LANE_IDLE_A_SHIFT + inst->index));
155153
mutex_unlock(&rk_phy->pcie_mutex);
156154
return err;
157155
}

0 commit comments

Comments
 (0)