Skip to content

Commit 96522ee

Browse files
moonlinuxvinodkoul
authored andcommitted
phy: rockchip-pcie: Refactor mutex handling in rockchip_pcie_phy_power_on()
Refactor the mutex handling in the rockchip_pcie_phy_power_on() 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_deassert() or regmap_read_poll_timeout() 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 bb70d1a commit 96522ee

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,17 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
163163

164164
mutex_lock(&rk_phy->pcie_mutex);
165165

166-
if (rk_phy->pwr_cnt++)
167-
goto err_out;
166+
if (rk_phy->pwr_cnt++) {
167+
mutex_unlock(&rk_phy->pcie_mutex);
168+
return 0;
169+
}
168170

169171
err = reset_control_deassert(rk_phy->phy_rst);
170172
if (err) {
171173
dev_err(&phy->dev, "deassert phy_rst err %d\n", err);
172-
goto err_pwr_cnt;
174+
rk_phy->pwr_cnt--;
175+
mutex_unlock(&rk_phy->pcie_mutex);
176+
return err;
173177
}
174178

175179
regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf,
@@ -226,13 +230,11 @@ static int rockchip_pcie_phy_power_on(struct phy *phy)
226230
goto err_pll_lock;
227231
}
228232

229-
err_out:
230233
mutex_unlock(&rk_phy->pcie_mutex);
231-
return 0;
234+
return err;
232235

233236
err_pll_lock:
234237
reset_control_assert(rk_phy->phy_rst);
235-
err_pwr_cnt:
236238
rk_phy->pwr_cnt--;
237239
mutex_unlock(&rk_phy->pcie_mutex);
238240
return err;

0 commit comments

Comments
 (0)