Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <linux.amoon@gmail.com>
Link: https://lore.kernel.org/r/20241012071919.3726-6-linux.amoon@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Anand Moon and committed by
Vinod Koul
96522eeb bb70d1aa

+8 -6
+8 -6
drivers/phy/rockchip/phy-rockchip-pcie.c
··· 163 163 164 164 mutex_lock(&rk_phy->pcie_mutex); 165 165 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 + } 168 170 169 171 err = reset_control_deassert(rk_phy->phy_rst); 170 172 if (err) { 171 173 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; 173 177 } 174 178 175 179 regmap_write(rk_phy->reg_base, rk_phy->phy_data->pcie_conf, ··· 230 226 goto err_pll_lock; 231 227 } 232 228 233 - err_out: 234 229 mutex_unlock(&rk_phy->pcie_mutex); 235 - return 0; 230 + return err; 236 231 237 232 err_pll_lock: 238 233 reset_control_assert(rk_phy->phy_rst); 239 - err_pwr_cnt: 240 234 rk_phy->pwr_cnt--; 241 235 mutex_unlock(&rk_phy->pcie_mutex); 242 236 return err;